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

using namespace std;
#define pb push_back
#define ALL(a) (a).begin() , a.end()
typedef long long ll;
int mod = 1e9 + 7;
int add(int a, int b){
  if(a + b >= mod)return a+ b - mod;
  return a + b;
}
int mul(int a, int b){
  return 1LL * a * b  % mod;
}
int power(int a, int b){
  int re = 1;
  while(b){
    if(b&1)re= mul(re, a);
    a = mul(a, a);
    b>>=1;
  }
  return re;
}
int const N = 100 *1001;
/********************i**********************************/
vector<int> edge[N], visited(N), child(N);
vector<pair<ll, int>> cont(N);
int co = 0;
void dfs1(int a, int p){
  co++;
  visited[a] = 1;
  for(int x : edge[a]){
    if(x == p)continue;
    dfs1(x, a);
  }

}
void dfs(int a, int p){
  auto &f = cont[a].first; 
  cont[a].second = a;
  child[a] = 1;
  for(int x : edge[a]){
    if(x == p)continue;
    dfs(x, a);
    f += 1LL * child[a] * child[x];
    child[a] += child[x];
  }
  f += 1LL * (co - child[a] ) * child[a]; 
}
void solve(){
  int a, b;
  cin >> a >> b;
  cout << (a / b) + (a % b != 0) << "\n";
}
/******************************************************/
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(nullptr);
  int t;
  t = 1;
  // cin >> t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 4992
using System;
public class Hello{
    public static void Main(){
      var n=0;
      int ans=1;
      n=int.Parse(Console.ReadLine());
      int[] d=new int[n];
      for(int i=0;i<n;i++){
        d[i]=int.Parse(Console.ReadLine());
      }
      Array.Sort(d);
      int newsize=d[0];
      for(int i=0;i<n;i++){
        if(newsize<d[i]){
          ans++;
          newsize=d[i];
        }
      }
      Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main()
{
	int n, t, c[6] = {500, 100, 50, 10, 5, 1}, i, s, m, u;
	while (cin >> n && n)
	{
		t = 1000 - n;
		m = 0;
		while (t)
		{
			if (t >= 500)		s = 0;
			else if (t >= 100)	s = 1;
			else if (t >= 50)	s = 2;
			else if (t >= 10)	s = 3;
			else if (t >= 5)	s = 4;
			else				s = 5;
			for (i = s; i < 6; i++)
			{
				u = t / c[i];
				m += u;
				t -= c[i] * u;
			}
		}
		cout << m << endl;
	}
}

Measured memory_bytes: 0
N = int(input())
a = list(map(int, input().split()))
L = [False]*8
cnt = 0
for i in range(N):
    for j in range(8):
        if j*400 <= a[i] <= j*400+399:
            L[j] = True
    if a[i] >= 3200:
        cnt += 1
if L.count(1):
    minnum = L.count(1)
else:
    minnum = 1
maxnum = min(N, minnum+cnt)
print(minnum, maxnum)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    if (n % 1111 == 0)
        cout << "Yes" << endl;
    else if ((n % 1000) % 111 == 0)
        cout << "Yes" << endl;
    else if (n % 1110 < 10)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;  
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<stack>
using namespace std;
int s[3005][3005]={0};
char a[3005],b[3005];

int main()
{
	cin>>a>>b;
	string ans="";
	int len_a=strlen(a);
	int len_b=strlen(b);
	for(int i=1;i<=len_a;i++)
	{
		
		for(int j=1;j<=len_b;j++)
		{
			if(a[i-1]==b[j-1])
			{
				s[i][j]=s[i-1][j-1]+1;
				ans+=a[i-1];
			}
			
			else
			s[i][j]=max(s[i-1][j],s[i][j-1]);
		}
	}
	//cout<<s[len_a][len_b]<<endl;
	//cout<<ans<<endl;
	stack<char>s1;
	int i=len_a,j=len_b;
	while(s[i][j]!=0)
	{
		if(s[i][j]==s[i-1][j])
			i--;
		else if(s[i][j]==s[i][j-1])
			j--;
		else if(s[i][j]>s[i-1][j-1])
		{
			i--,j--;
			s1.push(b[j]);
		}	
	}
	char temp; 
	while(!s1.empty())
	{
		temp=s1.top();
		s1.pop();
		cout<<temp;
	}
	return 0;
}

Measured memory_bytes: 53380
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int dp[11][8][2];
int main(){
    string N;
    cin >> N;
    int d=N.size();
    vector<int> n(d);
    rp(i,d) n[i]=N[i]-'0';
    for(int i=1; i<d; i++)dp[i][0][1]=1;
    dp[0][0][0]=1;
    rp(i,d){
        rp(j,8){
            rp(smaller,2){
                if(!smaller&&n[i]<3) continue;
                dp[i+1][j|1][smaller||(3<n[i])]+=dp[i][j][smaller];
                if(!smaller&&n[i]<5) continue;
                dp[i+1][j|2][smaller||(5<n[i])]+=dp[i][j][smaller];
                if(!smaller&&n[i]<7) continue;
                dp[i+1][j|4][smaller||(7<n[i])]+=dp[i][j][smaller];
            }
        }
    }
    cout << dp[d][7][0]+dp[d][7][1] << endl;
    return 0;
}

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

long double A[100009], S;
int N;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		S += 1.0L / A[i];
	}
	printf("%.12Lf\n", 1.0L / S);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <numeric>

using namespace std;

#define int long long

signed main()
{
    int n;
    vector<int> a;
    vector<int> b;

    cin >> n;

    a.resize(n + 1);
    b.resize(n);

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

    for(int i = 0; i < n; ++i)
    {
        cin >> b[i];
    }

    int ans = 0;
    for(int i = 0; i < n; ++i)
    {
        int current = min(a[i], b[i]);
        ans += current;
        b[i] -= current;

        int next = min(a[i + 1], b[i]);
        ans += next;
        a[i + 1] -= next;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

ll dp[110][2][10];

int main() {
    string s; int k;
    cin >> s >> k;

    int n = s.size();
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        int now = s[i] - '0';
        for (int smaller = 0; smaller < 2; smaller++) {
            for (int j = 0; j <= 3; j++) {
                for (int x = 0; x <= (smaller ? 9 : now); x++) {
                    if (x == 0) {
                        dp[i+1][smaller || x < now][j] += dp[i][smaller][j];
                    }
                    if (x > 0) {
                        dp[i+1][smaller || x < now][j+1] += dp[i][smaller][j];
                    }
                }
            }
        }
    }
    cout << dp[n][0][k] + dp[n][1][k] << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
    }
    let ans = b / a;
    println!("{}", std::cmp::min(ans, c));
}


Measured memory_bytes: 4352
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

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


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

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int t = sc.nextInt();
		int[] a = new int[n];

