akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <cfloat>
#include <iomanip>

using namespace std;
using ll = long long int;

const ll MOD = 1000000007;

template<typename T>
int cin_vec(vector<T> &vec) {
    for (auto &i : vec) {
        cin >> i;
    }
    return 0;
}

template<typename T>
int cout_vec(vector<T> vec, bool insertNewLine = true) {
    if (insertNewLine) {
        for (const auto &i : vec) {
            cout << i << endl;
        }
    } else {
        for (const auto &i : vec) {
            cout << i << flush;
        }
    }
    return 0;
}

template<typename T>
ll min_vec(std::vector<T> vec) {
    auto iter = min_element(vec.begin(), vec.end());
    ll index = distance(vec.begin(), iter);
    return index;
}

template<typename T>
ll max_vec(std::vector<T> vec) {
    auto iter = max_element(vec.begin(), vec.end());
    ll index = distance(vec.begin(), iter);
    return index;
}

int f(int x, int k) {
    int count = 0;
    while (x < k) {
        ++ count;
        x *= 2;
    }
    return count;
}

int main() {
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += (pow(0.5, f(i, k)) / n);
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
num_be = int(S[:2])
num_af = int(S[2:])

if ( ((num_be > 12) & (num_af > 12)) or ( (num_be == 0) & (num_af == 0) ) or ( (num_be == 0) & (num_af > 12) ) or ( (num_be > 12) & (num_af == 0)) ) :
  print('NA')
elif ( ((num_be > 0) & (num_be < 13)) & ((num_af > 0) & (num_af < 13)) ):
  print('AMBIGUOUS')
elif((num_be > 12) or (num_be == 0) ):
  print('YYMM')
else:
  print('MMYY')

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

using ll = long long;
const int mxN = 1e5;

int n, ans = 1e9;
vector <int> dp[2];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	vector <int> a(n+1);
	dp[0].resize(mxN+1); dp[1].resize(mxN+1);
	for (int i=1; i<=n; i++) {
		cin >> a[i];
		dp[i&1][a[i]] ++;
	}
	for (int i=1; i<=2; i++) {
		int in1 = max_element(dp[0].begin(), dp[0].end()) - dp[0].begin();
		int in2 = max_element(dp[1].begin(), dp[1].end()) - dp[1].begin();
		if (in1 != in2) {
			ans = min(ans, n-dp[0][in1]-dp[1][in2]);
		} else {
			int reserve = dp[1][in1];
			dp[1][in1] = 0;
			in2 = max_element(dp[1].begin(), dp[1].end()) - dp[1].begin();
			ans = min(ans, n-dp[0][in1]-dp[1][in2]);
			dp[1][in1] = reserve;
		}
		swap (dp[0], dp[1]);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1408
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1),i=new(r(2))(n.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));r(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3);t.exports=class{constructor(t){this.inp=new n(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=new Array(e),n=0;n<e;n++)r[n]=[];for(var i=0;i<e-1;i++){var o=t.in(),s=t.in(),u=t.in();r[o-1].push([s-1,u]),r[s-1].push([o-1,u])}for(var f=t.in(),c=t.in(),a=new Array(e).fill(-1),l=[[c-1,0]];l.length>0;)for(var p=l.pop(),d=r[p[0]].length,h=0;h<d;h++){var v=r[p[0]][h];if(-1==a[v[0]]){var y=p[1]+v[1];a[v[0]]=y,l.push([v[0],y])}}for(var b=[],g=0;g<f;g++){var m=t.in()-1,x=t.in()-1,j=a[m]+a[x];b.push(j)}t.fin(),console.log(b.join("\n"))}}]);

Measured memory_bytes: 119408
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}
ll n,m;
vector<vector<ll>> v;
bool reached[8];
void dfs(ll &ans,ll pre){
  reached[pre]=true;
  bool flag=true;
  rep(i,n) if(!reached[i]) flag=false;
  if(flag) ans++;
  for(auto tmp:v[pre]) if(!reached[tmp]) dfs(ans,tmp);
  reached[pre]=false;
}
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll ans=0;
  cin>>n>>m;
  v.resize(n);
  rep(i,m){
    ll a,b;cin>>a>>b;a--;b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(ans,0);
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll q;
    cin >> q;
    vector<ll> count(100001, 0);
    ll sum = 0;
    rep(i, n)
    {
        count[a[i]]++;
        sum += a[i];
    }
    rep(i, q)
    {
        ll b, c;
        cin >> b >> c;
        sum -= count[b] * b;
        sum += count[b] * c;
        count[c]+=count[b];
        count[b] = 0;
        cout << sum << "\n";
    }
}


Measured memory_bytes: 4764
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans = ans*i
        if ans > 1000000000000000000:
            print(-1)
            ans = -1
            break
    if ans != -1:
        print(ans)


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

