akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll x;
  R x;
  ll dp[x+1];
  mem(dp);
  dp[0]=1;
  rep(i,x) {
    rep(j,6) {
      if(i+100+j<=x) dp[i+100+j]|=dp[i];
    }
  }
  pr(dp[x]);
}

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


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A == 1) A += 13;
  if (B == 1) B += 13;
  if (A > B) cout << "Alice\n";
  else if (A < B) cout << "Bob\n";
  else cout << "Draw\n";
  return 0;
}


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

int main(){
    int H, W;


    while(1){
        cin >> H >> W;
        if(0 == H && 0 == W){
            break;
        }

        // cout << H << " " << W << endl;

        for(int j = 0; j < H; j++){
            for(int i = 0; i < W; i++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	s := input()
	n := len(s)
	stack := make([]byte, 0, n)
	for i := 0; i < n; i++ {
		if s[i] == 'S' {
			stack = append(stack, s[i])
		} else {
			if len(stack) == 0 || stack[len(stack)-1] == 'T' {
				stack = append(stack, s[i])
			} else {
				stack = stack[:len(stack)-1]
			}
		}
	}
	fmt.Println(len(stack))
}


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, k;
    cin >> n >> k;
    map<i64, i64> ab;
    for (i64 i = 0; i < n; i++) {
        i64 a, b;
        cin >> a >> b;
        if (a <= k) ab[a] += b;
    }

    i64 ans = 0;
    for (auto& e : ab) {
        i64 a, b;
        tie(a, b) = e;
        if (((a | k) ^ k) == 0) ans += b;
    }

    for (i64 i = 0; i < 30; i++) {
        if (((k >> i) & 1) == 0) continue;
        i64 can = 0;
        for (auto& e : ab) {
            i64 a, b;
            tie(a, b) = e;
            if ((((a | k) ^ k) >> (i + 1)) == 0 && ((a >> i) & 1) == 0) can += b;
        }
        ans = max(ans, can);
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 6528
function Main(input) {
    input = input.split('\n');
    input = input.map(function(e) {
        return e.split(' ').map(function(e) {
            return parseInt(e, 10);
        });
    });
    var r = 0;
    for (var i = 1; i < input.length-1; i++) {
        r += (input[i][1] - input[i][0] + 1);
    }

    console.log('%d', r);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7740
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<cstdio>

using namespace std;
int  main()
{
    int n,k;
    cin>>n>>k;
    int x[1005];
    for(int i=0;i<n;++i)
    	cin>>x[i];
    sort(x,x+n);
    long long sum=0;
    for(int i=0;i<k;++i)
    	sum+=x[i];
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3148
#include<stdio.h>
#include<string.h>
int main()
{
      int n;
      scanf("%d",&n);
      char s[n][10];
      int i,a,b,c,d;
      a=b=c=d=0;
      for(i=0;i<n;i++)
      {
            scanf("%s",s[i]);
            if(strcmp(s[i],"AC")==0) a++;
            else if(strcmp(s[i],"TLE")==0) b++;
            else if(strcmp(s[i],"WA")==0) c++;
            else if(strcmp(s[i],"RE")==0) d++;
      }
      printf("AC x %d\n",a);
      printf("WA x %d\n",c);
      printf("TLE x %d\n",b);
      printf("RE x %d\n",d);
}


Measured memory_bytes: 2704
/*------------------------------------------------,
|  __                                       __    |
| |  |--.-----.---.-.----.----.-----.-----.|  |_  |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _| |
| |_____|_____|___._|____|____|_____|   __||____| |
|                                   |__|          |
`------------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdint>
#include<deque>
#include<functional>
#include<iomanip>
#include<ios>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; using namespace std;
#define INF 2147483647
#define MOD 10000007
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {
  int ans=0;
  REP(i,5){
    int a;
    cin>>a;
    if(a==0)ans=i+1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 1;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
ll n, m, x = 0, y,z,w,h, sum= 0, ans = 0;
string s, t;
int main() {
	cin >> h >> w; char c;
	map<char, int> mp;
	rep(i, h) {
		rep(j, w) {
			cin >> c;
			mp[c]++;
		}
	}
	for (auto k : mp) {
		sum += k.second % 2;
		if (k.second % 4 > 1) ans++;
	}
	if (h % 2 && w % 2) {
		if (ans > w / 2 + h / 2 || sum > 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	else if (h % 2 || w % 2) {
		if (sum > 0 || ans > h % 2 * w / 2 + w % 2 * h / 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	else {
		if (sum > 0 || ans > 0) {
			cout << "No" << endl;
			return 0;
		}
	}cout << "Yes" << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

N = int(input())
alpha = [chr(ord('a') + i) for i in range(26)]

def dfs(s, max_i):
  if len(s) == N:
    print(s)
  else:
    for i in range(97,max_i+1):
      dfs(s+chr(i), max(max_i, i+1))

dfs('', 97)

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string S;
	cin >> S;

	int kotae = 1e9;
	rep(i, S.size() - 2) {
		string T = S.substr(i, 3);
		int N = stoi(T);
		kotae = min(kotae, abs(753 - N));
	}
	co(kotae);

	Would you please return 0;
}

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

typedef struct Node{
	int key;
	struct Node *left;
	struct Node *right;
}Node;

void insert(Node **p,int x){
	
	while((*p)!=NULL){
		
		if((*p)->key > x)
			p=&((*p)->left);
		else
			p=&((*p)->right);
			
	}
	
	*p=malloc(sizeof(Node));
	(*p)->key=x;
	(*p)->left=NULL;
	(*p)->right=NULL;
	
	return;
}

void Delete(Node **p,int x){
	Node *q=*p;
	Node **r;
	
	while(q!=NULL){
	
		if(q->key == x){
		
			if(q->left==NULL && q->right==NULL){
				free(q);
				*p=NULL;
				return;
			}
			else if(q->left==NULL && q->right!=NULL){
				//p=&(q->right);
				*p=q->right;
				return;
			}
			else if(q->left!=NULL && q->right==NULL){
				//p=&(q->left);
				*p=q->left;
				return;
			}
			else {
				r=&(q->right);
				q=*r;
				//printf("rkey %d\n",(*r)->key);
				while(q->left!=NULL){
					r=&(q->left);
					q=*r;
					/*q=q->left;
					*r=q;*/
				}
				(*p)->key=q->key;
				//printf("rkey %d\n",(*r)->key);
				Delete(r,q->key);
				return;
			}
			
		}	
		
		else if(q->key > x){
			p=&(q->left);
			q=*p;
		}
		else {
			p=&(q->right);
			q=*p;
		}
		
	}

	return;
}

void inorder(Node *p){
	
	if(p->left!=NULL)
		inorder(p->left);
	
	printf(" %d",p->key);
	
	if(p->right!=NULL)
		inorder(p->right);
	
	return;
}

void preorder(Node *p){
	
	printf(" %d",p->key);
	
	if(p->left!=NULL)
		preorder(p->left);
	
	if(p->right!=NULL)
		preorder(p->right);
	
	return;
}

void print(Node *root){
	inorder(root);
	printf("\n");
	
	preorder(root);
	printf("\n");
	
	return;
}

int find(Node *p,int x){

	while(p!=NULL){
		if(p->key == x)return 1;
		
		if(p->key > x)
			p=p->left;
		else
			p=p->right;
	}
	
	return 0;
	
}

int main(){
	int q,x;
	Node *root=NULL;
	char com[10];
	
	scanf("%d",&q);
	
	for(int i=0;i<q;i++){
		scanf("%s",com);
		
		if(com[0]=='i'){
			scanf("%d",&x);
			insert(&root,x);
		}
		
		else if(com[0]=='f'){
			scanf("%d",&x);
			if(find(root,x))
				printf("yes\n");
			else
				printf("no\n");
		}
		
		else if(com[0]=='p')
			print(root);
		
		else if(com[0]=='d'){
			scanf("%d",&x);
			Delete(&root,x);
		}
	}
	
	return 0;
	
}


Measured memory_bytes: 14364
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
	line := nextLine()

	for i := 0; i < 3; i++ {

		if string(line[i]) == "1" {
			fmt.Print(9)
		} else {
			fmt.Print(1)
		}
	}
	fmt.Println()
}