		for(int i = 0;i < n;i++){
			a[i] = sc.nextInt();
		}
		int[] big = new int[n];				//i番目以降で一番大きい数を収納
		int bigmin = 0;
		for(int i = n-1;i>=0;i--){
			bigmin = Math.max(bigmin, a[i]);
			big[i] = bigmin; 
		}
		int data[] = new int[n];
		for(int i = 0;i < n;i++){
			data[i] = big[i] -a[i];
		}
		Arrays.sort(data);
		int maxnum = data[n-1];
		int ans = 0;
		for(int i = 0;i < n;i++){
			if(data[i] == maxnum){
				ans++;
			}
				
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 50460
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

ll imos[55][55];

int main(){

	ll N, K;
	cin >> N >> K;
	vector<ll>X(N), Y(N);
	set<ll>XS, YS;
	for(ll i = 0; i < N; i++){
		cin >> X[i] >> Y[i];
		XS.insert(X[i]);
		YS.insert(Y[i]);
	}
	vector<ll>XI(1, -1145141919), YI(1, -1145141919);
	for(set<ll>::iterator it = XS.begin(); it != XS.end(); it++){
		XI.push_back(*it);
	}
	for(set<ll>::iterator it = YS.begin(); it != YS.end(); it++){
		YI.push_back(*it);
	}
	for(ll i = 0; i < N; i++){
		ll xidx = 0, yidx = 0;
		while(XI[xidx] < X[i])xidx++;
		while(YI[yidx] < Y[i])yidx++;
		imos[yidx][xidx]++;
	}
	for(ll y = 1; y < 55; y++){
		for(ll x = 1; x < 55; x++){
			imos[y][x] += imos[y - 1][x];
		}
	}
	for(ll x = 1; x < 55; x++){
		for(ll y = 1; y < 55; y++){
			imos[y][x] += imos[y][x - 1];
		}
	}
	ll ans = (1145141919) * (1145141919LL) * 4LL;
	for(ll l = 1; l < XI.size(); l++){
		for(ll r = l; r < XI.size(); r++){
			for(ll u = 1; u < YI.size(); u++){
				for(ll d = u; d < YI.size(); d++){
					if(imos[d][r] - imos[d][l - 1] - imos[u - 1][r] + imos[u - 1][l - 1] >= K){
						ans = min(ans, (XI[r] - XI[l]) * (YI[d] - YI[u]));
					}
				}
			}
		}
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[100005],b[100005],cnt=0;
vector<pair<long long,long long> > v;
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i-1],&b[i-1]);
		v.push_back(make_pair(a[i-1],b[i-1]));
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		cnt+=v[i].second;
		if(cnt>=k)
		{
			printf("%lld",v[i].first);
			break;
		}
	}
}

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