int main(){
    int N,Y;cin>>N>>Y;
    rep(i,Y/10000+1){
        rep(j,N-i+1){
            if(i*10000+j*5000+(N-i-j)*1000==Y){
                cout<<i<<" "<<j<<" "<<N-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
using namespace std;
int main()
{
    int n, m, i, j, k, l, a[5];
    for(i=0; i<5; i++)
    {
        cin>>a[i];
    }
    cin>>k;
    bool x=0;
    for(i=0; i<5-1; i++)
    {
        for(j=i+1; j<5; j++)
        {
            if((a[j]-a[i])>k)
            {
                x=1;
                break;
            }
        }
    }
    if(x==1)
    {
        cout<<":("<<endl;
    }
    else
        cout<<"Yay!"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
//1130 Red and Black

public class Main {
	int height,width,startx,starty;
	Scanner sc = new Scanner(System.in);
	char[][] field;
	boolean[][] visited;
	int count = 0;
	void run(){
		sc = new Scanner(System.in);
		while(true){
			count = 0;
			width = sc.nextInt();
			height = sc.nextInt();
			if(width == 0 && height == 0){
				break;
			}
			sc.nextLine();
			field = new char[height][width];
			visited = new boolean[height][width];
			for(int i = 0; i < visited.length; i++){
				for(int j = 0; j < visited[i].length; j++){
					visited[i][j] = false;
				}
			}

			for(int i = 0; i < height; i++){
				field[i] = sc.nextLine().toCharArray();
				//System.out.println(field[i]);
			}

			for(int i = 0; i < field.length;i++){
				for(int j = 0; j < field[i].length; j++){
					if(field[i][j] == '@'){
						startx = j;
						starty = i;
					}
				}
			}
			count++;
			dfs(starty,startx);
			System.out.println(count);
		}
	}

	public void dfs(int y, int x){
		if(y + 1 < height && visited[y+1][x] == false && field[y+1][x] == '.'){
			visited[y+1][x] = true;
			count++;
			dfs(y+1,x);
		}
		if(y - 1 > -1 && visited[y-1][x] == false && field[y-1][x] == '.'){

			visited[y-1][x] = true;
			count++;
			dfs(y-1,x);
		}
		if(x + 1 < width && visited[y][x+1] == false && field[y][x+1] == '.'){
			visited[y][x+1] = true;
			count++;
			dfs(y,x+1);
		}
		if(x - 1 > -1 && visited[y][x-1] == false && field[y][x-1] == '.'){
			visited[y][x-1] = true;
			count++;
			dfs(y,x-1);
		}
	}

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().run();
	}

}

Measured memory_bytes: 46292
#include <iostream>

using namespace std;

int s(long n) {
    int s = 0;
    while (n != 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

double f(long n) {
    return (double)n / s(n);
}

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

    long num = 1;
    long base = 1;
    for (long i = 1; i <= k; i++) {
        cout << num << endl;
        double next1 = f(num + base);
        double next2 = f(num + base * 10);
        if (next1 > next2) {
            base *= 10;
        }
        num += base;
    }

    return 0;
}

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

int main(void) {
	int a, b, c;

	cin >> a;
	cin >> b;
	cin >> c;

	int m = min(a + b, b + c);
	
	int m2 = min(m, c + a);

	cout << m2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import deque

h,w=nii()
ch,cw=nii()
dh,dw=nii()
s=[list(input()) for i in range(h)]

ch-=1
cw-=1
dh-=1
dw-=1

ans=[[-1]*w for i in range(h)]
ans[ch][cw]=0

que=deque()
que.append((ch,cw))

def BFS():
  while que:
    y,x=que.popleft()

    if y==dh and x==dw:
      print(ans[y][x])
      exit()

    for dy,dx in [[-1,0],[1,0],[0,-1],[0,1]]:
      ny=y+dy
      nx=x+dx
      if 0<=ny<h and 0<=nx<w and s[ny][nx]!='#':
        que.appendleft((ny,nx))
        s[ny][nx]='#'
        ans[ny][nx]=ans[y][x]

      for i in range(-2,3):
        for j in range(-2,3):
          ny=y+i
          nx=x+j
          if 0<=ny<h and 0<=nx<w and s[ny][nx]!='#' and ans[ny][nx]==-1:
            que.append((ny,nx))
            ans[ny][nx]=ans[y][x]+1

BFS()

print(-1)

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	unsigned long long h, w;
	cin >> h >> w;
	if(h == 1 || w == 1){
		cout << 1 << endl;
	}else if(h * w % 2 == 0){
		cout << h * w / 2 << endl;
	}else{
		cout << (h * w + 1) / 2 << endl;
	}
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) throws IOException {
    execute();
  }

  private static void execute() throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line = br.readLine();
    int a = Integer.parseInt(line.split(" ")[0]);

    System.out.println((calc(a) ? "Yes" : "No"));
  }

  private static boolean calc(int a) {
    for (int i = 1; i <= 9; i++){
      double remain = (double)a / i;
      if(remain - (int) remain == 0.0
      && remain <= 9.0){
        return true;
      }
    }
    return false;
  }
}


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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << " ";cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "Yes": "No") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
#define phi_v 1.618034

const ll inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x; cin >> x;
	printVerdict(x>=30);
}


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

int n = 3000;
long long arr[3000];
long long dp[3001][3001];
bool sht[3001][3001];

long long rec(int l, int r)
{
    if (sht[l][r]) return dp[l][r];
    sht[l][r] = 1;
    
    if (r == l) return dp[l][r] = 0;
    
    if ((r ^ l ^ n) & 1)
        return dp[l][r] = min(rec(l + 1, r) - arr[l], rec(l, r - 1) - arr[r - 1]);
    else
        return dp[l][r] = max(rec(l + 1, r) + arr[l], rec(l, r - 1) + arr[r - 1]);
}

int main()
{
    cin >> n;
    for (int i = 0; i != n; ++i) scanf("%d", &arr[i]);
    
    cout << rec(0, n);
    
    return 0;
}

Measured memory_bytes: 78464
#include<iostream>
#include<algorithm>
using namespace std;
struct Node
{
    int x;
    Node *l,*r,*p;
}*root,*NIL;

void Insert(int v)
{
    Node *x=root,*y=NIL,*z=new Node();
    z->x=v; z->l=z->r=NIL;
    while(x!=NIL)
    {
        y=x;
        if(x->x<v)x=x->r;
        else x=x->l;
    }
    z->p=y;
    if(y==NIL)root=z;
    else if(y->x<v)y->r=z;
    else y->l=z;
}

Node* Find(int v)
{
    Node *x=root;
    while(x!=NIL)
    {
        if(x->x==v)
            return x;
        else if(x->x<v)
            x=x->r;
        else x=x->l;
    }
    return NIL;
}

Node *get_Min(Node *x)
{
    while(x->l!=NIL)x=x->l;
    return x;
}

Node *treeSuccessor(Node *x)
{
    if(x->r!=NIL)return get_Min(x->r);
    Node *y=x->p;
    while(y!=NIL&&x==y->r)
    {
        x=y;
        y=y->p;
    }
    return y;
}
void Delete(Node *z)
{
    Node *y,*x;
    if(z->l==NIL||z->r==NIL)
        y=z;
    else y=treeSuccessor(z);
    if(y->l!=NIL)x=y->l;
    else x=y->r;
    if(x!=NIL)x->p=y->p;
    if(y->p==NIL)
        root=x;
    else
    {
        if(y==y->p->l)
            y->p->l=x;
        else y->p->r=x;
    }
    if(y!=z)z->x=y->x;
}
void Pre(Node *x)
{
    if(x==NIL)return ;
    cout<<' '<<x->x;
    Pre(x->l);
    Pre(x->r);
}
void Inorder(Node *x)
{
    if(x==NIL)return ;
    Inorder(x->l);
    cout<<' '<<x->x;
    Inorder(x->r);
}
void Print()
{
    Inorder(root);cout<<endl;
    Pre(root);cout<<endl;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s;int x;
        cin>>s;
        if(s=="insert")
        {
            cin>>x;Insert(x);
        }
        else if(s=="find")
        {
            cin>>x;
            if(Find(x)!=NIL)
                cout<<"yes"<<endl;
            else
                cout<<"no"<<endl;
        }
        else if(s=="delete")
        {
            cin>>x;
            Delete(Find(x));
        }
        else Print();
    }
    return 0;
}



