akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>

const int maxn = 1e5 + 20;

int n;
char s[maxn];

int main()
{
	int ans = 0;
	
	scanf("%s", s + 1);
	n = strlen(s + 1);
	
	for(int i = 2; i <= n; i++)
	{
		if(s[i] != s[i - 1]) ans++;
	}
	
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double h, v, y, t;
	int i;
	
	while (scanf("%lf", &v) != EOF){
		t = v / 9.8;
		y = 4.9 * t * t;
		
		i = 1;
		while (1){
			if (5 * i - 5 >= y){
				break;
			}
			else {
				i++;
			}
		}
		
		printf("%d\n", i);
	}
	
	return (0);
}

Measured memory_bytes: 628
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;
}


Measured memory_bytes: 3872
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

struct Vector2D
{
	float x, y;

	Vector2D()
	{

	}

	Vector2D(Vector2D v0, Vector2D v1)
	{
		this->x = v1.x - v0.x;
		this->y = v1.y - v0.y;
	}
};

float outer(Vector2D a, Vector2D b)
{
	return a.x * b.y - a.y * b.x;
}

int main()
{
	int n;
	for (cin >> n; n--;)
	{
		vector<Vector2D> p(4);

		for (int i = 0; i < 4; i++)
		{
			cin >> p.at(i).x >> p.at(i).y;
		}

		Vector2D ab = Vector2D(p.at(0), p.at(1));
		Vector2D cd = Vector2D(p.at(2), p.at(3));

		if (outer(ab, cd) == 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  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;
  }
  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, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll dp[110][110000];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    int w[N+1], v[N+1];
    REP(i,1,N+1) cin >> w[i] >> v[i];
    REP(i,1,N+1)
    {
        REP(j,1,W+1)
        {
            dp[i][j] = dp[i-1][j];
            if(j-w[i] >= 0) dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


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

/*
var n = int.Parse(Console.ReadLine());
var s = Console.ReadLine().Split(' ');
var a = new int[100];
for (int i = 0; i < 100; i++) {
    a[i] = int.Parse(s[i]);
}
*/



namespace Test
{
    class MainClass
    {
        static void Main(string[] args) {
            var s = Console.ReadLine().Split(' ');
            var a = new int[3];
            for (int i = 0; i < 3; i++) {
                a[i] = int.Parse(s[i]);
            }
            var list = new List<int> {
                Math.Abs(a[0] - a[1]) + Math.Abs(a[1] - a[2]),
                Math.Abs(a[0] - a[2]) + Math.Abs(a[2] - a[1]),
                Math.Abs(a[1] - a[0]) + Math.Abs(a[0] - a[2]),
                Math.Abs(a[1] - a[2]) + Math.Abs(a[2] - a[0]),
                Math.Abs(a[2] - a[0]) + Math.Abs(a[0] - a[1]),
                Math.Abs(a[2] - a[1]) + Math.Abs(a[1] - a[0]),
            };
            Console.WriteLine(list.Min());
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N;
int A[20];
int x[20][20], y[20][20];
int p[20];

int check(int state){
    REP(i, N){
        if(state & (1 << i)) p[i] = 1;
        else p[i] = 0;
    }
    REP(i, N){
        REP(j, A[i]){
            if(p[i] == 0) continue;
            if(p[x[i][j]] != y[i][j]) return -1;
        }
    }
    return __builtin_popcount(state);
}

signed main(){
    cin >> N;
    REP(i, N){
        cin >> A[i];
        REP(j, A[i]){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int ans = 0;
    REP(i, 1 << N) ans = max(ans, check(i));
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3596
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

  ll n;
  std::cin>>n;

  std::vector<ll> zero(60,0),one(60,0);

  rep(i,0,n){
    ll a;
    std::cin>>a;

    rep(j,0,60){
      if((a>>j)&1)one[j]++;
      else zero[j]++;
    }
  }

  ll ans=0;

  rep(i,0,60){
    ans=(ans+(pow_mod(2,i,MOD)*((zero[i]*one[i])%MOD))%MOD)%MOD;
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll a, b, m;
    cin >> a >> b >> m;
    vector<ll> pa(a), pb(b);
    REP(i, a){ cin >> pa.at(i); }
    REP(i, b){ cin >> pb.at(i); }
    ll ans = *min_element(ALL(pa)) + *min_element(ALL(pb));
    REP(i, m){
        ll xi, yi, ci;
        cin >> xi >> yi >> ci;
        xi--; yi--;
        ans = min(ans, pa.at(xi) + pb.at(yi) - ci);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4828
import java.io.*;

class Main{
    public static void main(String[] args) throws Exception{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num = 0;

       while(true){

            String num1 = br.readLine();
            String[] num2 = num1.split(" ");
            int H = Integer.parseInt(num2[0]);
            int W = Integer.parseInt(num2[1]);

            if(H == 0 && W == 0){
                break;
            }

            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    if((i+j)%2 == 0){
                        System.out.print("#");
                    }else {
                        System.out.print(".");
                    }
                }
                    System.out.println("");
            }
            System.out.println("");
        }
    }
}

Measured memory_bytes: 31048
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;

    int m=x2-x1;
    int n=y2-y1;

    printf("%d %d %d %d\n",x2-n,y2+m,x1-n,y1+m);
    
}


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

using namespace std;

typedef long long ll;

const int N = 200200;
const int Mod = 2019;

int P10[N];

void add_self(int& x, int y)
{
    if((x += y) >= Mod) x -= Mod;
}

void sub_self(int& x, int y)
{
    if((x -= y) < 0)    x += Mod;
}

int add(int x, int y)
{
    return add_self(x, y), x;
}

int sub(int x, int y)
{
    return sub_self(x, y), x;
}

int mul(int x, int y)
{
    return (ll) x * y % Mod;
}

int fp(int x, ll y)
{
    int Res = 1;
    for(; y > 0; y >>= 1, x = mul(x, x))
        if(y & 1)
            Res = mul(Res, x);
    return Res;
}

void PreCalcMod()
{
    P10[0] = 1;
    for(int i = 1; i < N; i++)  P10[i] = mul(10, P10[i - 1]);
}

int main()
{
    PreCalcMod();

    string s;   cin >> s;

    reverse(s.begin(), s.end());
    for(char& c : s)    c -= '0';

    int n = s.size();

    vector <int> Prefix(n + 1);
    for(int i = 0; i < n; i++)  Prefix[i + 1] = add(mul(s[i], P10[i]), Prefix[i]);

    ll Ans = 0;
    vector <int> Cnt(Mod);

    for(int i = 0; i < n; i++)
    {
        Cnt[Prefix[i]]++;
        Ans += (ll) Cnt[Prefix[i + 1]];
    }

    cout << Ans << endl;
}


Measured memory_bytes: 5168
//ABC072A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main() {
	int x, t;
	cin >> x >> t;
	cout << max(0,x-t) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()	
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000000LL;
typedef pair<int,int> P;
ll dp[110][1010];
map<ll,ll> mp;
ll f[2000010],fi[2000010];
ll mod_pow(ll x,ll n,ll mod){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret=ret*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return ret;
}

void fact(ll n){
	f[0]=1;
	for(ll i=1;i<=n;i++){
		f[i]=f[i-1]*i%MOD;
	}
	fi[n]=mod_pow(f[n],MOD-2,MOD);
	for(ll i=n-1;i>=0;i--){		
		fi[i]=fi[i+1]*(i+1)%MOD;
	}
}

ll nck(ll n,ll k){
	if(n<k)return 0;
	if(k==0){
		return 1;
	}else{
		return f[n]*fi[k]%MOD*fi[n-k]%MOD;
	}
}

ll hck(ll n,ll k){
	if(n==0&&k==0)return 1;
    return f[n+k-1]*fi[k]%MOD*fi[n-1]%MOD;   
}
int main(){
	ll n,m;cin>>n>>m;
	if(m==1){
		cout<<1<<endl;
		return 0;
	}
	vector<ll> v;
	fact(2*n);
	for(ll i=2;i*i<=m;i++){
		if(m%i==0){
			v.push_back(i);
			v.push_back(m/i);
		}
	}
	v.push_back(m);
	sort(all(v));
	v.erase(unique(all(v)),v.end());
	for(int i=0;i<v.size();i++){
		mp[v[i]]=i;
	}
	ll ans=0;
	for(int j=0;j<v.size();j++){
		dp[1][j]=1;
	}
	for(int i=1;i<40;i++){
		for(int j=0;j<v.size();j++){
			for(int k=0;k<v.size();k++){
				if(mp.find(v[j]*v[k])==mp.end())continue;
				dp[i+1][mp[v[j]*v[k]]]+=dp[i][j];
				dp[i+1][mp[v[j]*v[k]]]%=MOD;
			}
		}
	}
	for(int i=1;i<=min(n,40LL);i++){
		ans+=dp[i][mp[m]]*nck(n,(n-i))%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6272
#include <iostream>
#include <string>

using namespace std;

int main() {
  string N;
  cin >> N;

  if(N[0] == N[1] && N[1] == N[2]) cout << "Yes" << endl;
  else if(N[1] == N[2] && N[2] == N[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <functional>

using namespace std;

int d[114514];

int main()
{
	int k;
	cin >> k;
	d[1] = 1;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
	q.push(make_pair(1, 1));
	while (q.top().second) {
		int u = q.top().second;
		q.pop();
		for (int i = 0; i < 2; i++) {
			int v = (i ? u + 1 : u * 10) % k;
			if (d[v] && d[v] <= d[u] + i)
				continue;
			d[v] = d[u] + i;
			q.push(make_pair(d[v], v));
		}
	}
	cout << *d << endl;
	return 0;
}


Measured memory_bytes: 1276
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a[200001],b[200001];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    memcpy(b,a,sizeof(a));
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    	if (b[i]<a[n/2+1])printf("%d\n",a[n/2+1]);
    	else printf("%d\n",a[n/2]);
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long
#define mod 1000000007
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<n;i++)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define ms(v,n) memset((v),n,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define ad(a,b)  (a%mod+b%mod+mod)%mod
#define nl endl
#define inf 1e18
#define cases ll t;cin>>t;while(t--)
#define BLOCK 500
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
 
using namespace std;

const int N=2005;

ll dp[N][N],vis[N][N];
ll n,m;
 ll a[N],b[N];
ll go(ll i,ll j)
{
    if(i>=n||j>=m)
    return 0;

    ll &ans=dp[i][j];

    if(vis[i][j])
    return ans;

    vis[i][j]=1;
    if(a[i]==b[j])
    ans=1+go(i+1,j)+go(i,j+1);

    else
    {
    ans=go(i,j+1)+go(i+1,j);
    if(ans>=mod)
    ans-=mod;
    ans-=go(i+1,j+1);
    if(ans<0)
    ans+=mod;


    }
    

    if(ans>=mod)
    ans-=mod;

    return ans;


    
}

int main()
{
    
    fast

    
    cin>>n>>m;
   
    
    f(i,n)
    cin>>a[i];
    f(i,m)
    cin>>b[i];

    cout<<go(0,0)+1;

    
// f1(i,n+1)
// f1(j,m+1)
// {
    
//     if(a[i-1]==b[j-1])
//     {
//        f1(k,i)
//        f1(l,j)
//        {
//            dp[i][j]+=dp[k][l];
//            if(dp[i][j]>=mod)
//            dp[i][j]-=mod;
//        }
//     }
//     else
//     dp[i][j]=0;
// }


// ll ans=0;
// f1(i,n+1)
// f1(j,m+1)
// {
//     ans+=dp[i][j];
//     if(ans>=mod)
//     ans-=mod;
// }

// cout<<ans;

    
   


    

       
    return 0;
    
}



Measured memory_bytes: 63232
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int n; cin >> n;
    lint a[n]; rep(i, n) cin >> a[i];
    lint asum[n+1];
    asum[0] = 0LL;
    map<lint, lint> mp;
    mp[0]++;
    rep(i, n){
        asum[i+1] = asum[i] + a[i];
        mp[asum[i+1]]++;
    }
    lint ans = 0LL;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        lint k = itr->second;
        ans += k * (k-1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
N, K = map(int, input().split())
S = input()
T = [S[i] for i in range(N)]

if T[K-1] == 'A':
    T[K-1] = 'a'
elif T[K-1] == 'B':
    T[K-1] = 'b'
else:
    T[K-1] = 'c'
U = ''.join(T)
print(U)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cout<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    cout<<n/3<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;
ld dist(pair<ld,ld> &a,pair<ld,ld> &b) {
    return sqrt((a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se));
}
int main() {
    cs
    int n;cin>>n;
    ld ans=0,t=1;
    vector<pair<ld,ld>> v(n);
    for(auto &i:v) cin>>i.fi>>i.se;
    vector<int> vv(n);
    rep(i,n) {vv[i]=i;t*=(i+1);}
    do{
        rep(i,n-1) {
            ans+=dist(v[vv[i]],v[vv[i+1]]);
        }
    }while(next_permutation(vv.begin(),vv.end()));
    cout<<fixed<<setprecision(12)<<ans/t;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MOD = 1e9 + 7;
using ll = long long;
int main(){
    int X;
    ll ans = 0;
    cin >> X;
    for (int i = 1 ; i <= X ; i++){
        ll n = X / i , un = n * i;
        ans += n * (un + i) >> 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
package main

import "fmt"

func max(x ...int) int {
	ans := x[0]
	for _, v := range x[1:] {
		if v > ans {
			ans = v
		}
	}
	return ans
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println(max(a+b, a-b, a*b))
}


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

int main()
{
	long long n;
	cin >> n;

	long long count = 0;
	long long ret = 0;
	long long min = 10000000000;
	for (long long i = 0; i < n; ++i) {
		long long a;
		cin >> a;
		if (a < 0) {
			++count;
			if (-a < min) {
				min = -a;
			}
			ret += -a;
		}
		else {
			if (a < min) {
				min = a;
			}
			ret += a;
		}
	}

	if (count % 2 == 1) {
		ret -= min * 2;
	}

	cout << ret << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, N) for(int i = 0; i < N; ++i)
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    
    int s[m];
    int c[m];
    
    rep(i, m)
    {
        cin >> s[i] >> c[i];
    }
    
    
    rep(i, 1000)
    {
        int digit[3];
        digit[0] = i / 100;
        digit[1] = (i % 100) / 10;
        digit[2] = i % 10;

        if (!((n == 1 && digit[0] == 0 && digit[1] == 0)
              || (n == 2 && digit[0] == 0 && digit[1] != 0)
              || (n == 3 && digit[0] != 0)))
        {
            continue;
        }

        // cout << digit[0] << digit[1] << digit[2] << endl;
        int successCount = 0;
        rep(j, m)
        {
            // check if s[j] is c[j]
            if (s[j] + (3-n) - 1< 0 || s[j] + (3-n) - 1 >= 3)
            {
                continue;
            }

            if (digit[s[j] + (3-n) - 1] == c[j])
            {
                successCount++;
            }
        }
        if (successCount == m)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    long x;
    cin >> x;
    int n = x / 500;
    int m_num = x % 500;
    int m = m_num / 5;
    cout << n * 1000 + m * 5 << endl;
    return 0;
}


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

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

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int max_len = 0;
    char prev_char = '2';
    int left = 0;
    int right = 0;
    int prev_len = 0;
    int limit = K;
    for (int i = 0; i < S.length(); ++i) {
        char cur_char = S[i];
        prev_len++;

        if (prev_char != '0' && cur_char == '0') {
            if (limit == 0) {
                for (int j = left + 1; j <= i; ++j) {
                    if (S[j - 1] == '0' && S[j] == '1') {
                        right = j - 1;
                        break;
                    }
                }
                prev_len -= right - left + 1;
                left = right + 1;
            } else {
                limit--;
            }
        }
        max_len = max(max_len, prev_len);
        prev_char = cur_char;
    }

    cout << max_len << '\n';

    return 0;
}


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

#define mod 1000000007

long long inv[1000010];
long long fac[1000010];
long long invfac[1000010];

void getinv(){
  for (int i = 1; i < 1000010; i++) {
    if (i == 1) inv[i] = 1;
    else {
      inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
      if (inv[i] < 0) inv[i] += mod;
    }
  }
}

void getfac(){
  fac[0] = 1; invfac[0] = 1;
  for (int i = 1; i < 1000010; i++) {
    fac[i] = fac[i-1] * i; fac[i] %= mod;
    invfac[i] = invfac[i-1] * inv[i]; invfac[i] %= mod;
  }
}

long long comb(int n, int r) {
  long long ret = 1;
  ret *= fac[n];
  ret %= mod;
  ret *= invfac[n-r];
  ret %= mod;
  ret *= invfac[r];
  ret %= mod;
  return ret;
}

long long n(int a, int b) {
  return comb(a+b-2, b-1);
}

int main(){
  int h, w; cin >> h >> w;
  int x, y; cin >> x >> y;
  getinv();
  getfac();
  long long all = 0;
  for (int i = y+1; i <= w; i++) {
    long long c = n(h-x, i) * n(x, w-(i-1));
    c %= mod;
    all += c;
    all %= mod;
  }
  cout << all << endl;
  return 0;
}


Measured memory_bytes: 23680
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n");
var str="";
for(var i=0;i<Arr.length;i++){
var arr=Arr[i].split(" ").map(Number);
var h=arr[0];
var w=arr[1];
if(h===0 && w===0)break;
if(i!==0)str+="\n";
var W=Array(w+1).join("#")+"\n";
str+=W;
for(var j=1;j<h-1;j++)str+="#"+Array(w-1).join(".")+"#"+"\n";
str+=W;
}
console.log(str);


Measured memory_bytes: 17076
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long lli;

lli getn(char c){
	if('0' <= c && c <= '9') return c - '0';
	if('A' <= c && c<= 'Z') return c - 'A' + 10;
	if('a' <= c && c<= 'z') return c - 'a' + 10 + 26;
}

lli conv(int b, string &s){
	lli res = 0;
	for(int i=0;i<s.size();i++){
		res *= b;
		res += getn(s[i]);
	}
	return res;
}

int main(){
	int n;
	cin >> n;
	vector<lli> vec;
	lli ans = 0;
	for(int i=0;i<n;i++){
		int b;
		string s;
		cin >> b >> s;
		lli tmp = conv(b, s);
		lli cnt = 0;
		for(int i=0;(1LL<<i)<=tmp;i++){
			if((tmp >> i) & 1){
				cnt++;
			}else{
				ans ^= cnt;
				cnt = 0;
			}
		}
		ans ^= cnt;
	}
	cout << (ans == 0 ? "lose" : "win") << endl;
	return 0;
}

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

int main(){
  int n,d;
  cin >> n >> d;
  vector<vector<int>> dims;
  int tmp;
  for(int i=0; i<n; i++){
    vector<int> vec;
    for(int j=0; j<d; j++){
      cin >> tmp;
      vec.push_back(tmp);
    }
    dims.push_back(vec);
  }
  int ans=0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      tmp = 0;
      for(int k=0; k<d; k++){
        tmp += pow(dims.at(i).at(k)-dims.at(j).at(k),2);
      }
      if(sqrt(tmp)==ceil(sqrt(tmp)))ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();
        if (d <= t * s) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 35684
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, k, c;
string s;
vector<int> a, b;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k >> c;
    cin >> s;
    s = " " + s;
    int last = -1000000000;
    int cnt = 0;
    FOR(i,1,n) {
        if (s[i] == 'o') {
            if (i - last - 1 >= c) {
                a.push_back(i);
                cnt++;
                last = i;
                if (cnt == k) break;
            }
        }
    }
    last = 1000000000;
    cnt = 0;
    FORE(i,n,1)
        if (s[i] == 'o')
            if (last - i - 1 >= c) {
                b.push_back(i);
                cnt++;
                last = i;
                if (cnt == k) break;
            }
    reverse(ALL(b));
    FOR(i,0,SZ(b)-1)
        if (b[i] == a[i]) cout << a[i] << "\n";
    return 0;
}


Measured memory_bytes: 3404
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
 sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
int alice=0;
  int bob=0;
  for(int i=0;i<n;i+=2) alice+=a[i];
  for(int i=1;i<n;i+=2) bob+=a[i];
  cout<<alice-bob<<endl;
  return 0;}

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

int main()
{
	int x, a, b;
	int wa = scanf("%d%d%d", &x, &a, &b);
	if(abs(a - x) < abs(b - x))printf("A");
	else {
		printf("B");
	}
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  
  int count = 0;
  REP(i, N) {
    int d1, d2;
    cin >> d1 >> d2;
	if (d1 == d2)
      count++;
    else
      count = 0;
    
    if (count == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <ctype.h>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007

/* add vars here */

string S;

/* add your algorithm here */

int main() {
  cin >> S;

  if (S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }

  int a;
  int count = 0;

  for (int i = 2; i <= S.size() - 2; ++i) {
    if (S[i] == 'C') {
      count++;
      a = i;
    }
  }

  if (count != 1) {
    cout << "WA" << endl;
    return 0;
  }

  for(int i = 1; i < S.size(); ++i) {
    if (i == a) {
      continue;
    }

    if (S[i] >= 'A' && S[i] <= 'Z') {
      cout << "WA" << endl;
      return 0;
    }
  }

  cout << "AC" << endl;
}


Measured memory_bytes: 256
/**
 *    Author  : Ador
 *    Created : 24.07.2020
**/
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cctype>
typedef long long int ll ;
typedef unsigned long long int ull ;
using namespace std ;
int main(void)
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
        //freopen("input.txt", "r", stdin) ;
        //freopen("output.txt", "w", stdout) ;
    ll n , a , b , i , result = pow(2 , 60) , flag = 0 ; cin >> n ;
    for(i = 2 ; i * i <= n ; ++i)
    {
        if(!(n % i))
        {
            a = i ;
            b = n / i ;
            flag = 1 ;
            result = min(result , ((a - 1) + (b - 1))) ;
        }
    }
    if(flag) cout << result << "\n" ;
    else cout << n - 1 << "\n" ;
    return 0 ;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int a,b; cin>>a>>b;
    string s; cin>>s;
  	
  	for (int i=0;i<a;i++){
    	if(s[i]=='-'){
        	cout<<"No"<<endl;
          	return 0;
        }
    }
  	
  	if(s[a]!='-'){
		cout<<"No"<<endl;
      	return 0;
	}
  
  	for (int i=a+1;i<s.size();i++){
    	if(s[i]=='-'){
        	cout<<"No"<<endl;
          	return 0;
        }
    }
         cout<<"Yes"<<endl;
}

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

int main() {
	int n;
	cin>>n;
	pair<int,pair<int,int>> ar[n];
	
	for(int i=0;i<n;i++)
		cin>>ar[i].second.second>>ar[i].second.first,ar[i].first=ar[i].second.first;
		
	sort(ar,ar+n);
	
	long long int sum=0;
	for(int i=0;i<n;i++){
		sum+=ar[i].second.second;
		if(sum>ar[i].second.first){
			cout<<"No\n";//<<ar[i].second.second<<' '<<ar[i].second.first<<' '<<sum;
			return 0;
		}
		//cout<<ar[i].second.second<<' '<<ar[i].second.first<<' '<<sum<<'\n';
		
	}
	cout<<"Yes\n";
}

Measured memory_bytes: 2688
(defun solve (a-list b-list discount-list &optional (ans 0))
  (setq ans (+ (reduce #'min a-list)
               (reduce #'min b-list)))
  (dotimes (i (length discount-list) ans)
    (let ((cost (- (+ (aref a-list (1- (first  (aref discount-list i))))
                      (aref b-list (1- (second (aref discount-list i)))))
                   (third (aref discount-list i)))))
      (when (< cost ans)
        (setq ans cost)))))

(defun main ()
  (let* ((a (read))
         (b (read))
         (m (read))
         (a-list (make-array a :initial-contents (read-from-string (concatenate 'string "(" (read-line) ")"))))
         (b-list (make-array b :initial-contents (read-from-string (concatenate 'string "(" (read-line) ")"))))
         (discount-list (make-array m)))
    (dotimes (i m)
      (setf (aref discount-list i) (read-from-string (concatenate 'string "(" (read-line) ")"))))
    (princ (solve a-list b-list discount-list))
    (fresh-line)))

(main)


Measured memory_bytes: 80576
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<vector<int> >  vec2int;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int main()
{
  int n, k;cin >> n >> k;
  vecint p(n,0); REP(i,n){cin >> p[i];}
  double ans = 0.0;
  REP(i,k){
    ans += (double)p[i];
  }
  double tmp = ans;
  for(int i = 0; i< n -k; i ++){
    tmp = tmp + (double)(p[i + k] - p[i]);
    if(ans <= tmp){
      ans = tmp;
    }
  }
  cout << setprecision(20) << (ans + (double)k)*0.5 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    int mxi = 0;
    int mni = 0;
    REP(i, n) {
        if (a[mxi] < a[i]) mxi = i;
        if (a[mni] > a[i]) mni = i;
    }

    vector<pii> ans;
    if (abs(a[mxi]) >= abs(a[mni])) {
        REP(i, n) {
            ans.pb({mxi, i});
        }
        REP(i, n - 1) {
            ans.pb({i, i + 1});
        }
    } else {
        REP(i, n) {
            ans.pb({mni, i});
        }
        REPR(i, n - 2) {
            ans.pb({i + 1, i});
        }
    }
    
    cout << SZ(ans) << endl;
    FORE(p, ans) {
        cout << p.first + 1 << " " << p.second + 1 << endl;
        a[p.second] += a[p.first];
    }
    return (0^_^0);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ar array
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)
 
using namespace __gnu_pbds;
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > iil;
typedef pair<ll,int> li;
typedef pair<int,int> ii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;

inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
}
ll pMod(ll x,ll n,ll mod)
{ ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
 
}
 
//think recursively also;

void solve()
{ 
  string s;
  cin>>s;
  int ct=0,mx=0;
  for(int i=0;i<3;i++)
  {
     if(s[i]=='R')
     {
       ct+=1;
     }
     else
     {
      mx=max(mx,ct);
      ct=0;
     }
  }
  mx=max(mx,ct);
  cout<<mx<<endl;
}
int main()
{
  fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  {//cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    ll n,h;cin>>n>>h;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    sort(a.begin(),a.end());
    ll sl=a[n-1];
    sort(b.begin(),b.end());
    auto itr=lower_bound(b.begin(),b.end(),sl);
    ll k=itr-b.begin();
    ll res=0, d=0;
    for(ll i=n-1;i>=k&&d<h;i--){
        d+=b[i];
        res++;
    }
    if(d>=h){
        cout<<res<<endl;
        return 0;
    }
    ll buf=(h-d+sl-1)/sl;
    res+=buf;
    cout<<res<<endl;
}


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

using namespace std;
using ll=long long;
template <class T> using vec=vector<T>;
template <class T> using vvec=vec<vec<T>>;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define en "\n"

using result=pair<bool,int>;
#define value first
#define p second

ll bit=0;

bool equation(const string &s, int p);
result formula(const string &s, int p);
result term(const string &s, int p);

bool equation(const string& s,int p){
    result r1=formula(s,p);
    p=r1.p+1;//skip "="
    result r2=formula(s,p);
    return r1.value==r2.value;
}


result formula(const string &s,int p){
    if(s[p]=='('){
        p++;//skip '('
        result r1=formula(s,p);
        p=r1.p;
        ll op=0;
        if(s[p]=='*'){
            op=0;
            p++;
        }else if(s[p]=='+'){
            op=1;
            p++;
        }else{
            op=2;
            p+=2;
        }
        result r2=formula(s,p);
        p=r2.p+1;//skip ')'
        bool ans=false;
        if(op==0) ans = r1.value and r2.value;
        else if(op==1) ans= r1.value or r2.value;
        else ans = !r1.value or r2.value;

        return {ans,p};
    }else if(s[p]=='-'){
        result r = formula(s,p+1);
        r.value=!r.value;
        return r;
    }else{
        return term(s,p);
    }
}

result term(const string &s, int p){
    //cout<<"t:"<<p<<en;
    if(s[p]=='T') return {true,p+1};
    else if(s[p]=='F') return {false,p+1};
    else{
        int i=s[p]-'a';
        if((bit>>i)&1) return {true,p+1};
        else return {false,p+1};
    }
}


void solve(string s){
    REP(i,1<<11){
        bit=i;
        if(equation(s,0)==false) {
            //cout<<bitset<11>(bit) <<en;
            cout<<"NO"<<en;
            return;
        }
    }
    cout<<"YES"<<en;
}

int main(void){
    string s;
    while(cin>>s){
        if(s=="#") break;
        solve(s);
    }
    return 0;
}


Measured memory_bytes: 3212
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;++i)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
int main() {
	ll N;	cin >> N;
	int T, A;	cin >> T >> A;
	vector<ll> H(N);
	vector<double> C(N);
	double ans = mod;
	int ansNum;
	rep(i, N) {
		cin >> H[i];
		C[i] = T - H[i] * 0.006;
		if (C[i] - A < 0) {
			if (ans >= -(C[i] - A)) {
				ansNum = i + 1;
				ans = -1*(C[i] - A);
			}
		}
		else {
			if (ans >= C[i] - A) {
				ansNum = i + 1;
				ans = C[i] - A;
			}
		}
	}
	
	
	cout << ansNum << endl;
	cin >> N;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    # N = 3
    # A = [3, 2, 1]
    count = 0
    for i in range(1, N):
        diff = A[i - 1] - A[i]
        if diff > 0:
            count += abs(diff)
            A[i] += abs(diff)
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 94412
s = input()

if int(s[:2]) >= 1 and int(s[:2]) <= 12 and int(s[2:]) >= 1 and int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif int(s[:2]) >= 1 and int(s[:2]) <= 12:
    print('MMYY')
elif int(s[2:]) >= 1 and int(s[2:]) <= 12:
    print('YYMM')
else:
    print('NA')

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

sum = 0

if k-a >= 0:
    sum += a
    k = k-a
else:
    sum += k
    print(sum)
    exit(0)

if k-b >= 0:
    k = k-b
else:
    print(sum)
    exit(0)


if k-c >= 0:
    sum -= c
else:
    sum -= k
    print(sum)
    exit(0)

print(sum)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll t = c - a - b;
    if (t > 0 && 4 * a * b < t * t) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
using namespace std;

ll n,d;
int main() {
    //freopen("input.txt", "r", stdin) ;
    //freopen("output.txt", "w", stdout) ;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    cin>>n>>d;
    int ans=0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        if(sqrt((x*x)+(y*y))<=d) ans++;
    }
    cout<<ans;
    return 0;
}




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

#define  __  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  int  long long
#define  endl  '\n'
const double pi = acos(-1);
const int mod = 1e9 + 7;
//______________________



int32_t main()
{ 
  __
 
  
  
  int n,k;
  string s,ans;

  cin>>s;

  int ab=(s[0]-'0')*10 + (s[1]-'0');
  int cd = (s[2]-'0')*10 + (s[3]-'0');

  if((ab==0 and cd>12) or (cd==0 and ab>12) or (ab==0 and cd==0) or(ab>12 and cd>12))
   ans="NA";
  else if(ab>0 and ab<13 and cd>0 and cd<13)
    ans="AMBIGUOUS";
  else if((cd<13 and cd>0))
    ans="YYMM";
  else if(ab<13 and ab>0)
    ans="MMYY";
  

  cout<<ans;

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll a, b, k;
	cin >> a >> b >> k;
	if (a < k) {
		k -= a;
		a = 0;
	}
	else {
		a -= k;
		k = 0;
	}
	if (b < k) {
		b = 0;
	}
	else {
		b -= k;
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


int main()
{
    int N, Q;
    string s;
    cin >> N >> Q >> s;
    vector<char> t(Q);
    vector<char> d(Q);
    REP(i, Q) cin >> t[i] >> d[i];

    int L = -1, R = N;
    IREP(i, Q)
    {
        if (d[i] == 'L')
        {
            if (L + 1 < N and s[L + 1] == t[i]) L++;
            if (R < N and s[R] == t[i]) R++;
        }
        else
        {
            if (L >= 0 and s[L] == t[i]) L--;
            if (R > 0 and s[R - 1] == t[i]) R--;
        }
        if (L + 1 >= R) break;
    }
    cout << max(R - L - 1, 0) << endl;
}


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

long long n,k,a[2010],b[2010][2],ans;

int main(){
    cin>>n>>k;
    for(long long i=0;i<n;i++)cin>>a[i];
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            if(a[j]<a[i]){
                if(j<i)b[i][0]++;
                else if(j>i) b[i][1]++;
            }
        }
    }
    for(long long i=0;i<n;i++){
        ans+=k*(k-1)/2%1000000007*(b[i][0]+b[i][1])+k*b[i][1]%1000000007;
        ans%=1000000007;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    println!("{}",(a-1)*(b-1))
}

Measured memory_bytes: 4352
S = input().split(" ") #標準入力

H = int(S[0]) #モンスターのHP
A = int(S[1]) #サーバルの攻撃力

atCount = 0 #攻撃回数

while H > 0:
  H = H - A
  atCount = atCount + 1

print(atCount)



Measured memory_bytes: 2940
#include <iostream>

#include <iomanip>
using namespace std;
double ans;
int main()
{
    int r;
    cin >> r;
    
    double PI = 3.141592653589793238462643383279502884;
    
    ans = 2 * PI * r;
    cout << setprecision(20) << ans << "\n";
    
    return 0;
}


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

city = []
PY = []
for i in range(M):
    ll = [i] + list(map(int, input().split(" ")))
    # print(ll)
    PY.append(ll)

PY = sorted(PY, key=lambda x: x[2])
# print(PY)

ken = [1]*N
answer = []
for i in range(M):
    ue6 = "{0:06d}".format(PY[i][1])
    sita6 = "{0:06d}".format(ken[PY[i][1]-1])
    ken[PY[i][1]-1] += 1
    answer.append([PY[i][0], ue6+sita6])

answer = sorted(answer, key=lambda x: x[0])
for i in range(M):
    print(answer[i][1])

Measured memory_bytes: 43380