#define MAX_M 100000
struct req {
	int a, b;
};

bool judge(const req& r1, const req& r2) {
	return r1.a < r2.a || (r1.a == r2.a && r1.b < r2.b);
}

int main() {
	int N, M;
	req R[MAX_M];
	int fin = 0;
	int st, lim;
	int res = 0;

	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d%d", &R[i].a, &R[i].b);
	}

	sort(R, R + M, judge);

	while (fin < M) {
		st = R[fin].a;
		lim = R[fin].b;
		fin++;
		if (fin < M) {
			for (int i = st; i < lim; i++) {
				while (i >= R[fin].a) {
					lim = min(lim, R[fin].b);
					fin++;
					if (fin >= M) break;
				}
				if (fin >= M) break;
			}
		}
		res++;
	}

	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 896
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,C = map(int, lines.pop(0).split(' '))
    if min(A,B) < C and C < max(A,B):
        print('Yes')
    else:
        print('No')
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
	return in % Mod;
}
template<class T>
constexpr T UP(T left, T div) {
	return (left + div - 1) / div;
}

int n;
int main()
{
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);

	std::cin >> n;

	std::map<ll, int> m;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		std::cin >> x;
		m[x]++;
		ans ^= x;
	}
	if (m.size() == 1 && m.count(0) > 0) {
		std::cout << "Yes" << std::endl;
		return 0;
	}
	if (m.size() > 3 || n % 3 != 0) {
		std::cout << "No" << std::endl;
		return 0;
	}
	if (ans != 0) {
		std::cout << "No" << std::endl;
		return 0;
	}
	std::cout << "Yes" << std::endl;

	return 0;
}


Measured memory_bytes: 5120
use proconio::input;

fn gcd(mut x: u32, mut y: u32) -> u32 {
    if x > y {
        std::mem::swap(&mut x, &mut y);
    }
    if x == 0 {
        y
    } else {
        gcd(x, y % x)
    }
}