Measured memory_bytes: 21816
//#define anjn
//      Anjan Agarwala - anjn98

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, 
                  tree_order_statistics_node_update> ordered_set;

//ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

#define PR(x) cout<<#x<<": "<<x<<"\n";
#define PR1(x,y) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"  |  "<<#z<<": "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007


const int N=5e3+99;


int32_t main() 
{
    IO

    int x,a;
    cin>>x>>a;
    if(x<a)
        cout<<0<<endl;
    else 
        cout<<10<<endl;

    
}




 
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int t,n,up=-1,down=N;
int a[N],b[N],num[N];
template <typename T>
inline void read(T &x)
{
	T flg=1;x=0;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') flg=-flg;ch=getchar();}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	x*=flg;
}
template <typename T>
inline void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
inline int max(const int& x,const int& y) {return x>y?x:y;}
inline int min(const int& x,const int& y) {return x<y?x:y;}
signed main()
{
	read(n);
	for(register int i=1;i<=n;++i)
	  {
	  	read(a[i]);
	  	++b[a[i]];
	  	up=max(up,a[i]);
	  	down=min(down,a[i]);
	  }
	if(up-down>1) {puts("No");return 0;}
	if(up-down==0)
	  {
		if(up<=n/2||up==n-1) {puts("Yes");return 0;}
		else {puts("No");return 0;}
	  }
	int col=up;
	if(col>=b[down]+1&&col<=b[down]+(n-b[down])/2) puts("Yes");
	else puts("No");
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

string S;

bool dfs(string s) {
  if(s == "ABC") return true;

  int cnt = 0;
  string t = "";
  REP(i, 0, s.length()) {
    if(i <= s.length() - 3 && s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
      t += 'X';
      i += 2;
      cnt++;
    } else t += s[i];
  }

  if(cnt == 0) return false;

  bool ret = false;
  REP(i, 0, 3) {
    string u = "";
    bool f = true;
    REP(j, 0, t.length()) {
      if(t[j] == 'A' + i) f = false;
      u += (t[j] == 'X' ? 'A' + i : t[j]);
    }
    if(f) ret = ret || dfs(u);
  }

  return ret;
}

int main(void) {
  cin >> S;
  cout << (dfs(S) ? "Yes" : "No") << endl;
  return 0;
}

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

int main() {
	// your code goes here
	int A,B,C;
	int max, min;
	scanf("%d %d %d", &A, &B, &C);
	max = A;
	min = A;
	if(max<B){max = B;}
	if(min>B){min = B;}
	if(max<C){max = C;}
	if(min>C){min = C;}
	
	printf("%d\n", max-min);
	
	return 0;
}

Measured memory_bytes: 128
class UnionFind:
    def __init__(self, size):
        self.data = [-1] * size
    def root(self, x):
        if self.data[x] < 0:
            return x
        ans = self.root(self.data[x])
        self.data[x] = ans
        return ans
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.data[x] > self.data[y]:
            x, y = y, x
        self.data[x] += self.data[y]
        self.data[y] = x
        return True
    def same(self, x, y):
        return self.root(x) == self.root(y)
    def size(self, x):
        return -self.data[self.root(x)]

"""
Union-Find 森

https://scrapbox.io/data-structures/Union_Find

UnionFind(size):
0 ~ size - 1 がそれぞれ別々の集合に属するものとして初期化

root(x) -> void:
x が属する集合を表す根付き木の頂点を返す

unite(x) -> Bool:
root(x) と root(y) の間に辺を張り, x が属する集合と y が属する集合を結合する
変更があったかが返る (もともと同じ集合に属していたら False)

same(x, y) -> Bool:
x と y が同じ集合に属するか判定する

size(x) -> Int:
x が属する集合の要素数を返す

実装について
data[x] は data[x] < 0 のとき根であり, data[x] == -size(x) となっています
また, data[x] >= 0 のとき子であり, data[x] は親の番号を表しています
unite(x) は 
if self.data[x] > self.data[y]:
    x, y = y, x
で計算量が落ちます(データ構造をマージする一般的なテク)
root(x) は
self.data[x] = ans
で計算量が落ちます(経路圧縮)
"""


# https://atcoder.jp/contests/arc097/tasks/arc097_b

n, m = map(int, input().split())
p = list(map(int, input().split()))
for i in range(n):
    p[i] -= 1
uf = UnionFind(n)
for i in range(m):
    x, y = map(int, input().split())
    uf.unite(x - 1, y - 1)
ans = 0
for i in range(n):
    ans += uf.same(i, p[i])
print(ans)

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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 1e5 + 10;
const int M = (int) 2e6 + 7;
const ll LINF = (ll) 1e16;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;

int n;
ll pref[N], a[N];

ll get_low(int l, int r) {
	return a[r] * (r - l + 1) - (pref[r] - pref[l - 1]);
}

ll get_high(int l, int r) {
	return pref[r] - pref[l - 1] - a[l] * (r - l + 1);
}

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n;
    for (int i = 1; i <= n; i++) {
    	cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    /*
    for (int i = 1; i <= n; i++) {
    	pref[i] = pref[i - 1] + a[i];
	}
    for (int i = 1, l = 1, r = 1; i <= n; i++) {
    	while (l < i && get_low(l, i) + get_high(i, r) > n) {
    		if (a[i] - a[l] > a[r] - a[i]) ++l;
    		else --r;
    	}
		while (r <= n && get_low(l, i) + get_high(i, r) <= n) {
    		++r;
    	}
    	cout << i << ' ' << l << ' ' << r - 1 << endl;
    	ans = max(ans, r - l);
    }
    */
	int ans = 0;
    for (int i = 1, l = 1, r = 1; i <= n; i++) {
    	while (abs(a[i] - a[l]) > 1) ++l;
    	while (r <= n && abs(a[i] - a[r]) < 2) ++r;
    	ans = max(ans, r - l);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
const int N=102;
int n,cnp,cnj,cnt,og[N],hx[N<<1],fir[N<<1],prm[460];
bool npr[3200];
struct edge{
	int to,wi,nx;
}eg[N*N];

inline void add(int a,int b,int v){
	static int cnt=1;
	eg[++cnt]=(edge){b,v,fir[a]};
	fir[a]=cnt;
	eg[++cnt]=(edge){a,0,fir[b]};
	fir[b]=cnt;
}

inline char get_c(){
	static char buf[20000],*h,*t;
	if(h==t){
		t=(h=buf)+fread(buf,1,20000,stdin);
	}
	return h==t?EOF:*h++;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=get_c())>'9'||c<'0');
	while(x=x*10-48+c,(c=get_c())>='0'&&c<='9');
	return x;
}

inline void init(){
	npr[1]=1;
	for(int i=2;i<3200;++i){
		if(!npr[i]) prm[++cnp]=i;
		for(int j=1;j<=cnp&&i*prm[j]<3200;++j){
			npr[i*prm[j]]=1;
			if(i%prm[j]==0) break;
		}
	}
}

inline bool ispr(int x){
	if(x<3200) return !npr[x];
	int sq=sqrt(x)+1;
	for(int i=1;prm[i]<=sq;++i){
		if(x%prm[i]==0) return 0;
	}
	return 1;
}

namespace F{
	int dep[N<<1],que[N<<1],cur[N<<1];

	inline bool bfs(){
		memset(dep,0,sizeof(dep));
		int hd=0,tl=1;
		dep[0]=1;
		while(hd!=tl){
			int x=que[hd++];
			for(int i=cur[x]=fir[x];i;i=eg[i].nx){
				int y=eg[i].to;
				if(eg[i].wi&&!dep[y]){
					dep[y]=dep[x]+1;
					que[tl++]=y;
				}
			}
		}
		return dep[(N<<1)-1];
	}

	int dfs(int x,int t){
		if(x==(N<<1)-1) return t;
		int tp,tt=t;
		for(int &i=cur[x];i;i=eg[i].nx){
			int y=eg[i].to,v=eg[i].wi;
			if(v&&tt&&dep[x]+1==dep[y]&&(tp=dfs(y,std::min(v,tt)))){
				eg[i].wi-=tp;
				eg[i^1].wi+=tp;
				tt-=tp;
				if(!tt) break;
			}
		}
		return t-tt;
	}
}

int main(){
#ifndef ONLINE_JUDGE
//	freopen("c.in","r",stdin);
#endif
	init();
	n=nxi();
	for(int i=1;i<=n;++i){
		og[i]=nxi();
	}
	std::sort(og+1,og+n+1);
	og[0]=-1;
	for(int i=1;i<=n;++i){
		if(og[i]-og[i-1]>1){
			if(og[i-1]+1) hx[++cnt]=og[i-1]+1;
			hx[++cnt]=og[i];
		}
	}
	hx[++cnt]=og[n]+1;
	for(int i=1;i<=cnt;++i){
		if(hx[i]&1) ++cnj;
		if(hx[i]&1) add(0,i,1);
		else add(i,(N<<1)-1,1);
		for(int j=i+1;j<=cnt;++j){
			int p=hx[j]-hx[i];
			if((p&1)&&ispr(p)){
				if(hx[i]&1) add(i,j,1);
				else add(j,i,1);
			}
		}
	}
	int ans=0;
	while(F::bfs()){
		ans+=F::dfs(0,N);
	}
	printf("%d\n",cnt-ans+((cnj-ans)&1));
	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scan.nextInt();
        int c = scan.nextInt();
        int[][] d = new int[c][c];
        for (int i = 0; i < c; i++) {
            for (int j = 0; j < c; j++) {
                d[i][j] = scan.nextInt();
            }
        }
        int[][] g = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                g[i][j] = scan.nextInt() - 1;
            }
        }
        Main main = new Main();
        System.out.println(main.solve(n, c, d, g));
    }

    public int solve(int n, int c, int[][] d, int[][] g) {
        int[][] count_of_colors = new int[3][30];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                count_of_colors[(i+j)%3][g[i][j]] += 1;
            }
        }
        int answer = Integer.MAX_VALUE;
        for (int i = 0; i < c; i++) {
            int first_group_difference = difference(d, c, count_of_colors[0], i);
            for (int j = 0; j < c; j++) {
                if (i == j) {
                    continue;
                }
                int second_group_difference = difference(d, c, count_of_colors[1], j);
                for (int k = 0; k < c; k++) {
                    if (i == k || j == k) {
                        continue;
                    }
                    int third_group_difference = difference(d, c, count_of_colors[2], k);
                    answer = Math.min(answer, first_group_difference + second_group_difference + third_group_difference);
                }
            }
        }
        return answer;
    }

    public int difference(int[][] d, int c, int[] count, int color) {
        int diff = 0;
        for(int i = 0; i < c; i++) {
            diff += count[i] * d[i][color];
        }
        return diff;
    }
 
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

