akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,k,i,j,l;
	cin>>n>>k;

	l=n/2;
	if(l%2==1) l++;

	if(l>=k||k==1) cout<<"YES";
	else cout<<"NO";
	
	return 0;
}
//ctrl H replace

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    int k,s;
    cin>>k>>s;
    int ans=0;

   for(int i=0;i<=k;i++){

       for(int j=0;j<=k;j++) {

           if ((s -i-j)<=k&&(s-i-j)>=0) {
               //cout<<i<<" "<<j<<" "<<s-i-j<<endl;
               ans++;
           }
       }
   }


    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#define mop 1000000007
using namespace std;

int f[101][11];
long long p[101][11];
int main() {
    
    int n;
    cin >> n;

    for (int i=0;i<n;i++){
        for (int j=0;j<10;j++){
            cin >> f[i][j];
        }
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<11;j++){
            cin >> p[i][j];
        }
    }
    long long ans = -1 * mop;
    for (int b=1;b<1024;b++){
        long long par = 0;
        for (int i=0;i<n;i++) {
            int op = 0;
            for (int j = 0; j < 10; j++) {
                if ((b >> j & 1) == 1) {
                    if (f[i][j] == 1) {
                        op += 1;
                    }
                }
            }
            par += p[i][op];
        }

        if(ans < par){
            ans = par;
        }
    }
    cout << ans << endl;



}

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

using namespace std;