fn main() {
    input!(a: u32, b: u32, c: u32);
    println!(
        "{}",
        if gcd(b, c) % gcd(a, b) == 0 {
            "YES"
        } else {
            "NO"
        }
    );
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


void solve()
{
  int s;
  cin >> s;
  vector<mint> ans(s + 1, 1);
  ans[0] = ans[1] = ans[2] = 0;
  for(int i = 3; i <= s; ++i)
  {
  //cout << i << ":: " << endl;
    for(int j = 3; j <= i / 2; ++j)
    {
      ans[i] += ans[i - j] + ans[j];
      if (i - j  == j) ans[i]-=ans[j];
      //cout << ans[i] << endl;
    }
  }

  for(int i = 0; i <= s; ++i)
  {
   // cout << i << ": " << ans[i] << endl;
  }
  cout << ans[s];
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  string S;
  cin >> S;
  vector<bool> check(26, false);
  
  for (int i = 0; i < S.size(); i++) {
    check[S[i] - 'a'] = true;
  }
  for (int i = 0; i < 26; i++) {
    if (!check[i]) {
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

int main() {
  int in(N);
  N %= 10;

  if (N == 2 || N == 4 ||
      N == 5 || N == 7 ||
      N == 9)
    cout << "hon" << endl;
  else if (N == 3)
    cout << "bon" << endl;
  else
    cout << "pon" << endl;

  return 0;
}


Measured memory_bytes: 3636
use proconio::input;
 
fn main() {
  input! {
    d: u32,
    n: usize
  }
  if n == 100 {
    println!("{}", (n + 1) * 100usize.pow(d));
  } else {
    println!("{}", n * 100usize.pow(d));  
  }
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int a,b;
  while(cin>>a>>b,a||b) {
    if (a>b) swap(a,b);
    cout << a << " " << b << endl;
  }  
}



Measured memory_bytes: 2980
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int a,b;
  string s;
  cin >> a >> b >> s;
  rep(i,a){
    int tmp = s.at(i) - '0';
    if(0 <= tmp && tmp <= 9) continue;
    cout << "No" << endl;
    return 0;
  }
  if(s.at(a) != '-'){
    cout << "No" << endl;
    return 0;
  }
  rep(i,b){
    int tmp = s.at(a+1+i) - '0';
    if(0 <= tmp && tmp <= 9) continue;
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
  double ans = 0;
  int count = 0;
  int N;
  cin >> N;
  vector<pair<int, int>> points;
  for(int i=0;i<N;i++){
    pair<int, int> p;
    cin >> p.first;
    cin >> p.second;
    points.push_back(p);
  }
  sort(points.begin(), points.end());
  do{
    int sx = points[0].first;
    int sy = points[0].second;
    for(int i=1; i<N; i++){
      ans += sqrt(pow((sx-points[i].first), 2) + pow((sy-points[i].second), 2));
      sx = points[i].first;
      sy = points[i].second;
    }
    count++;
  }while(next_permutation(points.begin(), points.end()));
  cout << setprecision(10) << (double)ans/count << endl;
  return 0;
}

Measured memory_bytes: 3856
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
j=False
while n!=0:
    if n%10==7:
        j=True
    n=n//10
if j:
    print("Yes")
else:
    print("No")

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

void smallToLarge( char& a )
{
    if( 'a' <= a && a <= 'z' )
        a -= ( 'a' - 'A' );
}

void LargeToSmall( char& a )
{
    if( 'A' <= a && a <= 'Z' )
        a += ( 'a' - 'A' );
}

int main()
{
    string s;
    char c;

    while( cin >> s >> c )
    {
        int a = s.size();

        if( c == 'X' )
            break;
        else if( c == 'U' || c == 'L' )
        {
            c == 'U' ? smallToLarge(s[0]) : LargeToSmall(s[0]);
            for( int i = 0; i < a; i++ )
                if( s[i] == '_' )
                    smallToLarge(s[i+1]);
                else
                    cout << s[i];
        }
        else
        {
            LargeToSmall(s[0]);
            for( int i = 0; i < a; i++ )
            {
                if( 'A' <= s[i] && s[i] <= 'Z' )
                {
                    cout << '_';
                    LargeToSmall(s[i]);
                }
                cout << s[i];
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3180
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int N = sc.nextInt();
    
    int damage = 0;
    for(int i=0; i<N; i++){
      damage += sc.nextInt();
    }
    
    if(damage >= H){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
    
  }
}

Measured memory_bytes: 49604
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int a,b,c;
   cin >> a >> b >> c;

   int ans = a + b + c;

   if(ans >= 22) cout << "bust" << endl;
   else cout << "win" << endl;




   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int top,S[1000] ;

void push(int x){
	S[++top] = x;
}

int pop(){
	top--;
	return S[top + 1];
}

int main(){
	int a, b;
	top = 0;
	char s[100];
	while(scanf("%s",s) != EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		} 
		else if(s[0] == '-'){
			a = pop();
			b = pop();
			push(b - a);
		}
		else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b); 
		} 
		else{
			push(atoi(s));
		}
	}
	int ans = pop();
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2088
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        for(int i = x; i <= Math.pow(10, 9); i++){
            if(isPrime(i)){
                System.out.println(i);
                return;
            }
        }
        scan.close();
    }
    
    public static boolean isPrime(int n){
        for(int i = 2; i <= Math.sqrt(n); i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


Measured memory_bytes: 27096
A = int(input())
B = int(input())
C = int(input())
D = int(input())

if(A<B):
  if(C<D):
    print(A+C)
  else:
    print(A+D)
else:
  if(C<D):
    print(B+C)
  else:
    print(B+D)
    

Measured memory_bytes: 2940
n, m = map(int, input().split())
a_list = list(map(int, input().split()))

sum_list = [0 for _ in range(n)]
sum_list[0] = a_list[0]
for i in range(n - 1):
    sum_list[i + 1] += sum_list[i] + a_list[i + 1]

c_list = [0]
for s in sum_list:
    c_list.append(s % m)
from collections import Counter

counter = Counter(c_list)
count = 0

for k, v in counter.items():
    if v >= 2:
        count += v * (v - 1) // 2

print(count)


Measured memory_bytes: 18728
for _ in[0]*int(input()):
 a,b,c,d,e,f=map(float,input().split())
 x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
 y=((a*a+b*b)*(c-e)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
 print(f"{x:.3f} {y:.3f} {((x-a)**2+(y-b)**2)**.5:.3f}")


Measured memory_bytes: 5684
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int cnt[10];
int32_t main(){
    string a;
    cin >> a;
    int a1 = 0,b1 = 0;
    string b = "keyence",c = "ecneyek";
    for (int i = 0;i < 7;i++){
        if (a[i] == b[i]) a1++;
        else break;
    }
    int n = a.length() - 1;
    for (int i = 0;i < 7;i++){
        if (c[i] == a[n - i]) b1++;
        else break;
    }
    if (a1 + b1 >= 7){
        cout << "YES"<< endl;
    }else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    map<string,int>m;
    char p;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        m[s]++;
        if(m[s]>1){
            cout<<"No"<<endl;
            return 0;
        }
        if(i==0){
            p=s.back();
        }else{
            if(s[0]!=p){
                cout<<"No"<<endl;
                return 0;
            }else{
                p=s.back();
            }
        }
    }
    //cout<<m["aaa"]<<endl;
    cout<<"Yes"<<endl;
    
    return 0;
    
}



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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

const char sp = ' ';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

int main(){

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

    int n, a, b, c;
    cin >> n >> a >> b >> c;

    vector<int> l(n);
    rep(i, n){
        cin >> l[i];
    }

    int mp = INT_MAX;
    for(int i = 0; i < static_cast<int>(pow(4,n)); ++i){
        int tmpa = 0, tmpb = 0, tmpc = 0;
        int cnta = 0, cntb = 0, cntc = 0;
        int tmp = 0;
        for(int j = 0; j < n; ++j){
            if((i/static_cast<int>(pow(4,j)))%4 == 0){
                tmpa += l[j];
                ++cnta;
            }
            else if((i/static_cast<int>(pow(4,j)))%4 == 1){
                tmpb += l[j];
                ++cntb;
            }
            else if((i/static_cast<int>(pow(4,j)))%4 == 2){
                tmpc += l[j];
                ++cntc;
            }
        }
        tmp = abs(a-tmpa) + abs(b-tmpb) + abs(c-tmpc);
        if(cnta == 0 or cntb == 0 or cntc == 0) continue;
        mp = min(mp, tmp + 10*max(cnta-1, 0) + 10*max(cntb-1, 0) + 10*max(cntc-1, 0));
    }

    ppp(mp);

    return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

func main() {
	var x, k, d float64
	fmt.Scan(&x, &k, &d)

	x = math.Abs(x)

	st := math.Min(k, float64(int64(x) / int64(d)))
	k -= st
	x -= st * d

	if int64(k) % 2 == 0 {
		fmt.Printf("%.0f\n", x)
	} else {
		fmt.Printf("%.0f\n", d - x)
	}
}


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

#define int long long
#define REP(i, l, r) REPEAT(i,l,r,true) // [l, r)
#define rep(i, n) REP(i,0,n)           // [0, n)
#define REPEAT(i, l, r, condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n, l, r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...) true
#define showlr(n,l,r) true
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int, int>;

struct io {
    io() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.tie(0);
        cout << fixed << setprecision(20);
    }
} io;

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &e:v)is >> e;
    return is;
}

template<class T>
ostream &operator<<(ostream &os, vector<T> v) {
    os << "{";
    for (T &e:v)os << e << (v.size() - (int) (&e - &v[0]) > 1 ? ", " : "");
    os << "}";
    return os;
}

void _DEBUG() {}

template<typename H, typename... T>
void _DEBUG(H a, T...b) {
    cerr << a << (sizeof...(b) ? "," : "\n");
    _DEBUG(b...);
}

inline void in() {}

template<typename H, typename... T>
void in(H &a, T &... b) {
    cin >> a;
    in(b...);
}

inline void out() {}

template<typename H, typename... T>
void out(H a, T... b) {
    cout << a << (sizeof...(b) ? " " : "\n");
    out(b...);
}

template<class T>
void resz(int n, T &v) { v.resize(n); }

template<class H, class... T>
void resz(int n, H &a, T &... b) {
    a.resize(n);
    resz(n, b...);
}

template<typename V, typename H>
void resize(vector<V> &v, const H a) { v.resize(a); }

template<typename V, typename H, typename... T>
void resize(vector<V> &v, const H &a, const T... b) {
    v.resize(a);
    for (auto &v:v) resize(v, b...);
}

template<class T, class U>
void chmin(T &t, const U u) { if (t > u) t = u; }

template<class T, class U>
void chmax(T &t, const U u) { if (t < u) t = u; }

const int INF = 1LL << 55;
const int MOD = 1000000007;
const double EPS = 1e-8;

/*------------end of definitions------------*/

int N, M;

void solve() {
    vector<vi> V(N, vi(M));
    rep(i, M) {
        rep(j, N) {
            in(V[j][i]);
        }
    }
    int res = -1;
    rep(i, N) {
        int tmp = 0;
        for_each(all(V[i]), [&tmp](int x) { tmp += x; });
        chmax(res, tmp);
    }

    out(res);
}

signed main() {

    while (in(N, M), N) {
        solve();
    }

    return 0;
}



Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
string check[]={"AA","AB","AX","AY","BA","BB","BX","BY","XA","XB","XX","XY","YA","YB","YX","YY"};
int dp[1001];

signed main(){
  int n;
  cin>>n;
  int ans=0;
  rep(i,n+1){
    if(i%3>0&&i%5>0) ans+=i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  int s = n.size();
  int sum=0;
  for(int i=0;i<s;i++){
    sum += n.at(i)-48;
  }
//  cout << sum << endl;
  if(sum%9 == 0){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define ll long long int
#define si(x)    scanf("%d",&x)
#define sl(x)    scanf("%lld",&x)
#define ss(s)    scanf("%s",s)
#define pi(x)    printf("%d\n",x)
#define pl(x)    printf("%lld\n",x)
#define ps(s)    printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>    pii;
typedef pair<ll, ll>    pl;
typedef vector<int>        vi;
typedef vector<ll>        vl;
typedef vector<pii>        vpii;
typedef vector<pl>        vpl;
typedef vector<vi>        vvi;
typedef vector<vl>        vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
const int mod = 1000000007;
//=======================

int arr[100005], n, k;
int dp[100005];

int frog(int i)
{
    if(i == n)
        return 0;

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

    int mini = 1e9;
    for(int x = i+1; x<=min(n, i+k); x++)
        {
            mini = min(mini, abs(arr[x] - arr[i]) + frog(x));
        }

    return dp[i] = mini;
}
void solve() {
    cin>>n>>k;

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

     for(int i = 1; i<=n; i++)
        cin>>arr[i];
    
     cout<<frog(1)<<endl;


}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    solve();

    return 0;
}


Measured memory_bytes: 10684
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define MOD 1000000007
#define mod 998244353
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define si set<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define vvii vector<vii>
#define vsi vector<si>
#define endl "\n"
#define rep(i, n) for(i = 0; i < (n); i++)
#define rrep(i, n) for(i = (n - 1); i >= 0; i--)
#define MAXN 200001
#define read(arr,n) for(int i=0;i<n;i++)cin>>arr[i]
using namespace std;
void solve1();

int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool comp(pii a,pii b)
{
    return a.ss<b.ss;
}
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    int n;cin>>n;int a,b;
    int arr[n]={0};
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;if(a==b)arr[i]=1;
    }
    for(int i=0;i<n-2;i++)
    {
        if(arr[i]==1&&arr[i+1]==1&&arr[i+2]==1)
        {
            cout<<"Yes"<<endl;return;
        }
    }
    cout<<"No"<<endl;
}




Measured memory_bytes: 3648
import copy
n, m, q = map(int, input().split())

aaa = [[1]]
bbb = []

for i in range(n-1):
  for aa in aaa:
    for j in range(aa[-1], m+1):
      tmp = copy.copy(aa)
      tmp.extend([j])
      bbb.append(tmp)
  aaa = bbb
  if i < n-2:
    bbb = []

qs = []
for i in range(q):
  a, b, c, d = map(int, input().split())
  qs.append(a)
  qs.append(b)
  qs.append(c)
  qs.append(d)

ans = 0
for bb in bbb:
  score = 0
  for i in range(0, len(qs), 4):
    if bb[qs[i+1]-1] - bb[qs[i+0]-1] == qs[i+2]:
      score += qs[i+3]
  ans = max(ans, score)

print(ans)
  
  

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

cum_sum = [0 for i in range(N)]
cum_sum[0] = a[0]
for i in range(1, N):
    cum_sum[i] = a[i] + cum_sum[i - 1]
    
ans = 2000000000000000
for i in range(0, N - 1):
    ans = min(ans, abs(cum_sum[i] - (cum_sum[N - 1] - cum_sum[i])))
    
print(ans)

Measured memory_bytes: 24824
N = int(input())
W = list(map(int,input().split()))
A = [0 for _ in range(N)]
A[0] = W[0]
for i in range(1,N):
    A[i] = A[i-1]+W[i]
cmin = A[N-1]
for i in range(N):
    cmin = min(cmin,abs(2*A[i]-A[N-1]))
print(cmin)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define int long long
#define ll unsigned long long
#define ld long double
#define mx 100005
#define mod 1000000007
#define fr first
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

int tc=1;

struct hello
{
    int r,b,g;
    hello(){
        r=0, b=0, g=0;
    }

} tree[4005];

void solve(int kk)
{
    int n;
     string s1;
     cin >> n >> s1;
     int sum=0;

        tree[0].r=(s1[0] == 'R');
        tree[0].g=(s1[0] == 'G');
        tree[0].b=(s1[0] == 'B');

     for(int i=1; i<n; i++){
        tree[i].r=tree[i-1].r+(s1[i] == 'R');
        tree[i].g=tree[i-1].g+(s1[i] == 'G');
        tree[i].b=tree[i-1].b+(s1[i] == 'B');
     }

     for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(s1[i]!=s1[j]){
                int cc;
                if(s1[i] == 'R'){
                    if(s1[j] == 'B'){
                        sum+=(tree[n-1].g-tree[j].g);
                        if(s1[(2*j)-i] == 'G') sum--;
                        //sum-=(tree[j].g);
                    }
                    else if(s1[j] == 'G'){
                        sum+=(tree[n-1].b-tree[j].b);
                        if(s1[(2*j)-i] == 'B') sum--;
                        //sum-=(tree[j].b);
                    }
                }
                else if(s1[i] == 'B'){
                    if(s1[j] == 'G'){
                        sum+=(tree[n-1].r-tree[j].r);
                        if(s1[(2*j)-i] == 'R') sum--;
                        //sum-=(tree[j].r);
                    }
                    else if(s1[j] == 'R'){
                        sum+=(tree[n-1].g-tree[j].g);
                        if(s1[(2*j)-i] == 'G') sum--;
                        //sum-=(tree[j].g);
                    }
                }
                else if(s1[i] == 'G'){
                    if(s1[j] == 'B'){
                        sum+=(tree[n-1].r-tree[j].r);
                        if(s1[(2*j)-i] == 'R') sum--;
                        //sum-=(tree[j].r);
                    }
                    else if(s1[j] == 'R'){
                        sum+=(tree[n-1].b-tree[j].b);
                        if(s1[(2*j)-i] == 'B') sum--;
                        //sum-=(tree[j].b);
                    }
                }

            }
        }
     }
     cout << sum << "\n";

}

signed main()
{
   //freopen("text.txt", "r", stdin);
   //freopen("text2.txt", "w", stdout);
   fast;
   int kk=0;
   //cin >> tc;
   //scanf("%d", &tc);

   while(++kk<=tc) solve(kk);

   return 0;
}


Measured memory_bytes: 3792
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
#define IO ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);
typedef long long ll;
typedef long double ld;
 
 
 
ll MOD=1e9 + 7;
int OO=1e9 + 1;
const int N=1e3 + 10,M=20;
char arr[N][N];
int vis[N][N];


ll n,m,k,T;
int a,b,c,d;
int l,r,mid;



int main(){
	IO
	//freopen("in.txt","r",stdin);
	
	cin>>n>>k>>m;
	ll val = abs(n)/m;
	if(n < 0)
		n += 1ll*min(k,++val)*m;
	else
		n -= 1ll*min(k,val)*m;
	
	k-=min(k,val);

	if(k&1)
		n-=m;
	cout<<abs(n)<<endl;
}

 

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

int main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  
 for(int i=0;i<1000;i++){
 	
   int c[3]={i/100,(i/10)%10,i%10};
   int f=0;
   for(int j=0;j<n;j++){
     if(s[j]-'0'==c[f]) f++;
     if(f==3) break;
   }
   if(f==3) ans++;
   
 }
  cout<<ans<<endl;
}

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

int main(){
  const long long INF = 1e9;
  int N, M, C, S, G;
  while(cin >> N >> M >> C >> S >> G, N){
    --S,--G;
    vector<vector<vector<long long>>> D(C,vector<vector<long long>>(N,vector<long long>(N,INF)));
    for(int i = 0; i < M; ++i){
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      --x,--y,--c;
      D[c][x][y] = min<long long>(D[c][x][y],d);
      D[c][y][x] = min<long long>(D[c][y][x],d);
    }

    for(auto &d : D){
      for(int i = 0; i < N; ++i) d[i][i] = 0;
      for(int k = 0; k < N; ++k)
        for(int i = 0; i < N; ++i)
          for(int j = 0; j < N; ++j)
            d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    }
    
    vector<long long> P(C);
    for(int i = 0; i < C; ++i) cin >> P[i];

    vector<vector<long long>> E(N,vector<long long>(N,INF));
    for(int i = 0; i < C; ++i){
      vector<long long> Q(P[i]+1), R(P[i]+1);
      for(int j = 0; j+1 < P[i]; ++j) cin >> Q[j+1];
      Q.back() = INF;
      for(int j = 0; j < P[i]; ++j) cin >> R[j+1];
      vector<long long> T(P[i]+1);
      for(int j = 1; j <= P[i]; ++j){
        T[j] += T[j-1];
        T[j] += (Q[j]-Q[j-1])*R[j];
      }
      for(int j = 0; j < N; ++j){
        for(int k = 0; k < N; ++k){
          if(j == k) continue;
          int d = D[i][j][k];
          if(d >= INF) continue;
          int idx = lower_bound(Q.begin(), Q.end(), d) - Q.begin();
          long long cost = (d-Q[idx-1])*R[idx] + T[idx-1];
          E[j][k] = min(E[j][k],cost);
        }
      }
    }
    for(int i = 0; i < N; ++i) E[i][i] = 0;

    for(int k = 0; k < N; ++k)
      for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j)
          E[i][j] = min(E[i][j],E[i][k]+E[k][j]);
    int ans = E[S][G];
    if(ans >= INF) ans = -1;
    cout << ans << endl;
  }
}