struct cube { // NOT VERIFIED
  int f[6];
  unordered_map<int, string> mp;
  cube(){}
  /*
      1
    4 2 3 5
      6
  */
  cube(vector<int> const& vs){ for(int i=0; i<6; i++) f[i] = vs[i]; }
  cube(vector<string> const& vs) { for(int i=0; i<6; i++) mp[i+1] = vs[i]; }
  void roll_z() { roll(1, 2, 4, 3); }
  void roll_y() { roll(0, 2, 5, 3); }
  void roll_x() { roll(0, 1, 5, 4); }
  void roll(int i, int j, int k, int l) {
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }

  void roll(int k) {
    if(k == 0) roll_y();
    if(k == 1) roll_x();
    if(k == 2) for(int i=0; i<3; i++) roll_y();
    if(k == 3) for(int i=0; i<3; i++) roll_x();
  }

  int right(int top, int front) const {
    cube c = *this;
    for(int i=0; i<6; i++) {
      for(int j=0; j<4; j++) {
        if(c.f[0] == top && c.f[1] == front) return c.f[2];
        c.roll_z();
      }
      if(i % 2 == 0) c.roll_y();
      else c.roll_x();
    }
    return -1;
  }

  bool operator == (cube const& rhs) const {
    for(int i=0; i<6; i++)
      if(f[i] != rhs.f[i]) return false;
    return true;
  }