int main(void) {
  int n, d, x;
  cin >> n >> d >> x;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int ch = 0;
  for(int i = 0; i < n; i++) {
    ch += (d - 1) / a[i] + 1;
  }
  ch += x;
  cout << ch << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 a;
    string s;
    cin>>a>>s;
    if(a>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

int n,k,a,b;
vector<int> jb[10];
int dp[2001];

int main(){

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

  for(int i=0;i<n;i++){
    scanf("%d%d",&a,&b);

    jb[b-1].push_back(-a);
  }

  for(int i=0;i<10;i++){
    sort(jb[i].begin(),jb[i].end());

    for(int j=1;j<jb[i].size();j++){
      jb[i][j]+=jb[i][j-1]-j*2;
    }
  }
  
  for(int i=0;i<10;i++)
    for(int j=n-(int)jb[i].size();j>=0;j--)
      for(int l=0;l<jb[i].size();l++){
	dp[j+l+1]=min(dp[j+l+1],dp[j]+jb[i][l]);
      }
  
  printf("%d\n",-dp[k]);
  
  return 0;
}

Measured memory_bytes: 1072
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  vector<ll> S(N+1,0),p(N+1,0);
  for(int i=0; i<N; i++){
    S[i+1] = S[i] + A[i];
    p[i+1] = p[i];
    if(A[i] > 0){
      p[i+1] += A[i];
    }
  }
  ll ans = -INF;
  for(int i=0; i+K<=N; i++){
    ll ret = 0;
    ret += p[i];
    ret += p[N] - p[i+K];
    ret += max(0LL,S[i+K] - S[i]);
    chmax(ans,ret);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2176
object Main extends App {

  import scala.io.StdIn._

  val n = readLine.trim.toInt
  val h = readLine.trim.split(' ').map(_.toInt)
  val memo = Array.tabulate(n){_ ⇒ None: Option[Int]}.also{arr ⇒ arr(n - 1) = Some(0)}
  for (i ← (0 until n by 100).reverse){
    minCost(h, memo, i)
  }
  println(minCost(h, memo, 0))
  def minCost(heights: Array[Int], memo: Array[Option[Int]], current: Int = 0): Int = {
    if (current == heights.length) 0
    else {
      memo(current) match {
        case Some(r) ⇒ r
        case None ⇒
          (current + 1 to current + 2).filter(p ⇒ heights.indices.contains(p)).map(p ⇒ minCost(heights, memo, p) + math.abs(heights(p) - heights(current))).min.also{min ⇒ memo(current) = Some(min)}
      }
    }
  }
  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
}

Measured memory_bytes: 82608
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> H;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
    H = fetch_vec<int>(N);
}

int solve(){ 
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        while(H[i]) {
            ans++;
            H[i]--;
            int j=i+1;
            while(H[j] && j<N){H[j]--;j++;}
            }
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,n,dem=0;
  cin>>n;
  int a[n],b[n];
  for(i=0;i<n;i++) {cin>>a[i];b[i]=a[i];}
  sort(b,b+n);
  for(i=0;i<n;i++) if(a[i]!=b[i]) dem++;
  if(dem<=2) cout<<"YES";
   else cout<<"NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int N;
  scanf("%d", &N);
  ll a[N],b[N];
  pair<ll,pair<ll,ll>> p[N];
  for (int i = 0; i < N; ++i) {
    scanf("%lld%lld", &a[i],&b[i]);
    p[i] = MP(a[i]+b[i],MP(a[i],b[i]));
  }

  sort(p,p+N,greater<pair<ll,pair<ll,ll>>>());

  ll sum = 0;

  FOR(i,0,N-1){
    if(i%2==0) sum += p[i].second.first;
    else sum -= p[i].second.second;
  }

  cout << sum << endl;



}



Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main() {
  int A[100][100];
  int b[100];
  int c[100] = {};
  int i, j, n, m;
  cin >> n >> m;
  for(i = 0; i < n; i++) {
	for(j = 0; j < m; j++) {
	  cin >> A[i][j];
	}
  }
  for(j = 0; j < m; j++) {
	cin >> b[j];
  }

  for(i = 0; i < n; i++) {
	for(j = 0; j < m; j++) {
	  c[i] += A[i][j] * b[j];
	}
	cout << c[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
a = str(input()).split()
n = int(a[0])
y = int(a[1])
c = 0
for i in range(0,n+1):
    for j in range(0,n-i+1):
        k = n-i-j
        if y == 10000*i + 5000*j + 1000*k:
            c = 1
            s = i
            t = j
            r = k
if c == 1:
    print(s,t,r)
else:
    print(-1,-1,-1)
  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=2019;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
ll take_p5(ll n){
	return (n*n*n*n*n);
}
int main() 
{
	int n , m,x;
	cin>>n>>m>>x;
	int mat[n+1][m+1];
	int c[n+1];
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++)
			cin>>mat[i][j];
	}
	int ans=INT_MAX;
	for(int i=0;i<(1<<n);i++){
		int tot=0;
		int al[m+1];
		memset(al ,0 , sizeof(al));
		for(int j=0;j<n;j++){
			if(i&(1<<j))
			{
				tot=tot+c[j];
				for(int k=0;k<m;k++)
					al[k]=al[k]+mat[j][k];
			}
			bool flag=true;
			for(int j=0;j<m;j++){
				if(al[j]<x)
					flag=false;
			}
			if(flag)
				ans=min(ans, tot);
		}
	}
	if(ans==INT_MAX)
		cout<<-1;
	else
		cout<<ans;



}

Measured memory_bytes: 27068
n = int(input())
order_list = list(map(int, input().split()))
dict = {}
for i, order in enumerate(order_list):
  dict[order] = i + 1
ans_list = []
for i in range(n):
  ans_list.append(str(dict[i+1]))
ans = ' '.join(ans_list)
print(ans)

Measured memory_bytes: 24924
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        for(;;){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if((h==0) && (w==0)) break;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if((i==0) || (i==h-1)){
                        System.out.print("#");
                    }else if((j==0) || (j==w-1)){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
        sc.close();
    }
}


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


int main(){
	
		long long int a,b,x;
		
		scanf("%lli %lli",&a,&b) ;
		
		if((a+b)%2==0) {
			
			x= (a+b)/2;
			
			printf("%lli\n",x);
			
			
		}
		
		else {
			
			printf("IMPOSSIBLE\n") ;
		}
        
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> g(100005);
constexpr ll MOD = 1000000007;

int n, k;
ll ans = 1;

vector<bool> visited(100005);

void bfs() {
	queue<P> Q;
	Q.emplace(0, k);
	while (!Q.empty()) {
		auto v = Q.front(); Q.pop();
		ans *= v.se;
		ans %= MOD;

		visited[v.fi] = true;

		int cnt = 1;
		for (int to: g[v.fi]) {
			if (visited[to]) continue;
			if (v.fi == 0) Q.emplace(to, k - cnt);
			else Q.emplace(to, k - (1 + cnt));
			cnt++;
		}
	}
}

int main() {
	
	cin >> n >> k;
	rep (i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].pb(b);
		g[b].pb(a);
	}

	bfs();

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6904
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
const int maxn=205;
int a[maxn][maxn];
vector<int>b[maxn];
int n,m;
int c[maxn];
bool check(int p)
{
	for(int i=0;i<b[p].size();i++)
	{
		int j=b[p][i];
		if(a[p][j]&&!c[j])
		{
			c[j]=1;
			check(j);
		}
	}
}
int main()
{
	//freopen("1.txt","r",stdin);
	scanf("%d%d",&n,&m);
	int s,t;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&s,&t);
		a[s][t]=a[t][s]=1;
		b[s].push_back(t);
		b[t].push_back(s);
	}
	int tot=0;
	for(int i=1;i<=n;i++)
	for(int j=0;j<b[i].size();j++)
	{
		int k=b[i][j];
		a[i][k]=a[k][i]=0;
		memset(c,0,sizeof(c));
		check(i);
		for(int ii=1;ii<=n;ii++)
		if(!c[ii])
		{
			tot++;
			break;
		}
		a[i][k]=a[k][i]=1;
	}
	printf("%d",tot/2);
	return 0;
} 

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    s = input()
    parity_sn = 0
    if "S" in s:
        parity_sn += 1
    if "N" in s:
        parity_sn += 1
    parity_ew = 0
    if "E" in s:
        parity_ew += 1
    if "W" in s:
        parity_ew += 1
    if parity_sn % 2 == parity_ew % 2 == 0:
        print("Yes")
    else:
        print("No")

main()



Measured memory_bytes: 3444
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    let sum = 0
    for(let i = 1; i<= N; i++){
        if(i % 3 !== 0 && i % 5 !== 0){
            sum += i
        }
    }
    console.log(sum)

}
Main()


Measured memory_bytes: 34996
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int s=stoi(a+b);
    for(int i=1; i<=1000; i++)
    {
        if(i*i==s)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;

}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t;
    t = 1;
    for(int i=0;i<t;i++)
    {
        int n;
        cin>>n;
        int arr[n];
        int ans = 0;
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
            ans ^= arr[i];
        }
        for(int i=0;i<n;i++)
        {
            int l = ans^arr[i] ;
            cout<<l<<" ";
        }
    }
    return 0;
}

Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5+5;