Measured memory_bytes: 640
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![0; n];
    let mut open = HashMap::<usize, usize>::new();
    for i in 0..n {
        let v = read::<usize>();
        seq[i] = v;
        *open.entry(v).or_insert(0) += 1;
    }
    seq.sort();
    seq.dedup();
    let mut ans = "No";
    if seq.len() == 1 {
        if seq[0] == 0 {
            ans = "Yes";
        }
    } else if seq.len() == 2 {
        if seq[0] == 0 && open[&seq[1]] == open[&0] * 2 {
            ans = "Yes";
        }
    } else if seq.len() == 3 {
        if open[&seq[0]] == open[&seq[1]] && open[&seq[1]] == open[&seq[2]] && seq[0] ^ seq[1] == seq[2] {
            ans = "Yes";
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 12540
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll n,x,y;
    cin >> n >> x >> y;

    double xyc = (x+y)/2.0f;
    vll dists(n);
    FOR(i,1,n){
        FOR(j,i+1,n){
            //printf("(%d,%d):",i,j);
            ll dist;
            // i to j
            dist = min(abs(x-i)+1+abs(j-y), j-i);
            //printf("%d\n",dist);
            dists[dist]++;
        }
    }

    FOR(k,1,n-1){
        cout << dists[k] << endl;
        // if(k==1){
        //     cout << n << endl;
        //     continue;
        // }else if(k==n-1){
        //     cout << 0 << endl;
        //     continue;
        // }

    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int n,ans=0;
	string s;
	cin >> n >> s;
	rep(i, n - 1) {
		string l, r;
		int tmp = 0;
		l = s.substr(0, i + 1);
		r = s.substr(i + 1, n - i - 1);
		for (char c = 'a'; c <= 'z'; c++) {
			if (l.find(c) != string::npos&&r.find(c) != string::npos)tmp++;
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
using namespace std;
using Int = int64_t;
auto prime_factor(Int n) {
    unordered_map<Int, Int> ret;
    for(Int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}
int main() {
    Int N, P;
    cin >> N >> P;
    auto m = prime_factor(P);
    Int ans = 1;
    for (const auto& p : m) for (Int i = 0; i < p.second / N; i++) ans *= p.first;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<ll> a(n+1);
    rep(i,n+1) cin>>a[i];

    if(n==0){
        if(a[0]==1) cout<<1<<endl;
        else cout<<-1<<endl;
        return 0;
    }

    if(a[0]!=0){
        cout<<-1<<endl;
        return 0;
    }

    ll cur=1;
    ll ans=1;
    ll tot=0;
    rep(i,n+1) tot+=a[i];
    for(int i=1;i<n+1;i++){
        cur*=2;
        if(cur<a[i]){
            cout<<-1<<endl;
            return 0;
        }

        ans+=min(cur,tot);
        cur=min(cur,tot)-a[i];
        tot-=a[i];
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, K;
    cin >> N >> K;
    double ans;
    vector<ll> p(N);
    ll Sum = 0;
    ll MaxVal, MaxIndex;
    REP(ll,i,0,K){
        cin >> p.at(i);
        Sum += p.at(i);
    }
    MaxVal   = Sum;
    MaxIndex = K - 1;
    REP(ll,i,K,N){
        cin >> p.at(i);
        Sum += p.at(i) - p.at(i-K);
        if ( MaxVal < Sum ){
            MaxIndex = i;
            MaxVal = Sum;
        }
    }
    //cout << MaxIndex << " " << MaxVal << endl;
    ans = 0.0;
    for ( int i = MaxIndex; i > MaxIndex - K; i--){
        ans += 0.5 * ( p.at(i) + 1 );
    }
    printf("%f\n",ans);
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var X, Y, Z, K int

	fmt.Scan(&X, &Y, &Z, &K)

	var A = make(SortBy, X)
	var B = make(SortBy, Y)
	var C = make(SortBy, Z)
	var ans1 = make(SortBy, 0)
	var ans2 = make(SortBy, 0)

	for i := 0; i < X; i++ {
		fmt.Scan(&A[i])
	}
	for i := 0; i < Y; i++ {
		fmt.Scan(&B[i])
	}
	for i := 0; i < Z; i++ {
		fmt.Scan(&C[i])
	}

	sort.Sort(A)
	sort.Sort(B)
	sort.Sort(C)

	for i := 0; i < X; i++ {
		for j := 0; j < Y; j++ {
			ans1 = append(ans1, A[i]+B[j])
		}
	}
	sort.Sort(ans1)
	for i := 0; i < min(len(ans1), K); i++ {
		for j := 0; j < Z; j++ {
			ans2 = append(ans2, ans1[i]+C[j])
		}
	}
	sort.Sort(ans2)
	for i := 0; i < K; i++ {
		fmt.Println(ans2[i])
	}
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) > abs(a[j]) }


Measured memory_bytes: 93312
#include<stdio.h>
int main()
{
  int A[100];
  int i,j;
  int temp=0;
  int hant_num=0;
  int num,mini;

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

  for (i=0;i<num;i++)
    {
      mini = i;
      for (j=i;j<num;j++)
	{
	  if (A[j] < A[mini]) mini = j;
	}
      if (A[i] > A[mini])
	{
	  temp = A[i];
	  A[i] = A[mini];
	  A[mini] = temp;
	  hant_num++;
	}
    }
  for (i=0;i<num;i++)
    {
      printf("%d",A[i]);
      if (i<num-1) printf(" ");
    }
  printf("\n%d\n",hant_num);
  return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> col(H, vector<char>(W));
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      cin >> col.at(i).at(j);
  
  for (int i = 0; i < H; i++) {
    int del = 1;
    for (int j = 0; j < W; j++)
      if(col.at(i).at(j) == '#')
        del = 0;
    if(del)
      for (int j = 0; j < W; j++)
        col.at(i).at(j) = 'l';
  }
  
  for (int j = 0; j < W; j++) {
    int del = 1;
    for (int i = 0; i < H; i++)
      if(col.at(i).at(j) == '#')
        del = 0;
    if(del)
      for (int i = 0; i < H; i++)
        if(col.at(i).at(j) == '.')
          col.at(i).at(j) = 'x';
  }
  
  for (int i = 0; i < H; i++) {
    if(col.at(i).at(0) == 'l') continue;
    for (int j = 0; j < W; j++) {
      if(col.at(i).at(j) == '.' || col.at(i).at(j) == '#')
        cout << col.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int K = sc.nextInt();
        String Slist[] = S.split("");
        
        String change = Slist[K-1];
        
        for(int i=0;i<S.length();i++){
            
            if(!(Slist[i].equals(change))){
                Slist[i]="*";
            }
        }
        
        for(int i=0;i<S.length();i++){
            System.out.print(Slist[i]);
        }
        
        System.out.println("");
        
    }
}


Measured memory_bytes: 35724
n,m=map(int, input().split()) 
s=[list(map(int, input().split())) for i in range(m)]
R=0
L=0
s=sorted(s)
L=s[m-1][0]
s=sorted(s, key=lambda x:x[1])
R=s[0][1]
if R-L>=0:
    print(R-L+1)
else:
    print(0)

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

static const int INFTY = (1<<29);
int M[100][100];
int d[100];
int n;

void dfs(int s){
    int u;
    queue<int> q;

    q.push(s);
    for(int i=0;i<n;i++) d[i]=INFTY;
    d[s]=0;

    while( !q.empty() ){
	u=q.front(); q.pop();
	for(int v=0;v<n;v++){
	    if(M[u][v]==0) continue;
	    if(d[v]!=INFTY) continue;
	    d[v]=d[u]+1;
	    q.push(v);
	}
    }

    for(int i=0;i<n;i++){
	cout << i+1 << " " << ((d[i]==INFTY) ? (-1):d[i]) << endl;
    }
    
}

int main(void){
    int u,k,v;

    cin >> n;
 
    for(int i=0;i<n;i++){
	cin >> u >> k;
	u--;
	for(int j=0;j<k;j++){
	    cin >> v;
	    v--;	
	    M[u][v]=1;
	}
    }

    dfs(0);

    return 0;
}

Measured memory_bytes: 3096
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

const int size = 100010;

int main() {
  int n;
  cin >> n;
  vector<int> t(size), x(size), y(size);
  t[0] = 0, x[0] = 0, y[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  
  for (int i = 0; i < n; i++) {
    int dt = t[i+1] - t[i];
    int dis = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    int a = (x[i] + y[i]), b = (x[i+1] + y[i+1]);
    if (dis <= dt && (a+dt) % 2 == b % 2) {
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

#define int long long int

const int mod = 1e9+7;

#undef int
int main()
{
#define int long long int
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int a, b, c;
	cin>>a>>b>>c;
	if((a == b && b != c) || (a == c && c != b) || (b == c && c != a))
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int H, A;
  while (cin >> H >> A) {
    cout << (H + A - 1) / A << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int a[] ={0,1,2,1,4,1,4,1,1,4,1,4,1};
  int x,y;
  cin >> x >> y;
  cout << (a[x]==a[y]?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 5;
struct Node {
    int id, num;
}node[maxn];
bool cmp(Node &a, Node &b) {
    return a.num < b.num;
}
//hh
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d", &node[i].num), node[i].id = i + 1;
    sort(node, node + n, cmp);
    for (int i = 0; i < n ; i++)
        printf("%d ", node[i].id);
    return 0;
}

Measured memory_bytes: 1536
def BubbleSort(A,N):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for i in range(N-1,0,-1):
            if A[i] < A[i-1]:
                tmp = A[i]
                A[i] = A[i- 1]
                A[i-1] = tmp
                flag = 1
                count = count +1
    print(' '.join(map(str,A)))
    print(count)
             
N = int(input())
A = list(map(int,input().split()))
BubbleSort(A,N)


Measured memory_bytes: 5596
#include <string>
#include <time.h>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <utility>
#include <iostream>
#include <cmath>
#include <deque>

#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

typedef long long ll;
using namespace std;
#define MAXN 228228
#define MOD 1000000007
ll x, y, n, m, k;
ll a[MAXN];
vector<ll> f, g;
string s;
int main() {
    cin >> n;
    cin >> s;
    for (int i = 0; i < 2*n; i++) {
        ll x = 1;
        if (s[i] == 'B') {
            x = 0;
        }
        if (i % 2 == 1) {
            x ^= 1;
        }
        a[i] = x;
    }
    ll x = 0;
    ll ans = 1;
    for (int i = 0; i < 2 * n; i++) {
        if (a[i] == 0) {
            x++;
        } else {
            if (x == 0) {
                cout << 0 << endl;
                return 0;
            }
            ans = ans * x % MOD;
            x--;
        }
    }
    if (x != 0) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        ans = ans * i % MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2180
#include <stdio.h>

int main (void) {
  int H, W, i, j;
  H = 1; W = 1;
  while (H != 0 || W != 0){
    scanf("%d %d", &H, &W);
    if(H == 0 && W == 0) return 0;
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
	if ((i + j) % 2 == 0 )printf("#");
	else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
}


Measured memory_bytes: 2108
#include <iostream>
#include <vector>

using namespace std;  

typedef long long ll;

bool judge(ll k, int n, int a, int b, vector<int> h) {
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    ll t = h[i] - k*b;
    if (t > 0) {
      sum += (t+a-b-1) / (a-b);
      if (sum > k) { return false; }
    }
  }
  return true;
}

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

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

  vector<int> h(n);

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

  ll low = 0, high = (ll)1e9+9;

  while (low < high) {
    ll mid = (low + high) / 2;
    if (judge(mid, n, a, b, h)) {
      high = mid;
    } else {
      low = mid+1;
    }
  }

  cout << low << endl;

  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long[] capacities = new long[] { sc.nextLong(), sc.nextLong(), sc.nextLong(), sc.nextLong(), sc.nextLong() };
		sc.close();

		long min = capacities[0];
		for (int i = 0; i < 5; i++) {
			min = Math.min(min, capacities[i]);
		}

		long cnt = (long) Math.ceil(N * 1.0 / min);
		System.out.println(4l + cnt);
	}
}


Measured memory_bytes: 35688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    REP(i, N)
    {
        int r = 0;
        int n = i + 1;
        REP(j, 5)
        {
            r += n % 10;
            n = n / 10;
        }
        if (A <= r && r <= B)
        {
            ans += i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    long long k;
    cin >> n >> k;
    
    vector<int> A(n);
    for (int i = 0; i < n; i++){
        cin >> A.at(i);
    }

    long long kk;
    if(k%2==0){
        kk=((k/2)*(k-1))%(7+(long long)1e9);
    }
    else{
        kk=(k*((k-1)/2))%(7+(long long)1e9);
    }

    long long ans1=0;
    long long ans2=0;
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            if(A[i]>A[j]){
                ans1=(ans1+k)%(7+(long long)1e9);
            }
        }
        for (int j = 0; j < n; j++){
            if(A[i]>A[j]){
                ans2=(ans2+kk)%(7+(long long)1e9);
            }
        }
    }
    
    cout << (ans1+ans2)%(7+(long long)1e9) << endl;
}



Measured memory_bytes: 3564
#include<iostream>
#include<stdio.h>
#include<algorithm>
#define ios ios::sync_with_stdio(false)
using namespace std;
int main()
{
	ios;
	int n;
	long long sum=0;
	cin>>n;
	for(int i=1;i<n;i++){
		sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dis[205][205];
int tot=0x3f3f3f3f,vis[205];
int n,m,r,Start;
int R[12];
int x,y,z;

void floyd(){
	for (int k = 1; k <= n; k++) {
            for (int i = 1; i <= n; i++) {
                if (i == k) continue;
                for (int j = 1; j <= n; j++) {
                    if (i == j || k == j) continue;
                    dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
                }
            }
        }
        
}

void dfs(int last,int x,int num){
	if(x>r){
		tot = min(tot,num);
		return;
	}
	for(int i=1;i<=r;i++){
		if(!vis[R[i]]){
			vis[R[i]]=1;
			dfs(R[i],x+1,num+dis[last][R[i]]);
			vis[R[i]]=0;
		}
	}
}

int main(){
	memset(dis,0x3f3f3f3f,sizeof(dis));
	scanf("%d%d%d",&n,&m,&r);
	for(int i=1;i<=r;i++) scanf("%d",&R[i]);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&x,&y,&z);
		dis[x][y]=z;
		dis[y][x]=z;
	}
	floyd();
	for(int i=1;i<=r;i++){
		vis[R[i]]=1;
		dfs(R[i],2,0);
		vis[R[i]]=0;
	}
	printf("%d\n",tot);
	return 0;
}
        
        

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

int main() {
    int n, sum=0;
    cin >> n;
    int nums[n];
    for (int i=0; i<n; i++) {
        cin >> nums[i];
        sum += nums[i];
    }
    for (int i=0; i<n; i++) {
        if (nums[i]*2 >= sum) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define SZ(x)        ((int)(x).size())
#define READ(x)      freopen(x,"r",stdin)
#define WRITE(x)     freopen(x,"w",stdout)
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
typedef vector<int> VI;
const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

struct node {
    ll u;
    ll cost;
    node(ll _u, ll _cost) {
        u = _u;
        cost = _cost;
    }
    bool operator < ( const node& p ) const {
        return cost > p.cost;      //Operator overloading
    }

};

ll dis[15];
vector<ll>g[15],cost[15];

void dijstkra(ll n,ll source) {

    for(ll i=0; i<=n; i++) {
        dis[i] = INF;
    }

    priority_queue<node>q;
    q.push(node(source,0));
    dis[source] = 0;

    while(!q.empty()) {
        node top = q.top();
        q.pop();
        ll u=top.u;

        for(ll i=0; i<(ll)g[u].size(); i++) {
            ll v=g[u][i];

            //Relaxation
            if(dis[u] + cost[u][i] < dis[v]) {
                dis[v] = dis[u] + cost[u][i];
                q.push(node(v, dis[v]));
            }
        }
    }
}

int main() {

    Fast_Input

    ll h,m; cin>>h>>m;

    ll a;


    for(ll i=0; i<10; i++){
        for(ll j=0; j<10; j++){
            cin>>a;
            g[j].push_back(i);
            cost[j].push_back(a);
        }
    }

    map <ll,ll> Map;
    map <ll,ll> ::iterator it;

    for(ll i=0; i<h; i++){
        for(ll j=0; j<m; j++){
            cin>>a;
            if(a>-1 && a!=1) Map[a]++;
        }
    }
    dijstkra(9,1);
    ll ans=0;
    for(it=Map.begin(); it!=Map.end(); it++){
        ans+= (it->se * dis[it->fi]);
       // cout<<it->fi<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
if int(input()) in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 42, 45, 48, 49, 54, 56, 63, 64, 72, 81):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9124
#include <iostream>
#include <vector>
using std::vector;
using std::cout;
using std::cin;
using std::endl;

int main(void){
    int n;
    int prev = -1;
    int sum = 0;
    vector<int> a;
    vector<int> b;
    vector<int> c;

    cin >> n;
    int tmp;
    for (int i = 0; i < n; i++){
        cin >> tmp;
        a.push_back(tmp);
    }

    for (int i = 0; i < n; i++){
        cin >> tmp;
        b.push_back(tmp);
    }
    
    c.push_back(0);
    for (int i = 0; i < n-1; i++){
        cin >> tmp;
        c.push_back(tmp);
    }

    for (int i = 0; i < n; i++){
        sum += b[a[i] - 1];
        if (prev == a[i] - 2){
            sum += c[a[i] - 1];
        }
        prev = a[i] - 1;
    }

    cout << sum << endl;
    return 0;
}

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

int main() {
	char tile[100][100];
	bool flag[100][100];
	int h, w, x, y;

	while (cin >> h >> w, h || w) {
		memset(tile, 0, sizeof(tile));
		memset(flag, 0, sizeof(flag));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> tile[i][j];
			}
			getchar();
		}
		x = 0; y = 0;
		while (1) {
			if (flag[y][x])
				break;
			else
				flag[y][x] = 1;

			switch (tile[y][x]) {
			case '>':
				x++;
				break;
			case '<':
				x--;
				break;
			case '^':
				y--;
				break;
			case 'v':
				y++;
				break;
			}
		}
		if (tile[y][x] == '.')
			cout << x << ' ' << y << endl;
		else
			cout << "LOOP" << endl;
	}
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll A[200005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> A[i].first >> A[i].second;
    }
    sort(A, A + N, [](pll a, pll b) { return a.second < b.second; });
    ll t = 0;
    bool f = true;
    REP(i, N)
    {
        t += A[i].first;
        if (A[i].second < t)
            f = false;
    }
    if (f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

int X, N;
int p[110];

int main() {
    cin >> X >> N;
    for (int i = 0; i < N; i++) cin >> p[i];
    
    bool is_exist[101];
    memset(is_exist, false, sizeof(is_exist));

    for (int i = 0; i < N; i++) {
        is_exist[p[i]] = true;
    }

    int ans, diff;
    if (X > 50) {
        ans = 101; 
        diff = abs(101 - X);
    }
    else {
        ans = 0; 
        diff = abs(X);
    }

    for (int i = 100; i >= 0; i--) {
        if (!is_exist[i]) {
            if (diff >= abs(i - X)) {
                ans = i;
                diff = abs(i - X);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
n, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
v = [0 for _ in range(n -1)]
for i in range(n - 1):
    v[i] = t[i + 1] - t[i] - 1
v.sort(reverse = True)
print(t[-1] - t[0] + 1 - sum(v[:(k - 1)]))


Measured memory_bytes: 14064
#include<bits/stdc++.h>
#define ll long long int
#define vll vector<ll>
#define uset unordered_set<ll>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, a;
    cin >> n;
    uset x;
    
    for(ll i=0; i<n; i++){
        cin >> a;
        x.insert(a);
    }
    
    if(x.size() != n){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 11404
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    vec<vec<int>> D(N, vec<int>(2));
    rep(i, N) rep(j, 2) cin >> D[i][j];

    for(int i=2;i<N;++i){
        bool c1 = D[i][0] == D[i][1];
        bool c2 = D[i-1][0] == D[i-1][1];
        bool c3 = D[i-2][0] == D[i-2][1];

        if(c1&&c2&&c3){
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';

}


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

int main(){
	int n, total=0;
	cin >> n;
	
	for (int i=1; i<=n; i++){
		int s=0;
		if (i%2==1){
			for (int j=1; j<=int(sqrt(i)); j++){
				if (i%j==0) s+=2;
			}
			if ( sqrt(i)==int(sqrt(i)) )  s--;
			if (s==8) total++;
		}
	}
	
	cout << total;
	return 0;
}

Measured memory_bytes: 256
import math


def ok(y: list, z: list, D: int)->bool:
    d = 0
    for i in range(D):
        d += (y[i]-z[i]) ** 2

    s = int(math.sqrt(d))

    return s * s == d


def good_distance(N: int, D: int, X: list)->int:
    count = 0

    for i in range(N):
        y = X[i]
        for j in range(i+1, N):
            z = X[j]

            count += ok(y, z, D)

    return count


if __name__ == "__main__":
    N, D = map(int, input().split())
    X = [[int(s) for s in input().split()] for _ in range(N)]
    ans = good_distance(N, D, X)

    print(ans)


Measured memory_bytes: 3064
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n);

    ll ans = 0;
    ll rest = 0;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0){
            rest = 0;
            continue;
        }
        if(rest == 1){
            a[i]++;
            rest = 0;
        }
        if(a[i] % 2 == 0){
            ans += a[i] / 2;
        } else {
            ans += a[i] / 2;
            rest = 1;
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[110000];
int q[110000];
pair<int,int>s[110000];
int R[110000];
int v[110000];
int main()
{
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)
	{
		scanf("%d%d",p+i,q+i);
		p[i]--;
		s[i]=make_pair(-q[i],p[i]);
	}
	std::sort(s,s+a);
	priority_queue<int>Q;
	int sz=0;
	long long cur=0;
	for(int i=0;i<a;i++)
	{
		if(sz==b||v[s[i].second])
		{
			Q.push(-s[i].first);
		}
		else
		{
			v[s[i].second]=1;
			R[sz]=-s[i].first;
			sz++;
			cur-=s[i].first;
		}
	}
	long long ret=0;
	int req=b-sz;
 
	for(int i=sz;i>=1;i--)
	{
		while(req)
		{
			req--;
			cur+=Q.top();
			Q.pop();
		}
		ret=max(ret,(long long)i*i+cur);
		cur-=R[i-1];
		req++;
	}
	printf("%lld\n",ret);
	return 0;
}

Measured memory_bytes: 2940
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b,c;

  cin >> a >> b >> c;

  if(b - a ==  c - b  ) cout << "YES" << endl;
  else cout << "NO";


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
n = int(input())
cnt = 1

bl = [False] * (10**6 + 1)
bl[n] = True

while 1:
    cnt += 1
    if n % 2 == 0:
        next = n // 2
    else:
        next = 3 * n + 1
    if bl[next]:
        break
    n = next
    bl[n] = 1

print(cnt)


Measured memory_bytes: 10868
// mizuyokan
// JOI 2017/2018 yosen Q4
// YAMADA Terushige  2018.8.18.

#include<iostream>
using namespace std;
#define NMAX 51
#define INF (1<<30)

int N;
int TL[NMAX];// 左端から切れ目までの長さ

// 最小のピース長 lmin に対する適切な最大のピース長を動的計画法で求める
int lmax(int lmin){
  //  cout << "lmin = " << lmin << endl;
  int dp[NMAX];// i 番目の切れ目まで考えるときの適切な最大のピース長
  dp[0]=0;

  for(int i=1;i<=N;i++){ // ピースの右端
    //    cout << "i = " << i << endl;
    dp[i]=INF;
    for(int j=0;j<i;j++){ // ピースの左端
      if(i==N && j==0) continue;// 最低でも1箇所はカットする
      //      cout << "(" << j << "," << i << ") "; 
      int lpiece=TL[i]-TL[j]; // ピースの長さ
      //      cout << "lpiece = " << lpiece << endl;
      if(lpiece >= lmin)
	dp[i]=min( max(lpiece,dp[j]) ,dp[i]);
      //      cout << " dp[" << i << "] = " << dp[i];
    }
    //    cout << endl;
  }
  return dp[N];
}

int main(){
  cin >> N;
  TL[0]=0;
  for(int i=1;i<=N;i++){
    int l;
    cin >> l;
    TL[i]=TL[i-1]+l; // 左端から切れ目までの長さ
  }

  int ans=INF;
  for(int i=0;i<N;i++){// left of minimum piece
    for(int j=i+1;j<=N;j++){// right of minimum piece
      if(i==0 && j==N) continue;
      int lmin=TL[j]-TL[i];// length of minimum piece
      ans = min( lmax(lmin)-lmin ,ans);
      //      cout << "ans = " << ans << endl;
    }
  }
  cout << ans << endl;
}



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

int main() {
  
  string nine;
  
  cin >> nine;
  
  if(nine[0]=='9') {
    
    cout << "Yes" << endl;
    
  } else if(nine[1]=='9') {
    
    cout << "Yes" << endl;
    
  } else if((nine[0] && nine[1]) == '9') {
    
    cout << "Yes" << endl;
    
  } else {
    
    cout << "No" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
class BIT:
    def __init__(self, n, MOD):
        self.n = n
        self.data = [0] * (n + 1)
        self.MOD = MOD

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            s %= self.MOD
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            self.data[i] %= self.MOD
            i += i & -i


n, k = map(int, input().split())
mod = 998244353
bit = BIT(n + 2, mod)
ranges = []
for _ in range(k):
    l, r = map(int, input().split())
    ranges.append((l, r))

bit.add(1, 1)

for i in range(1, n):
    v = bit.sum(i)
    for l, r in ranges:
        bit.add(i + l, v)
        bit.add(min(n + 1, i + r + 1), -v)
print((bit.sum(n) - bit.sum(n - 1)) % mod)


Measured memory_bytes: 78724
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[130][130];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

void dfs(int y,int x){
	a[y][x]=0;
	for(int i=0;i<4;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx>=0 && nx<n && ny>=0 && ny<n){
			if(a[ny][nx]==1){
				dfs(ny,nx);
			}
		}
	}
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		string str;
		cin >> str;
		for(int j=0;j<n;j++){
			if(str[j]=='o')a[i][j]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i][j]==1){
				cnt++;
				dfs(i,j);
			}
		}
	}
	printf("%d\n",cnt/3);
	return 0;
}

Measured memory_bytes: 3336