  bool isomorphic(cube rhs) const {
    for(int i=0; i<6; i++) {
      for(int j=0; j<4; j++) {
        if(operator==(rhs)) return true;
        rhs.roll_z();
      }
      if(i % 2 == 0) rhs.roll_y();
      else rhs.roll_x();
    }
    return false;
  }

};

int main() {

  cube c; for(int i=0; i<6; i++) cin >> c.f[i];
  string q; cin >> q;
  string d = "WNES";
  rep(i, q.size()) c.roll(d.find(q[i]));
  cout << c.f[0] << endl;
  
  return 0;
}

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

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


def run():
    N, *A = map(int, read().split())
    SUM = sum(A)
    ans = 0
    for a in A:
        ans += ((SUM - a) * a)%mod
        ans %= mod
        SUM -= a
    print(ans)


if __name__ == "__main__":
    run()

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

int main(){
   int n, k, a[1000];
   cin >> n >> k;
   for(int i=0; i<n; ++i)
	cin >> a[i];
sort(a, a+n);
int s=0;
	for(int i=0;i<k;++i)
		s+=a[i];
	cout<<s;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int X;
	cin >> X;
	for (int i = X;i >= 0;i--) {
		for (int j = 2;j*j <= X;j++) {
			int Y = i;
			while (Y > 1) {
				if (Y % j) break;
				Y /= j;
			}
			if (Y == 1) {
				cout << i << "\n";
				return 0;
			}
		}
	}
	cout << 1 << "\n";

	return 0;
}

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