vector<pair <int, int> >v;

int32_t main()
{
    int n, m;
    cin >> n >> m;
    int x, y;
    for(int i = 1; i <= m; i++)
    {
        cin >> x  >> y;
        v.push_back(make_pair(x, y));
    }
    sort(v.begin(), v.end());

    int ans = 0, a =  0, b = 0;

    for(int i = 0; i < v.size(); i++)
    {
         if(a<=v[i].first){
            ++ans;
            a = v[i].second;
         }
         a = min(a, v[i].second);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, sum = 0, cur = 1;
    cin >> n;
    rep(i, n){
        int in;
        cin >> in;
        if(in == cur) cur++;
        else sum++;
    }
    if(cur == 1) cout << "-1" << endl;
    else cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;

namespace std{
  bool operator < (const P &a,const P &b){
    return (a.imag()==b.imag()?
            a.real()<b.real():
            a.imag()<b.imag());
  }
};

double eps=1e-8;
double PI=acos(-1);

bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}

//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}

bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}

//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}

double calcArea(vec &t){
  double res=0;
  int n=t.size();
  for(int i=0;i<n;i++)res+=cross(t[i],t[(i+1==n?0:i+1)]);
  return abs(res/2.0);
}

double Arg(P a,P b,P c){
  b-=a,c-=a;
  return arg(c*conj(b));
}

int inPolygon(vec &t,P p){
  int n=t.size();
  double sum=0;  
  for(int i=0;i<n;i++){
    P a=t[i],b=t[(i+1==n?0:i+1)];
    if( ccw(a,b,p) == 0 )return 1;// on
    sum+= Arg(p,a,b);
  }
  if( abs(sum) < eps )return 0;//out
  else  return 2;//in
}

typedef pair<double,P> Pair;

vec andrewScan(vec &t){
  int N=t.size(),C=0;
  vec R(N);
  for(int i=0;i<N;i++){
    while(2<=C&&ccw(R[C-2],R[C-1],t[i])==-1)C--;
    R[C++]=t[i];
  }
  vec res(C);
  for(int i=0;i<C;i++)res[i]=R[i];
  return res;
}

vec ConvexHull2(vec t){
  sort(t.begin(),t.end());
  vec u=andrewScan(t);
  reverse(t.begin(),t.end());
  vec l=andrewScan(t);
  for(int i=1;i+1<(int)l.size();i++)u.push_back(l[i]);
  return u;
}

vec ConvexHull(vec t){
  vector<Pair> u;
  vec R;
  int N=t.size(),K=0,C=0;
  for(int i=1;i<N;i++)if(t[i]<t[K])K=i;
  for(int i=0;i<N;i++)u.push_back(Pair(arg(t[i]-t[K]),t[i]));
  R.push_back(t[K]),C++;
  sort(u.begin(),u.end());
  for(int i=0;i<N;i++){
    P p=u[i].second;
    if(2<=C&&ccw(R[C-2],R[C-1],p)==0)continue;
    if(2<=C&&ccw(R[C-2],R[C-1],p)==2)continue;
    while(2<=C&&ccw(R[C-2],R[C-1],p)!=1)R.pop_back(),C--;
    R.push_back(p),C++;    
  }
  return R;
}