Measured memory_bytes: 4748
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define iiii pair<ii,ii>
#define pb push_back
#define fi first
#define se second
using namespace std;
int n,m;
int di,val;
int ans[10];
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin>>n>>m;
	int dim[10];
	for(int i = 0;i<10;i++) dim[i] = -1, ans[i] = -1;
	int ga = 0;
	
	for(int i= 0;i<m;i++){
		cin>>di>>val;
		if(dim[di]!=val && dim[di] !=-1) ga = 1;
		dim[di] = val;
		ans[di] = val;
	}
	if(ga || (!ans[1] && n > 1)) {
		cout<<"-1\n";return 0;
	}
	for(int i = 2;i<=n;i++) if(ans[i] == -1) ans[i] = 0;
	if(ans[1] == -1 && n > 1) ans[1] = 1;
	else if(ans[1] == -1) ans[1] = 0;
	for(int i = 1;i<=n;i++) cout<<ans[i];cout<<"\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;


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

  int a, b, k;
  cin >> a >> b >> k;
  ll g = __gcd(a, b);
  int ans = 0, cnt = 0;
  for(ll i = g; i>= 1; i--){
  	if(g%i == 0){
  		ans = i;
  		cnt++;
  		if(cnt == k)break;
  	}
  }
  cout << ans << endl;

}




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