int main() {
  int N,ans=0;
  cin >> N;
  int A[N+1],B[N+1],C[N];
  for(int i=1;i<=N;i++) cin >> A[i];
  for(int i=1;i<=N;i++) cin >> B[i];
  for(int i=1;i<=N-1;i++) cin >> C[i];
  
  for(int i=1;i<=N;i++){
    ans += B[A[i]];
    if(A[i]==A[i-1]+1) ans += C[A[i-1]];
  }
  
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

int main() {
	int n;
	scanf("%d", &n);
	ll a[n];
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		sum += a[i];
	}
	
	ll div = (ll)n * (n + 1) / 2;
	if (sum % div != 0) {
		printf("NO\n");
		return 0;
	}
	
	int need = sum / div;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int d = a[(i + 1) % n] - a[i];
		d -= need;
		if (d > 0) {
			printf("NO\n");
			return 0;
		}
		d = -d;
		if (d % n != 0) {
			printf("NO\n");
			return 0;
		} else {
			cnt += d / n;
		}
		
		if (cnt > need) {
			printf("NO\n");
			return 0;
		}
	}
	
	
	
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
#include <functional>


using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int n, k;
bool a[10];

bool check(int n) {
	while (n > 0) {
		int t = n % 10;
		if (a[t] == 1)
			return false;
		n = n / 10;
	}
	return true;
}