int main(){
  int n;
  cin>>n;
  vec t;
  double x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  vec ans=ConvexHull2(t);
  vec ans2=ConvexHull(t);
  assert( eq(calcArea(ans),calcArea(ans2) ) );
  cout<<ans.size()<<endl;
  for(int i=0;i<(int)ans.size();i++){
    cout<<(int)ans[i].real()<<' '<<(int)ans[i].imag()<<endl;
  }
  return 0;
}

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

using namespace std;

#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define MAJ(x) (((x)+1)/2)

int main() {
	int n; cin >> n;
	rep(i, n) {
	    string s; cin >> s;
	    vector<int> v, w;
	    string buf;
	    for(char c: s) {
	        if(c == '[') {
	            w.push_back(v.size());
	        } else if(c == ']') {
	            if(!buf.empty()) {
	                v.push_back(MAJ(atoi(buf.c_str())));
	                buf.clear();
	            }
                int a = w.back(); 
                w.pop_back();
	            sort(v.begin()+a, v.end());
	            int tmp = accumulate(v.begin()+a, v.begin()+a+MAJ(v.size()-a), 0);
	            v.resize(a);
	            v.push_back(tmp);
	        } else {
	            buf.push_back(c);
	        }
	    }
	    cout << v.back() << endl;
	}
}



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

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

	bool can = false;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == N) {
				can = true;
				cout << "Yes" << endl;
				break;
			}
		}
		if (can) {
			break;
		}
	}
	if (!can) {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <bitset>
#include <limits.h>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
int n;
LL ans = 0;
map<char, LL> mp;
/**********************************************/

signed main(){
    cin >> n;
    mp['M'] = 0;
    mp['A'] = 0;
    mp['R'] = 0;
    mp['C'] = 0;
    mp['H'] = 0;
    REP(i, n){
        string s;
        cin >> s;
        mp[s[0]]++;
    }
    
    ans += mp['M'] * mp['A'] * mp['R'];
    ans += mp['M'] * mp['A'] * mp['C'];
    ans += mp['M'] * mp['A'] * mp['H'];
    ans += mp['M'] * mp['R'] * mp['C'];
    ans += mp['M'] * mp['R'] * mp['H'];
    ans += mp['M'] * mp['C'] * mp['H'];
    ans += mp['A'] * mp['R'] * mp['C'];
    ans += mp['A'] * mp['R'] * mp['H'];
    ans += mp['A'] * mp['C'] * mp['H'];
    ans += mp['R'] * mp['C'] * mp['H'];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "stdio.h"

int main()
{
    int a[100001],i,z=0,n,m;
    long long x=0;
    scanf("%d %d",&n,&m);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    for(i=0; i<n-1; i++)
    {
        if(a[i]+a[i+1]>m)
        {
            if(a[i]>m)
            {
                x+=a[i]-m+a[i+1];
                a[i+1]=0;
            }
            else
            {
                x+=a[i]+a[i+1]-m;
                a[i+1]=m-a[i];
            }
        }
    }
    printf("%lld\n",x);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 100005;
int arr[MAXN], n;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", arr + i);
	sort(arr + 1, arr + 1 + n);
	reverse(arr + 1, arr + 1 + n);
	int p = 0;
	for (int i = 1; i <= n; i++)
		if (arr[i] >= i) p = i;
		else break;
	if ((arr[p] - p) & 1) return puts("First") * 0;
	int q = 0;
	for (int i = p + 1; i <= n; i++)
		if (arr[i] >= p) ++q;
		else break;
	if (q & 1) return puts("First") * 0;
	puts("Second");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    
    string ans="second";
    rep(i,0,n){
        int a;
        cin>>a;
        if(a%2==1) ans="first";
    }
    
    cout<<ans<<endl;
}



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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  string t;
  cin>>t;
  int N = int(t.size());
  for(int i(0);i<N;i++){
    if(t[i] == '?'){
      t[i] = 'D';
    }
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 3756
n = str(input())
ans = 0
if int(n) < 10:
  print(int(n))
  exit()
for i in range(2 ** (len(n) -1)):
  num = format(i,"b").zfill(len(n)-1)
  lis = ""
  for j in range(len(str(num))):
    if str(num[j]) == "1":
      lis += (str(n[j])+"+")
    else:
      lis += str(n[j])
  lis += n[-1]
  li = lis.split("+")
  for h in range(len(li)):
    li[h] = int(li[h])
  ans += sum(li)
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

class Data:
    def __init__(self, a, b, c, d):
        self.A = a
        self.B = b
        self.C = c
        self.D = d

def solve(N, d, cache):
    if N in cache:
        return cache[N]

    if N == 0:
        return 0
    if N == 1:
        return d.D

    ans = d.D * N

    for (n, coeff) in ((2, d.A), (3, d.B), (5, d.C)):
        if N % n == 0:
            ans1 = coeff + solve(N // n, d, cache)
            ans = min(ans, ans1)
        else:
            left = N % n
            ans2 = d.D * left + coeff + solve((N - left) // n, d, cache)

            right = n - left
            ans3 = d.D * right + coeff + solve((N + right) // n, d, cache)

            ans = min(ans, ans2, ans3)

    cache[N] = ans
    return ans
    

def main():
    T = int(input())
    for t in range(T):
        N, A, B, C, D = map(int, input().split())
        d = Data(A, B, C, D)
        cache = {}
        print(solve(N, d, cache))


main()


Measured memory_bytes: 12676
def bubble_sort(A):
    cnt = 0
    for i in range(0, len(A) - 1):
        for j in range(len(A) - 1, i, -1):
            if A[j] < A[j - 1]:
                A[j - 1], A[j] = A[j], A[j - 1]
                cnt += 1
    print(' '.join(map(str,A)))
    print(cnt)


if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))
    bubble_sort(l)



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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    ll ret = 0;
    for(i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)ret+=i;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char s[100004];
int main() {
	scanf("%s",s+1);
	int l=1,r=strlen(s+1),ans=0;
	while (l<=r) {
		if (l==r) break;
		if (s[l]==s[r]) {++l,--r;continue;}
		if (s[l]=='x') {++l,++ans;continue;}
		if (s[r]=='x') {--r,++ans;continue;}
		puts("-1");
		return 0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#include <bitset>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=0;i<=n;++i)
#define INF 10000000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
int f[100];
ll int num[100][11];
int tmp;

int main(){
    scanf("%d", &N);

    REP(i, N){
        f[i] = 0;
        REP(j, 10){
            scanf("%d", &tmp);
            if(tmp) f[i] += pow(2, j);
        }
    }
    
    REP(i, N) REP(j, 11) scanf("%lld", &num[i][j]);

    ll int ans = -INF;

    for(int bit=1;bit<(1<<10);++bit){
        ll int res=0;
        REP(i, N){
            int tmp=0;
            REP(j, 10){
                if((bit & f[i]) & (1<<j)){
                    ++tmp;
                }
            }
            res += num[i][tmp];
        }

        ans = max(ans, res);
    }

    printf("%lld\n", ans);

	return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n;
	cin >> n;
	long long ans = 0ll;
	vector<int> cnt(n + 1, 0), a(n);
	for (int i = 0; i < n; ++i){
		cin >> a[i];
		cnt[a[i]]++;
	}
	for (int i = 1; i <= n; ++i){
		ans += (1ll * cnt[i] * (cnt[i] - 1)) / 2;
	}
	for (int i = 0; i < n; ++i){
		cout << ans - 1ll * (cnt[a[i]] - 1) * cnt[a[i]] / 2 + 1ll * (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2 << "\n";
	}
	return 0;
}



Measured memory_bytes: 4224
// E - Colorful Blocks
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int N,M,K;

#define MOD 998244353
#define MAX 200100 // [n+1] 1_origin
ll fac[MAX]; // 階乗 n!
ll inv[MAX]; // 逆元 1/n
ll finv[MAX]; // 逆元の階乗 (n^-1)! = (1/n)!

// n 個の配列に、mod p で前処理する
void init(int n){
	int p = MOD;
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rp(i,2,n+1){
		fac[i] = fac[i-1] * i % p;
		inv[i] = p - inv[p%i] * (p/i) % p;
		finv[i] = finv[i-1] * inv[i] % p;
	}
}

// 組み合わせ nCr(mod m)
ll nCr(int n, int r){
	int m = MOD;
	if(n<r || n<0 || r<0) return 0;
	return fac[n] * (finv[n-r] * finv[r] % m) % m;
}

int main(){
	cin>>N>>M>>K;
	init(N); // combination init
	int div_point = min(N-1, K); // division point
	ll colors = M; // color allocation
	for(int p=N-1; p>div_point; --p) colors = colors * (M-1) % MOD;
	ll ans = 0;
	for(int p=div_point; p>=0; --p){ // p:[N-1,0] number of pairs
		ll groups = nCr(N-1, p); // number divided into groups
		ans = (ans + groups * colors % MOD) % MOD;
		colors = colors * (M-1) % MOD;
	}
	cout<< (ans + MOD) % MOD <<endl; // if negative
}


Measured memory_bytes: 8268
import java.util.Scanner;


/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = 0, res = 0;
        int n = in.nextInt();
        char[] string = in.next().toCharArray();
        for (int i = 0; i < n; i++) {
            if (string[i] == 'I'){
                x++;
            }else {
                x--;
            }
            res = Math.max(res, x);
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";

int main()
{

   Ezio
   ll t,m,n,x,a,b;
   string s;

   cin>>a>>b;
   cout<<((a>9  or b>9)? -1 : a*b)<<endl;
   return 0;
}


Measured memory_bytes: 3660
n, m = map(int, input().split())
K = [0]*m
S = [[] for _ in range(m)]
for i in range(m):
    K[i], *S[i] = map(lambda x:int(x)-1, input().split())
    K[i] += 1
P = list(map(int, input().split()))

ans = 0
for i in range(pow(2,n)):
    B = bin(i)[2:].zfill(n)
    D = {j:True if b=='1' else False for j,b in enumerate(B)}
    _P = []
    for j,s in enumerate(S):
        _P.append(sum(D[_s] for _s in s)%2 == P[j])
    if all(_P):
        ans += 1
print(ans)

Measured memory_bytes: 9164
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include <math.h> 
using namespace std;

int main()
{
	int a,b,c,ans;
	vector<int>::iterator it;
	cin>>a>>b>>c;
	ans = floor(b/a);
	if (ans > c)
	{
		ans = c;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  char s[100000];
  int i, c = 1, j;

  scanf("%d",&n);
  scanf("%c",&s[0]);
  for(i = 1;c <= n &&(scanf("%c", &s[i])) == 1; i++,c++){
    
    if(s[i - 1] == s[i]){
      i--;
    }
  }
  i--;
  printf("%d",i);
  return 0;
}


Measured memory_bytes: 256
from math import floor
def Main(A, B):
    for i in range(1, 1001):
        if floor(i*0.08) == A and floor(i*0.1) == B:
            return i
    return -1
    
def main():
    A, B = map(int, input().split())
    print(Main(A, B))

if __name__ == '__main__':
    main()

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

int main(){
  int n;
  string ans = "hon";
  cin >> n;
  if(n%10 == 3){
    ans = "bon";
  }
  else if (n%10 == 0 || n%10 == 1 || n%10== 6 || n%10==8){
    ans = "pon";
  }
  cout << ans << endl;
}

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

ll mod = 998244353;
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    ll ans = 0;

    for(int i=0;i<n;i++){
        ll ret = modpow(2,n-i-1);
        ret *= (a[i] * modpow(a[i]+1,i))%mod;
        //cerr << ret << endl;
        ans += ret; 
        ans %= mod;
    }
    cout << ans << endl;
}


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

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

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

    int max = 0;
    int scnd = 0;
    for (int i = 0; i < n; i++){
        if(a[i] > max) max = a[i];
    }

    for (int i = 0; i < n; i++){
        if (a[i] != max && a[i] > scnd) scnd = a[i];
    }

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


    if(cnt != 1)  for(int i = 0; i < n; i++)  cout << max << "\n";
    else {
        for (int i = 0; i < n; i++){
            if(a[i] != max) cout << max << "\n";
            else cout << scnd << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 2432
import math


def main():
    N = int(input())
    cnt = [[0] * 10 for _ in range(10)]
    for i in range(1, N+1):
        d = int(math.log(i, 10))
        cnt[i//(10**d)][i % 10] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += cnt[i][j] * cnt[j][i]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40428
A,B,K = map(int,input().split())
k = []
for i in range(A,A+K):
    if A<=i<=B:
        k.append(i)
for i in range(B-K+1,B+1):
    if A<=i<=B:
        k.append(i)
p = set(k)
q = list(p)
q.sort()
for i in range(len(q)):
    print(q[i])

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdbool.h>

#define N_MAX 50
#define INF 1145141919
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

int i, j;

int n, m;
int k;

bool max[N_MAX * N_MAX];
bool d[N_MAX][N_MAX];

void solve(){
	return;
}

int main (void) {
	int fuc, ker;
	scanf("%d%d", &n, &k);
	n--;
	k--;
	fuc = 1;
	ker = k;
	for (i = 0; i < n; i++) {
		fuc *= k;
		ker *= k;
	}
	printf("%d\n", fuc+ker);
	return 0;
}




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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> ans;
  if (n%2) {
    for (int l = 1, r = n-1; l < r; l++, r--) {
      ans.emplace_back(l,r);
    }
  } else {
    bool flag = false;
    for (int l = 1, r = n-1; l < r; l++, r--) {
      if (!flag && r-l <= n/2) {
        --r;
        flag = true;
      }
      ans.emplace_back(l,r);
    }
  }
  rep(i,m) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}

Measured memory_bytes: 4252
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	x, a, b := nextInt(), nextInt(), nextInt()
	if abs(a-x) < abs(b-x) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;


int main(void){
	int h,w,k;
	cin>>h>>w>>k;
	ll dp[h+5][w+5];

	rep(i,h+5){
		rep(j,w+5){
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(int i=1;i<=h;i++){
			for(int k=0;k<(1<<(w-1));k++){
				int tmp=k;
				int line[w-1];
				line[0]=tmp%2;
				bool flag=false;
				for(int l=1;l<w-1;l++){
					tmp/=2;
					line[l]=tmp%2;
					if(line[l]==1 && line[l-1]==1)flag=true;
				}
				if(flag)continue;
				rep(l,w){
					if(l-1 >= 0 && line[l-1]==1)dp[i][l-1]+=dp[i-1][l];
					else if(l < w-1 && line[l]==1)dp[i][l+1]+=dp[i-1][l];
					else dp[i][l]+=dp[i-1][l];
					dp[i][l-1]%=MAX;
					dp[i][l]%=MAX;
					dp[i][l+1]%=MAX;
				}
			}
	}

	/*rep(i,h+1){
		rep(j,w){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<dp[h][k-1]<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace whatever{
	int readu(){
		char ch=getchar();
		while(!isdigit(ch))
			ch=getchar();
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value;
	}
	void writeull(long long n){
		if(n<10)
			putchar(n+'0');
		else{
			writeull(n/10);
			putchar(n%10+'0');
		}
	}
	void run(){
		cerr<<"time(0): "<<time(0)<<endl;
		int h=readu();
		int w=readu();
		static char s[300][301];
		for(int i=0; i<h; ++i){
			gets(s[i]);
			assert(int(strlen(s[i]))==w);
		}
		static int cnt[300][300];
		long long result=0;
		int first_a;
		int last_a;
		memset(cnt, 0, sizeof(cnt));
		for(int i=0; i<h; ++i)
			for(int j=0; j<w; ++j){
				cnt[i][j]=int(s[i][j]=='#');
				if(i!=0&&j!=0)
					cnt[i][j]+=cnt[i-1][j-1];
			}
		for(int i=0; i<h; ++i)
			for(int j=0; j<w; ++j)
				if(s[i][j]=='#')
					for(int k=1; k<min(h-i, w-j); ++k)
						if(s[i+k][j+k]=='#'){
							first_a=max(0, k-i);
							last_a=min(k, w-(j+k)-1);
							if(first_a<=last_a){
								result+=cnt[i-k+last_a][j+k+last_a];
								if(i-k+first_a-1>=0&&j+k+first_a-1>=0)
									result-=cnt[i-k+first_a-1][j+k+first_a-1];
							}
							first_a=max(0, k-j);
							last_a=min(k, h-(i+k)-1);
							if(first_a<=last_a){
								result+=cnt[i+k+last_a][j-k+last_a];
								if(i+k+first_a-1>=0&&j-k+first_a-1>=0)
									result-=cnt[i+k+first_a-1][j-k+first_a-1];
							}
						}
		cerr<<"result: "<<result<<endl;
		for(int i=0; i<h; ++i)
			reverse(s[i], s[i]+w);
		memset(cnt, 0, sizeof(cnt));
		for(int i=0; i<h; ++i)
			for(int j=0; j<w; ++j){
				cnt[i][j]=int(s[i][j]=='#');
				if(i!=0&&j!=0)
					cnt[i][j]+=cnt[i-1][j-1];
			}
		for(int i=0; i<h; ++i)
			for(int j=0; j<w; ++j)
				if(s[i][j]=='#')
					for(int k=2; k<min(h-i, w-j); ++k)
						if(s[i+k][j+k]=='#'){
							first_a=max(1, k-i);
							last_a=min(k-1, w-(j+k)-1);
							if(first_a<=last_a){
								result+=cnt[i-k+last_a][j+k+last_a];
								if(i-k+first_a-1>=0&&j+k+first_a-1>=0)
									result-=cnt[i-k+first_a-1][j+k+first_a-1];
							}
							first_a=max(1, k-j);
							last_a=min(k-1, h-(i+k)-1);
							if(first_a<=last_a){
								result+=cnt[i+k+last_a][j-k+last_a];
								if(i+k+first_a-1>=0&&j-k+first_a-1>=0)
									result-=cnt[i+k+first_a-1][j-k+first_a-1];
							}
						}
		writeull(result);
		putchar('\n');
	}
}
int main(){
	whatever::run();
}

Measured memory_bytes: 640
s=input()
if s[0]==s[1]==s[2]==s[3]:
    print("No")
elif (s[0]==s[1] and s[2]==s[3]) or (s[0]==s[2] and s[1]==s[3]) or (s[0]==s[3] and s[1]==s[2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const ll M = 1e9+7;

using namespace std;

int main()
{
    fast;
    ll n,k,i;
    cin>>n>>k;
    n++;
    ll ans=0,tp;
    for (i=k;i<=n;i++)
    {
        tp=((n-i)%M*i%M+1)%M;
        ans=(ans+tp)%M;
    }
    cout<<ans<<endl;
}


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

using namespace std;


int main() {
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    for(int i=1;i<n&&k;i++){
        int j=i;
        while(j<n&&s[j]==s[i])j++;
        
        if(s[j-1]!=s[i-1]){
            for(int l=i;l<=j-1;l++)s[l]=s[i-1];
            k--;
        }
        i=j-1;
    }
    int an=0;
    for(int i=1;i<n;i++){
        an+=s[i]==s[i-1];
    }
    cout<<an;
    return 0;
}

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

int main()
{
	string S; cin >> S;
	int k = S.size();
	int win = 0;

	for (int i = 0; i < k; i++)
	{
		if (S[i] =='o') {
			win++;
		}
	}
	if ((15 - k) + win > 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

string add(string a,string b){
  int numa[200] = {0},numb[200] = {0};
  for(int i = a.size()-1 ; i >= 0 ; i-- )numa[a.size()-i-1] = a[i]-'0';
  for(int i = b.size()-1 ; i >= 0 ; i-- )numb[b.size()-i-1] = b[i]-'0';

  vector<int> renum(201);
  fill(renum.begin(),renum.end(),0);
  int mxsize = max(a.size(),b.size());

  for(int i = 0 ; i < mxsize ; i++ ){
    renum[i+1] += (renum[i] + numa[i] + numb[i])/10;
    renum[i] = (renum[i] + numa[i] + numb[i])%10;
  }

  string srenum = "";
  for(int i = mxsize ; i >= 0 ; i-- ){
    if(i == mxsize && renum[i] == 0)continue;
    srenum += renum[i]+'0';
  }
  return srenum;
}

bool cheak(string str){
  str += '#';
  int spos = 0;
  string num[3];
  int p = 0;
  for(int i = 0 ; spos < str.size() ; i++ ){
    if(str[i+1] < '0' || '9' < str[i+1] ){
      num[p++] = str.substr(spos,i+1-spos);
      spos = i+2;
    }
  }
  return add(num[0],num[1]) == num[2];
}

int main(){
  string str;
  while(  cin >> str ){
    int f = 1;
    for(int i = 0 ; i < 10 ; i++ ){
      string tmp = str;
      for(int j = 0 ; j < tmp.size() ; j++ ){
	if(tmp[j] == 'X')tmp[j] = (i + '0');
      }
      if(cheak(tmp)){
	cout << i;
	f = 0;
	break;
      }
    }
    if(f)cout << "NA";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define repc(i,n) for(int i=0;i<=(n);++i)
#define repcn(i,m,n) for(int i=(m);i<=(n);++i)
#define repcd(i,n) for(int i=(n);i>=0;--i)
#define repcnd(i,m,n) for(int i=(n);i>=(m);--i)
#define repc0(i,n) for(i=0;i<=(n);++i)
#define repcn0(i,m,n) for(i=(m);i<=(n);++i)
#define repcd0(i,n) for(i=(n);i>=0;--i)
#define repcnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE cout<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,1,-1,-1,0};
const int dy[]={0,0,1,-1,1,-1,1,-1,0};

int x[100], y[100];

int main() {
	int n, res, count = 0;
	IL{
		cin >> n;
		if (n == 0) break;
		rep (i, n) cin >> x[i] >> y[i];
		res = 0;
		rep (i, n - 1) res += (x[i + 1] - x[i]) * (y[i + 1] + y[i]);
		res += (x[0] - x[n - 1]) * (y[0] + y[n - 1]);
		res = abs(res);
		printf("%d %.1f\n", ++count, (double)res / 2);
	}
	return 0;
}

Measured memory_bytes: 0