char s[1010];
int n;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	if (s[0]!='A')
	{
		printf("WA\n");
		return 0;
	}
	int sum=0;
	for (int i=2;i<n-1;i++)
	{
		if (s[i]=='C')	sum++;
	}
	for (int i=1;i<n;i++)
	{
		if (s[i]!='C' && (s[i]<='Z' && s[i]>='A'))
		{
			printf("WA\n");
			return 0;
		}
	}
	if (sum==1)	printf("AC\n");else printf("WA\n");
	return 0;
}

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

#undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

#define VMAX 100001
// #define VMAX 50
vector<vector<int>> to(VMAX * 2);
vector<int> used(VMAX * 2);
int mx = 0;
int my = 0;

void dfs(int v)
{
  if (used[v])
    return;
  used[v] = true;
  if (v < VMAX)
    mx++;
  else
    my++;
  dump(v, mx, my);
  dumpv(to[v]);
  for (int u : to[v]) {
    dfs(u);
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    y += VMAX;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  dumpv(used);
  ll ans = 0;
  for (int i = 0; i < VMAX * 2; i++) {
    mx = 0, my = 0;
    dfs(i);
    ans += (ll)mx * my;
  }
  dumpv(used);
  cout << ans - N << endl;
  return 0;
}


Measured memory_bytes: 10880
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	s1, s2, s3 := next(), next(), next()
	out(strings.ToUpper(string(s1[0]) + string(s2[0]) + string(s3[0])))
}


Measured memory_bytes: 640