int main(){
	cin >> n >> k;
	int t;
	rep(i, k) {
		cin >> t;
		a[t] = 1;
	}
	int ans;
	for (ans = n;; ans++) {
		if (check(ans))
			break;
	}
	

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


Measured memory_bytes: 256
#include"iostream"
using namespace std;


int main(){
	int a=100000;
	int b;
	cin>>b;
	for(int i=0;i<b;i++){
	a+=int(a*0.05);
	if(!(a%1000==0)){
	a/=1000;
	a++;
	a*=1000;
	}
	}
	cout << a<< endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

string sort(string str, int len, int x){
    while(len != str.size()) str+='0';
    if(x == 1){
        rep(i,str.size() - 1){
            rep(j,str.size() - 1){
                if(str[j] > str[j + 1]){
                    char temp = str[j];
                    str[j] = str[j + 1];
                    str[j + 1] = temp;
                }
            }
        }
    }else if(x == 0){
        rep(i,str.size() - 1){
            rep(j,str.size() - 1){
                if(str[j] < str[j + 1]){
                    char temp = str[j];
                    str[j] = str[j + 1];
                    str[j + 1] = temp;
                }
            }
        }
    }
    return str;
}

int changeNum(string str){
    int num = 0, K = 1;
    for(int i = str.size() - 1; i >= 0; i--){
        num+=(str[i] - '0') * K;
        K*=10;
    }
    return num;
}

string changeStr(int n, int len){
    string str;
    int K = 1;
    rep(i,len) K*=10;
    rep(i,len + 1){
        if(n / K == 0) str+= '0';
        else str+= ('0' + n / K);
        n%=K; K/=10;
    }
    return str;
}

bool checkNum(int a[25], int i){
    rep(j,i){
        if(a[i] == a[j] && i != j){
            cout << j << ' ' << a[i] << ' ' << i - j << endl;
            return 1;
        }
    }
    return 0;
}

int main(){
    string str;
    int len, A[25];
    while(cin >> str >> len, str[0] != '0'||len){
        A[0] = changeNum(sort(str, len, -1));
        range(i,1,24){
            A[i] = changeNum(sort(str, len, 0)) - changeNum(sort(str,len, 1));
            str = changeStr(A[i], len - 1);
            if(checkNum(A, i)) break;
        }
    }
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acos(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	ll n;
	cin >> n;
	cout << ((n - 1) * n) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define pb(x) push_back(x)
#define sss(str) scanf("%s",str+1)
#define ssf(x) scanf("%lf",&x)
#define aLL(x) x.begin(),x.end()
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef double dd;
typedef pair<LL,LL> pt;
const int N=5e5+5;
const int M=2e2+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int sz=18;
const double eps=1e-10;
const double pi=acos(-1);
//***********************
int n,m;
char str[N];
//***********************
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    r(n);
    sss(str);
    set<int> s[30];
    FOR(i,1,n){
        int t=str[i]-'a'+1;
        s[t].insert(i);
    }
    r(m);
    FOR(i,1,m){
        int op;
        r(op);
        if(op==1){
            int a; char c;
            scanf("%d %c",&a,&c);
            int b=c-'a'+1;
            FOR(i,1,26){
                if(s[i].count(a)){
                    s[i].erase(a);
                    break;
                }
            }
            s[b].insert(a);
        }
        else if(op==2){
            int a,b;
            rr(a,b);
            int ans=0;
            FOR(i,1,26){
                if(s[i].lower_bound(a)!=s[i].upper_bound(b)) ans++;
            }
            cout<<ans<<endl;
        }
    }
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, m, q;
		cin >> n >> m >> q;
		if (!n)break;
		vvi v(m, vi(n, 1));
		string prev;
		REP(i, m)prev += '0';
		REP(i, q) {
			string a, b;
			cin >> a >> b;
			REP(j, m) {
				if (prev[j] != b[j]) {
					REP(k, n) {
						v[j][k] &= (a[k]-'0');
					}
				}
				else {
					REP(k, n) {
						v[j][k] &= (1-int(a[k] - '0'));
					}
				}
			}
			prev = b;
		}
		REP(i, m) {
			int ans = -1, cnt = 0;
			REP(j, n) {
				if (v[i][j]) {
					cnt++;
					ans = j;
				}
			}
			if (cnt == 1) {
				if (ans <= 9)cout << char(ans + '0');
				else cout << char(ans - 10 + 'A');
			}
			else cout << '?';
		}
		cout << endl;
	}
	

	return 0;
}

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

int main(){
	int n;
  cin>>n;
  vector<int> v(n);
  for(auto &a:v){
  	cin>>a;
  }
  int k = *min_element(v.begin(),v.end());
  int maxs =INT_MAX;
  for(;k<=100;k++){
  	int sum=0;
    for(auto a:v){
    	sum += pow(a-k,2);
    }
    maxs = min(sum,maxs);
  }
  if(maxs==INT_MAX) cout<<0;
  else cout<<maxs;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
b1,b2,b3=map(int,input().split())

if b1==1 and b2==0 and b3==0:
    print('Close')
elif b1==0 and b2==1 and b3==0:
    print('Close')
elif b1==1 and b2==1 and b3==0:
    print('Open')
elif b1==0 and b2==0 and b3==1:
    print('Open')
else:
    print('Close')


Measured memory_bytes: 5596
#include<stdio.h>

int myAbs(int a){
	if(a < 0) a = -a;
	return a;
}

int min(int a, int b){
	if(a < b){
		return a;
	}
	return b;
}

int minList(int a[ ], int size){
	int i = 0;
	int ret = a[i];
	for(i = 1; i < size; i++){
		ret = min(ret, a[i]);
	}
	return ret;
}

int main(){
	int N, X, Y;
	scanf("%d %d %d", &N, &X, &Y);
	int i, j;
	int a[3];
	int b[N];
	for(i = 0; i < N; i++){
		b[i] = 0;
	}
	for(i = 1; i < N; i++){
		for(j = i+1; j <= N; j++){
			a[0] = myAbs(j - i);
			a[1] = myAbs(X - i) + 1 + myAbs(j - Y);
			a[2] = myAbs(Y - i) + 1 + myAbs(j - X);
			b[minList(a, 3)]++; 
		}
	}
	for(i = 1; i < N; i++){
		printf("%d\n", b[i]);
	}
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string a,b;
	cin>>a>>b;
	bool ag=false,al=false;
	if(a.size()>b.size())ag=true;
	else if(a.size()<b.size())al=true;
	else for(int i=0;i<a.size();++i){
		if(a.at(i)>b.at(i)){
			ag=true;
			break;
		}else if(a.at(i)<b.at(i)){
			al=true;
			break;
		}
	}
	if(ag)cout<<"GREATER"s;
	else if(al)cout<<"LESS"s;
	else cout<<"EQUAL"s;
	cout<<"\n"s;
}

Measured memory_bytes: 256
while True:
    (H, W) = [int(x) for x in input().split()]
    if H == W == 0:
        break

    for hc in range(H):
        for wc in range(W):
            if hc == 0 or hc == H - 1:
                print('#', end='')
            else:
                print('#', end='') if wc == 0 or wc == W - 1 else print('.', end='')

        print()

    print()

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

typedef long long ll;

int main() {
    ll N, P, e = 0, o = 0;
    cin >> N >> P;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        if (A[i] % 2) o++;
        else e++;
    }
    if (o == 0) {
        if (P) {
            cout << "0\n";
        } else {
            cout << (1LL << N) << "\n";
        }
    } else {
        cout << (1LL << (N - 1)) << "\n";
    }
}

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

using namespace std;
int main() {
    string N;
    int ans=0,n;
    cin >> N;
    n=N.size();

    if(n%2==1)
        ans+=stoi(N)-pow(10,n-1)+1;
    for(int i=1;i<n;i++) {
        if(i%2==1)
            ans += 9 * pow(10, i-1);

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



Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
state = [list(input().rstrip()) for _ in range(H)]

q = [(x1-1, y1-1)]
checked = [[-1]*W for _ in range(H)]
checked[x1-1][y1-1] = 0
while q:
    qq = []
    for x, y in q:
        d = checked[x][y]
        dx = 1
        while x+dx < H and state[x+dx][y] == ord(".") and dx <= K:
            if checked[x+dx][y] == -1:
                checked[x+dx][y] = d + 1
                qq.append((x+dx, y))
            elif checked[x+dx][y] >= d + 1:
                checked[x+dx][y] = d + 1
            else:
                break
            dx += 1
        dx = -1
        while x+dx >= 0 and state[x+dx][y] == ord(".") and dx >= -K:
            if checked[x+dx][y] == -1:
                checked[x+dx][y] = d + 1
                qq.append((x+dx, y))
            elif checked[x+dx][y] >= d+1:
                checked[x+dx][y] = d + 1
            else:
                break
            dx -= 1
        dy = 1
        while y+dy < W and state[x][y+dy] == ord(".") and dy <= K:
            if checked[x][y+dy] == -1:
                checked[x][y+dy] = d + 1
                qq.append((x, y+dy))
            elif checked[x][y+dy] >= d+1:
                checked[x][y+dy] = d+1
            else:
                break
            dy += 1
        dy = -1
        while y+dy >= 0 and state[x][y+dy] == ord(".") and dy >= -K:
            if checked[x][y+dy] == -1:
                checked[x][y+dy] = d + 1
                qq.append((x, y+dy))
            elif checked[x][y+dy] >= d+1:
                checked[x][y+dy] = d+1
            else:
                break
            dy -= 1
    q = qq

print(checked[x2-1][y2-1])

Measured memory_bytes: 107868