akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
//int count =0;
//int count2 =0;
Node treeMinimum(Node x){
   while (x->left != NIL){
    x = x->left;
}
return x;
}



Node IterativetreeSearch(Node u, int k){

  if(u == NIL || k == u -> key) return u;
  if(k < u -> key) return IterativetreeSearch(u -> left, k);
  else return IterativetreeSearch(u -> right, k);

}



/*Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;

  if(k < u->key) 
  return treeSearch(u->left,k);
  
  else return treeSearch(u->right,k);
  
  }*/

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
      }
  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right; 
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  }
  else if (z->key < y->key){
    y->left = z;
  }
  
  else y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" ");
    printf("%d",u->key);
    inorder(u->right);
  }
 
}




void preorder(Node u){
  
  
    if (u != NIL) {
      printf(" ");
      printf("%d",u->key); 
      preorder(u->left);
      preorder(u->right);
    
 
    
    }
}

int main(){
  int n, i, x;
    //int num[500000];
  char com[20];
  scanf("%d", &n);
  //for ( i = 0; i < n; i++ ){num[i] = 0;}//???
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = IterativetreeSearch(root, x);
      if ( t != NIL ){ 
	printf("yes\n");
      }
      else {
	printf("no\n");
      }
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    
    
    else if ( com[0] == 'p' ){
      
      /*for(j=0;j<n;j++){
	  if(num[j]==1)printf("yes\n");
	  else if(num[j]==2)printf("no\n");
	  else printf("");
	  }  */
	  
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	  //count = 0;
	
       
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(IterativetreeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19360
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws Exception {
try {
	BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
	String input = buf.readLine();
	
	String[] strAry = input.split(" ");
    int a = Integer.parseInt(strAry[0]);
    int b = Integer.parseInt(strAry[1]);

    int d = a/b;
    int r = a%b;
    double f = 1.0 *  a/b;
    
    System.out.printf("%d %d %.5f\n", d, r, f);

} catch (Exception e) {
	// TODO: handle exception
}
		 }
    }

Measured memory_bytes: 24868
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl

using namespace std;


int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		vector<int> ans = vector<int>(n,0);
		rep(i,n){
			cin >> ans[i];
		}
		
		sort(ans.begin(),ans.end());
		
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=ans[i];
		}
	
		cout << sum/(n-2) << endl;

	}


	return 0;
}

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

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

vector<int> compress (vector<int> a) {
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    return a;
}

int main() {
    int n, m;
    cin >> n >> m;
    // key : 座圧前, value : 座圧後
    map<int, int> datx, daty;
    datx[0] = 0; daty[0] = 0;

    vector<int> a(n), b(n), c(n), d(m), e(m), f(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
        datx[a[i]] = 0;
        datx[b[i]] = 0;
        daty[c[i]] = 0;
    }
    for (int i = 0; i < m; i++) {
        cin >> d[i] >> e[i] >> f[i];
        datx[d[i]] = 0;
        daty[e[i]] = 0;
        daty[f[i]] = 0;
    }

    // index : 座圧後, value : 座圧前
    vector<int> cx, cy;
    for (auto &e : datx) {
        e.second = cx.size();
        cx.push_back(e.first);
    }
    for (auto &e : daty) {
        e.second = cy.size();
        cy.push_back(e.first);
    }

    const int h = cx.size() * 2;
    const int w = cy.size() * 2;
    // 0 : 未到達, 1 : 到達済み, 2 : 壁
    vector<vector<int>> g(h, vector<int>(w, 0));
    for (int i = 0; i < n; i++) {
        int y = daty[c[i]] * 2;
        int from = datx[a[i]] * 2, to = datx[b[i]] * 2;
        for (int x = from; x <= to; x++) g[x][y] = 2;
    }
    for (int i = 0; i < m; i++) {
        int x = datx[d[i]] * 2;
        int from = daty[e[i]] * 2, to = daty[f[i]] * 2;
        for (int y = from; y <= to; y++) g[x][y] = 2;
    }

    queue<pair<int, int>> que;
    que.emplace(datx[0] * 2, daty[0] * 2);
    while (not que.empty()) {
        auto [x, y] = que.front(); que.pop();
        if (g[x][y] != 0) continue;
        g[x][y] = 1;
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 or h <= nx or ny < 0 or w <= ny) continue;
            if (g[nx][ny] != 0) continue;
            que.emplace(nx, ny);
        }
    }

    long long ans = 0;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        if (g[i][j] != 1) continue;
        if (i == 0 or i + 1 == h or j == 0 or j + 1 == w) {
            cout << "INF" << '\n';
            return 0;
        }
        if (i % 2 == 0 or j % 2 == 0) continue;
        long long x = cx[i / 2 + 1] - cx[i / 2];
        long long y = cy[j / 2 + 1] - cy[j / 2];
        ans += x * y;
    }
    
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 144488
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int N;
int A, B;
int ans = 0;

int main(){
    cin >> N;
    if(N==1){
        cout << "Hello World"<<endl;
        return 0;
    }else if(N==2){
        cin >> A >> B;
        cout << A+B << endl;
        return 0;
    }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
const int _ = 303;
int n,m,P,f[_][_][_]={0};
int main()
{
	std::cin>>n>>m>>P;
	f[0][1][0]=1;
	for(int i=0;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=i;k>=0;k--)
			{
				if(k)f[i][j][k-1]=(f[i][j][k-1]+f[i][j][k])%P;
				else f[i][j+1][i]=(f[i][j+1][i]+f[i][j][k])%P;
				f[i+1][j][k]=(f[i+1][j][k]+1ll*f[i][j][k]*(k+1)%P)%P;
			}
	std::cout<<f[n][m][0];
	return 0;
}


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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

template<typename T>
struct Segtree {
    int n, n_org;
    T e;
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(){}
    Segtree(int n_input, Func f_input, T e_input){
        initialize(n_input, f_input, e_input);
    }
    void initialize(int n_input, Func f_input, T e_input){
        n_org = n_input;
        f = f_input;
        e = e_input;
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
    }

    void build(vector<T>& A){
        for(int k=0; k<int(A.size()); k++) dat[k+n-1] = A[k];
        for(int k=n-2; k>=0; k--) dat[k] = f(dat[2*k+1], dat[2*k+2]);
    }

    void update(int k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get(int k){
        return dat[k+n-1];
    }

    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }

    // [S, t] が条件checkを満たす最大のtを求める
    int bisect(int S, function<bool(T a)> check){
        T val = get(S);
        int k = S+n-1, l = S, r = S+1;
        while(true){
            while(k%2) k = (k-1)/2, r += r-l;
            T val2 = f(val, dat[k]);
            if(check(val2)){
                if(r == n) return n_org-1;
                val = val2;
                k++;
                int d = r-l;
                l += d, r += d;
            }else{
                break;
            }
        }
        while(k<n-1){
            T val2 = f(val, dat[2*k+1]);
            if(check(val2)){
                val = val2;
                k = 2*k+2;
                l = (l+r)/2;
            }else{
                k = 2*k+1;
                r = (l+r)/2;
            }
        }
        return min(l, n_org)-1;
    }
};


int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> XD(N);
    for(int i=0; i<N; i++){
        int x, d;
        cin >> x >> d;
        XD[i] = {x, d};
    }
    sort(XD.begin(), XD.end());
    vector<int> num = {1};
    for(int i=1; i<N; i++){
        if(XD[i-1].first + XD[i-1].second > XD[i].first){
            num.back()++;
        }else{
            num.push_back(1);
        }
    }
    Segtree<int> st(N, [](int a, int b){ return max(a, b); }, 0);

    for(int i=N-1; i>=0; i--){
        st.update(i, i+1);
        int x2 = XD[i].first + XD[i].second;
        int pt = lower_bound(XD.begin(), XD.end(), make_pair(x2, -1)) - XD.begin();
        st.update(i, st.between(i, pt-1));
    }

    vector<int64_t> dp(N+1);
    dp[0] = 1;
    for(int i=0; i<N; i++){
        add(dp[i+1], dp[i]);
        int to = st.get(i);
        add(dp[to], dp[i]);
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 6008
#include <iostream>

using namespace std;

int checkYoko( char stage[4][4], int i )
{
	if( stage[i][0] == stage[i][1] && stage[i][1] == stage[i][2] ) {
		if( stage[i][0] == 'b' ) return 1;
		else if( stage[i][0] == 'w' ) return 2;
		else return 0;
	}

	return 0;
}

int checkTate( char stage[4][4], int i )
{
	if( stage[0][i] == stage[1][i] && stage[1][i] == stage[2][i] ) {
		if( stage[0][i] == 'b' ) return 1;
		else if( stage[0][i] == 'w' ) return 2;
		else return 0;
	}

	return 0;
}


int main(int argc, char const* argv[])
{
	char stage[4][4];

	while( cin >> stage[0] && stage[0][0] != '0' ){
		for( int i = 1;i < 3;i++ ) cin >> stage[i];

		int i;
		for( i = 0;i < 3;i++ ) {
			int answer = checkYoko( stage, i );
			
			if( answer == 0 ) {
				answer = checkTate( stage, i );
			}

			if( answer == 1 ){
				cout << 'b' << endl;
				break;
			} else if( answer == 2 ){
				cout << 'w' << endl;
				break;
			} else {
				if( stage[0][0] == stage[1][1] && stage[1][1] == stage[2][2] && stage[0][0] != '+' || stage[2][0] == stage[1][1] && stage[1][1] == stage[0][2] && stage[1][1] != '+' ) {
					cout << stage[1][1] << endl;
					break;
				}
			}
		}
		if( i == 3 ) cout << "NA" << endl;
	}

	return 0;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

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

    ll h,w;
    cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }

    ll ans = h*w % 2 == 0 ? h * w /2 : h * w / 2 + 1;

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(x==a && x==b){
		cout<<"delicious"<<endl;
	}
	else if(x>=a-b && a-b>=0){
		cout<<"delicious"<<endl;
	}
	else if(x>=b-a && b-a>=0){
		cout<<"safe"<<endl;
	}
	
	if(x<b-a){
		cout<<"dangerous"<<endl;
	}

return 0;
}

Measured memory_bytes: 256
from itertools import*;a,b,c,d=map(int,input().split());D=[[0]*6011for _ in[0]*6011];D[a][b]=1
for i,j in product(range(c+d),repeat=2):
 D[i+1][j+1]+=(D[i+1][j]*(i+1)+D[i][j+1]*(j+1)-D[i][j]*i*j)%998244353
print(D[c][d])

Measured memory_bytes: 357468
n, x = map(int, input().split())
a = [int(m) for m in input().split()]

a.sort()
t = 0
ans = 0
for i in range(n):
    t += a[i]
    if t > x:
        print(ans)
        exit()
    else:
        ans += 1
if t == x:
    print(ans)
else:
    print(ans - 1)

Measured memory_bytes: 3064
primes = [0, 0] + [1]*999999
for i in range(2, 1001):
    if primes[i]:
        for j in range(i*i, 1000001, i):
            primes[j] = 0

while True:
    try:
        n = int(input()) + 1
        print(sum([1 for i in range(n) if primes[i]]))
    except:
        break

Measured memory_bytes: 23000
N, M = map(int,input().split())
PY = []
for i in range(M):
  PY.append(list(map(int,input().split())))

cnt = [1]*(N+1)
for j in sorted(PY, key=lambda x: x[1]):
  j.append("{:06d}{:06d}".format(j[0], cnt[j[0]]))
  cnt[j[0]] += 1

for k in PY:
  print(k[2])

Measured memory_bytes: 36016
#include<cstdio>
#include <iostream>
#include <cmath>
using namespace std;
	char c;
	bool v[28];
int main()
{c=getchar();
	while ((c>='a'&&c<='z'))
		{if (c<='z'&&c>='a')v[c-'a']=1;c=getchar();}
	for (int i=0;i<26;i++)
	if (!v[i]){printf("%c",(char)i+'a');return 0;}
	printf("None");
} 

Measured memory_bytes: 256
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)));
        long N = scan.nextLong();
        long M = scan.nextLong();
        long answer = 0;
        if (M < N * 2) {
            answer = M / 2;
        } else {
            long all = N * 2 + M;
            answer = all / 4;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
N = int(input())
ASC = 97

def dfs(s, mx):
    if len(s) == N:
        print(s)
        return
    for c in range(ASC, mx+2):
        t = s + chr(c)
        dfs(t, max(mx, c))
    
s = 'a'
mx = ord(s)
dfs(s, mx)


Measured memory_bytes: 4412
package main

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

func main() {
	N := ReadInt()
	S := make([]string, N)
	P := make([]int, N)
	names := make([]string, 0)
	nameToIndices := make(map[string][]int)
	for i := 0; i < N; i++ {
		S[i], P[i] = ReadString(), ReadInt()
		if _, exists := nameToIndices[S[i]]; !exists {
			names = append(names, S[i])
		}
		nameToIndices[S[i]] = append(nameToIndices[S[i]], i)
	}
	sort.Strings(names)
	for _, name := range names {
		indices := nameToIndices[name]
		sort.Slice(indices, func(i, j int) bool {
			return P[indices[i]] > P[indices[j]]
		})
		for _, index := range indices {
			fmt.Println(index + 1)
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 1868
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    while(N != 0){
        vector<int> H,W;
        H.push_back(0);
        W.push_back(0);
        map<int,int> mp_H,mp_W;
        for(int i=1; i<=N; i++){
            int a;
            cin >> a;
            a += H.back();
            for(int j=0; j<i; j++){
                mp_H[a-H[j]]++;
            }
            H.push_back(a);
        }
        for(int i=1; i<=M; i++){
            int a;
            cin >> a;
            a += W.back();
            for(int j=0; j<i; j++){
                mp_W[a-W[j]]++;
            }
            W.push_back(a);
        }
        ll ans = 0;
        for(auto m : mp_H){
            ans += m.second * mp_W[m.first];
        }
        cout << ans << enld;
        cin >> N >> M;
    }
    return 0;
}



Measured memory_bytes: 34224
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int h, w; cin >> h >> w;
    queue<pair<int, int> > q;
    vector<vector<int> > g(h, vector<int> (w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char in; cin >> in;
            if(in == '#'){
                g[i][j] = 1;
                q.push({i, j});
            }else g[i][j] = 0;
        }
    }
    
    int di[4] = {0, 1, 0, -1};
    int dj[4] = {1, 0, -1, 0};
    int cnt = 0;
    while(1){
        vector<pair<int, int> > nxt;
        if(q.empty()){
            cout << cnt - 1 << endl;
            return 0;
        }

        while(!q.empty()){
            int i = q.front().first;
            int j = q.front().second;
            q.pop();

            for(int l = 0; l < 4; l++){
                int ni = i + di[l];
                int nj = j + dj[l];
                if(ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
                if(g[ni][nj] == 1) continue;

                g[ni][nj] = 1;
                nxt.push_back({ni, nj});
            }
        }

        for(int i = 0; i < (int)nxt.size(); i++) q.push(nxt[i]);
        cnt++;
    }
    return 0;
}



Measured memory_bytes: 27660
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String s1 = s.substring(2, 3);
        String s2 = s.substring(3, 4);
        String s3 = s.substring(4, 5);
        String s4 = s.substring(5, 6);
        if(s1.equals(s2) && s3.equals(s4)) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int a, b;
	cin >> hex >>a >> hex >> b;
	if (a < b)
	{
		cout << "<";
	}
	else if (a > b)
	{
		cout << ">";
	}
	else
	{
		cout << "=";
	}
	cout << endl;

}

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


int main()
{
	
	int i=0,p=0,t=0,flag=0,count=0;
	
	scanf("%d", &p);
	int *bubblesort = (int*)malloc(sizeof(int)*p);

	for (i = 0; i < p; i++)
	{
		scanf("%d", &bubblesort[i]);
	}
	
	
	
	flag = 1;
	while(flag)
	{
		flag = 0;
		for(i=p-1;i>0;i--)
		{
			if(bubblesort[i] < bubblesort[i-1])
			{
				 t = bubblesort[i];
				 bubblesort[i] = bubblesort[i-1];
				 bubblesort[i-1] = t;
				 count++;
				 flag = 1;
			}
		}
	}
	
	
	for(i=0;i<p;i++)
	{
		if(i==0){
			printf("%d",bubblesort[i]);
		}
		else{
			printf(" %d",bubblesort[i]);
		}
	}
	
	printf("\n");
	printf("%d\n",count);
	
	return 0;
	
	
}

Measured memory_bytes: 604
H,W,K = map(int,input().split())
K -= 1
MOD = 10**9+7

dp = [[0]*W for i in range(H+1)]
dp[0][0] = 1

for i in range(H):
    for b in range(2**(W-1)):
        if '11' in bin(b): continue
        b *= 2
        for j in range(W):
            if b&(1<<j):
                dp[i+1][j-1] += dp[i][j]
                dp[i+1][j-1] %= MOD
            elif b&(1<<(j+1)):
                dp[i+1][j+1] += dp[i][j]
                dp[i+1][j+1] %= MOD
            else:
                dp[i+1][j] += dp[i][j]
                dp[i+1][j] %= MOD
print(dp[-1][K])


Measured memory_bytes: 3064
while true do
    h,w=gets.chomp.split(" ").map(&:to_i)
    break if h == 0 && w == 0
    (1..h).each do |i|
        if i == 1 || i == h
            puts "#" * w
        else
            puts "#" + "." * (w-2) + "#"
        end
    end
    puts
end


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

int main(){
  ll N;cin>>N;
  vector<vector<ll>> data(N);
  for(int i=0;i<N;i++){
    ll a,b;cin>>a>>b;
    data.at(i).push_back(b);data.at(i).push_back(a);
  }
  sort(data.begin(),data.end());
  if(data.at(0).at(0)<data.at(0).at(1)){cout<<"No"<<endl;return 0;}
  for(int i=1;i<N;i++){
    data.at(i).at(1)+=data.at(i-1).at(1);
    if(data.at(i).at(0)<data.at(i).at(1)){
      cout<<"No"<<endl;return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int N;
    bool is_amaring = false;
    cin >> N;
    ll ans = 0;
    REP(i,N) {
        int a;
        cin >> a;
        if(is_amaring) {
            if(a > 0) {
                a--;
                ans++;
            }
            is_amaring = false;
        }
        if(a%2) is_amaring = true;
        ans+=(a/2);
    }
    cout << ans << endl;
}

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

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

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

const int INF = 1001001001;

struct Edge{
	int to, cost;
	Edge(int to, int cost): to(to), cost(cost){}
};

vector<vector<Edge>> g(100005);
vector<int> visited(100005, 0);

void dfs(int u, int c){
	visited[u] = c;
	for (Edge e : g[u]){
		int to = e.to, cost = e.cost;
		if (visited[to] != 0) continue;
		if (cost % 2) dfs(to, -c);
		else dfs(to, c);
	}
}

int main(){
	int n; cin >> n;
	rep(i,n-1){
		int u, v, w; cin >> u >> v >> w;
		u --; v --;
		g[u].emplace_back(v, w);
		g[v].emplace_back(u, w);
	}
	dfs(0,1);
	rep(i, n) {
		cout << (visited[i] == 1 ? 1 : 0) << endl;
	}
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 3010;
const int mod = 998244353;
int a[M];
ll dp[M];
int main(){
    int n, s;
    scanf("%d%d", &n, &s);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        dp[0]++;
        for(int j = s; j >= a[i]; j--) {
            dp[j] += dp[j - a[i]];
            dp[j] %= mod;
        }
        ans = (ans + dp[s]) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <assert.h>
#include <queue>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <functional>
#include <bitset>
using namespace std;
#define ll long long

const int N = 2e5+15;
pair<int,int> in[N];

ll minMaxR(pair<int,int> maxIn,int n) {
    priority_queue<pair<int,int> ,vector<pair<int,int> >,greater<pair<int,int> > > pq;
    ll ret = 4e18;
    const int inf = 2e9;
    pq.push(make_pair(maxIn.first,inf));
    pq.push(make_pair(in[0].second,inf));
    int R = max(in[0].second,maxIn.first);
    int len = maxIn.second - in[0].first;
    for(int i=1;i<n;++i) {
        pq.push(in[i]);
        R = max(R,in[i].first);
    }
    while(true) {
        pair<int,int> v = pq.top();
        if(v.first==inf) {
            break;
        }
        pq.pop();
        ret = min(ret, (ll)(R- v.first)*len);
        R = max(R,v.second);
        pq.push(make_pair(v.second,inf));
    }
    return ret;
}

void solve() {
    int n;
    scanf("%d",&n);
    if(n==1) {
        cout<<0<<endl;
        return;
    }
    int ind = 0,maxi = 0;
    for(int i=0;i<n;++i) {
        scanf("%d %d",&in[i].first,&in[i].second);
        if(in[i].first>in[i].second) {
            swap(in[i].first,in[i].second);
        }
        if(maxi<in[i].second) {
            ind = i;
            maxi = in[i].second;
        }
    }
    pair<int,int> maxIn = in[ind];
    for(int i=ind;i<n-1;++i) {
        in[i] = in[i+1];
    }
    --n;
    sort(in,in+n);
    ll ret = minMaxR(maxIn, n);
    //when min B max R
    int Bmini  = min(in[0].first,maxIn.first), Bmaxi = max(in[0].first,maxIn.first);
    int Rmaxi = maxIn.second,Rmini = in[0].second;
    for(int i=1;i<n;++i) {
        Bmaxi = max(Bmaxi,in[i].first);
        Rmini = min(Rmini,in[i].second);
    }
    ret = min(ret, (ll)(Bmaxi - Bmini)*(Rmaxi - Rmini));
    printf("%lld\n",ret);
}

int main() {
    //freopen("/Users/gotop/Documents/ps_practice/ps_practice/input.txt", "r", stdin);
    solve();
}


Measured memory_bytes: 3956
#include <iostream>
using namespace std;
#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x>y?y:x)
#define INF 1000000
typedef long long ll;

ll cost[15][15];

int main()
{
	int n,max,num;
	ll sum,min;
	
	while(cin>>n,n){
		num=0;
		min=INF;
		max=0;
		
		for(int i=0;i<15;i++){
			for(int j=0;j<15;j++){
				cost[i][j]=(i==j?0:INF);
			}
		}
		
		for(int i=0;i<n;++i){
			int a,b;
			ll c;
			cin>>a>>b>>c;
			cost[a][b]=c;
			cost[b][a]=c;
			if(max<MAX(a,b))max=MAX(a,b);

		}
		
		for(int k=0;k<=max;k++){
			for(int i=0;i<=max;i++){
				for(int j=0;j<=max;j++){
					cost[i][j]=MIN(cost[i][j],cost[i][k]+cost[k][j]);
				}
			}
		}
		
		for(int i=0;i<=max;i++){
			sum=0;
			for(int j=0;j<=max;j++){
				sum+=cost[i][j];
			}
			if(min>sum){
				min=sum;
				num=i;
			}	
		}
		cout<<num<<" "<<min<<endl;
	}
	return 0;
}

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

int n, w;
ll dp[100100];
int val[102], wt[102];

int main() {
	cin >> n >> w;
	for (int i = 1; i <= n; ++i) cin >> wt[i] >> val[i];

	for (int pos = 1; pos <= n; ++pos) {
		for (int weight = w; weight >= 0; --weight) {
			if ( weight - wt[pos] >= 0 ) 
				dp[weight] = max(dp[weight], dp[weight - wt[pos]] + val[pos]);
		}
	}

	cout << dp[w] << endl;
	return 0;
}


Measured memory_bytes: 1024
///Bismillahir Rahmanir Rahim
#define ll long long
#define ull unsigned long long
#define scf1(a)  scanf("%lld",&a)
#define scf2(a,b)  scanf("%lld %lld",&a,&b)
#define pf    printf
#define pb    push_back
#define rsrt(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define ff first
#define ss second
#define spd ios_base::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
ll arr[100005];
ll dp[100005];
ll n,res,ans;
ll mincost(ll pos)
{
    if(pos>=n)return 0;

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


    ll res = abs(arr[pos]-arr[pos+1]) + mincost(pos+1);

    if(pos+2<=n)
     res = min(res,abs(arr[pos]-arr[pos+2]) + mincost(pos+2));

    dp[pos] = res;

    return dp[pos];
}
int main()
{
    spd;

    ll i,j,k;

    cin>>n;

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

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

    cout<<mincost(1)<<endl;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int A=in(),B=in(),C=in(),D=in();
	
	out(A!=C?1:0);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
 	int x,y;
   cin>>x>>y;
   for(int i=0;i<=x;i++){
     int j=x-i;
       if(i*2+j*4==y){cout<<"Yes"<<endl;return 0;}
     }
   cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int ans = 0;
		for(int i = 0; i < s.length(); ++i) {
			if(s.charAt(i) == '+')ans++;
			else ans--;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double  
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((ll)x.size())

const ll Nmax=1e5;
vector<ll> dp(Nmax,0);

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
    ll _; cin>>_;
    for(ll x=1 ; x<=100 ; x++){
    for(ll y=1 ; y<=100 ; y++){
      for(ll z=1 ; z<=100 ; z++){
        ll n=((x+y+z)*(x+y+z)+x*x+y*y+z*z)/2;
        dp[n]++;
      }
    }
  }
    for(ll i=1 ; i<=_; i++) cout<<dp[i]<<'\n';
  return 0;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  if (A <= 5) {
    cout << 0 << endl;
  }
  else if (A < 13) {
    cout << B / 2 << endl;
  }
  else {
    cout << B << endl;
  }
}

Measured memory_bytes: 3592
// be name khoda
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define int long long
#define mpr make_pair 
typedef long long ll;
#pragma GCC optimize("Ofast")

const int maxn = 1e6+10;
const int N = 1e6+5;
const int mod = 998244353;
const int inf = 1e9+10;

int n, m;
bool is[maxn];
deque<int> deq = {1}; 
vector<int> g[maxn];

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>> n >> m;
    for(int i = 1, u, v; i <= m; i++)
    {
        cin>> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    is[1] = 1;
    while(1)
    {
        bool can = 0;
        for(auto u : g[deq.back()])
            if(!is[u])
            {
                can = 1;
                deq.push_back(u);
                is[u] = 1;
                break;
            }
        if(!can) break;
    }
    while(1)
    {
        bool can = 0;   
        for(auto u : g[deq.front()])
            if(!is[u])
            {
                can = 1;
                deq.push_front(u);
                is[u] = 1;
                break;
            }
        if(!can) break;
    }     
    cout<< deq.size() <<"\n";
    for(auto x : deq) cout<< x <<" ";
}





Measured memory_bytes: 28288
using System;

public class ABC150A {
  public static void Main(string[] args) {
    var str = Console.ReadLine().Split();
    int k = int.Parse(str[0]);
    int x = int.Parse(str[1]);
    
    if (500 * k >= x) {
      Console.WriteLine("Yes");
    }else {
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 13140
#include <iostream>
void swap(int A[],int B[],int I[],int i,int j)
{
    int temp;
    temp=A[i];
    A[i]=A[j];
    A[j]=temp;
    temp=B[i];
    B[i]=B[j];
    B[j]=temp;
    temp=I[i];
    I[i]=I[j];
    I[j]=temp;
}

void pushdown(int A[],int B[],int I[],int f,int l)
{
    int p=f;
    int c=2*p;
    while (c<=l)
    {
        if(c<l&&((B[c-1]<B[c])||(B[c-1]==B[c]&&A[c-1]<A[c])))c++;
        if(B[c-1]<B[p-1]||(B[c-1]==B[p-1]&&A[c-1]<A[p-1]))break;
        swap(A,B,I,c-1,p-1);
        p=c;
        c=2*p;
    }
}

void heap_sort(int A[],int B[],int I[],int n)
{
    int i;
    for(i=n/2;i>0;i--)pushdown(A,B,I,i,n);
    for(i=n;i>1;i--)
    {
        swap(A,B,I,0,i-1);
        pushdown(A,B,I,1,i-1);
    }
}
int main()
{
    int N;
    int i;
    int t=0;
    scanf("%d",&N);
    int A[N],B[N],I[N];
    for(i=0;i<N;i++)
    {
        scanf("%d %d",&A[i],&B[i]);
        I[i]=i;
    }
    heap_sort(A,B,I,N);
    for(i=0;i<N;i++)
    {
        t+=A[i];
        if(t>B[i])
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 123456789012345
#define int ll
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//
int cx[105],cy[105],cr[105];
int vx[105],vy[105];
//
//initialization finish


// your function is here
//

//
// your function finished

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//

	string s;cin >> s;

	int ans = 700;
	rep(i,3) if(s[i] == 'o')ans += 100;

	Print(ans);



	//
	// your code finished


	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

n = int(input())
l = [input() for _ in range(n)]
d = defaultdict(int)
for i in range(len(l)):
    d[l[i]] += 1
d = sorted(d.items(), key=lambda x:-x[1])
ans = []
num = d[0][1]
for i in range(len(d)):
    if d[i][1] != num:
        break
    ans.append(d[i][0])
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 120656
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(){
	int n,x;
	cin>>n>>x;
	int a[n];
	int b=1,k=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		k+=a[i];
		if(k<=x){
			b++;
		}
	}
	cout<<b;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const int N = 1e6 + 5;
int f[N];
int ok[N];

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

   int a[n];
   f(i,0,n) cin >> a[i] , f[a[i]]++;

   int cnt = 0;

   f(i,0,n){
      f[a[i]]--;
      int ok = 1;
      for(int j=1 ; j*j <= a[i] ; j++){
         if(a[i] % j == 0){
            if(f[j] || f[a[i]/j]) ok = 0;
         }
      }
      cnt += ok;
      f[a[i]]++;
   }
   cout << cnt << "\n";
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;

int main(void){

    //input
    int R;
    cin >> R;

    //output
    int arc = 0;

    cout<< 2*R*3.14;
    
    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100
void solve(){
	int n, a;
	cin>>n>>a;
	if(a>=n%500)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
    int n,m,ri[550]={0},a[10050]={0},b[10050]={0},ans=0;
    cin>>n>>m;
    if(n==0 && m==0)break;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        if(a[i]==1){
            ri[b[i]]=2;
        }
    }
    for(int i=0;i<m;i++){
        if(ri[a[i]]==2 && ri[b[i]]!=2){
            ri[b[i]]=3;
        }
        else if(ri[a[i]]!=2 && ri[b[i]]==2){
            ri[a[i]]=3;
        }
    }
    for(int i=2;i<=n;i++){
        if(ri[i]>1)ans++;
    }
    cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int r;
    cin>>r;
    if(r<1200) cout<<"ABC"<<endl;
    else if(r<2800) cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
    
    return 0;
}

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

using namespace std;

int main() 
{
    vector<int> abc(3);

    cin >> abc[0] >> abc[1] >> abc[2];
    sort(abc.begin(), abc.end());
    abc.erase(unique(abc.begin(), abc.end()), abc.end());

    cout << abc.size() << endl;

    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;


int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << " " << a*2+b*2 <<"\n";

  return 0;
}





Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

/*lli RepeatSquaring(lli N, lli P){
    if(P==0) return 1;
    if(P%2==0){
        lli t = RepeatSquaring(N, P/2);
        return t*t;
    }
    return N * RepeatSquaring(N, P-1);
}//繰り返し二乗法




lli zenbu(lli ket){
lli ret;
  ret=RepeatSquaring(3, ket)-3*RepeatSquaring(2, ket)+3;
  return ret;
}

int main(){
  lli N;
  cin >> N;
  lli keta;
  keta=log10(N);
  lli ans=0;
  if(keta<2){
    cout << 0 << endl;
    return 0;
  }
  else if(keta==2){
  if(N/100<3)
    cout << 0 << endl;
    else if(N/100<5)
    cout << 2 << endl;
    else if(N/100<7)
    cout << 4 << endl;
    else    
      cout << 6 << endl;
    return 0;
  }
  
  else {
    ans+=zenbu(keta);
  if(N/RepeatSquaring(10,keta)<3)
    ans+=0;
    else if(N/RepeatSquaring(10,keta)<5){
    ans+=RepeatSquaring(2,keta)-2;
    }
    else if(N/RepeatSquaring(10,keta)<7){
      ans*=2;
    ans+=RepeatSquaring(2,keta)-2;
    ans+=RepeatSquaring(2,keta)-2;
    }
    else    {
      ans=0;
      ans=zenbu(keta+1);
    }
  }
  cout << ans << endl;
}*/

//generate pattern

int main(){
  int X,Y;
  cin >> X >>Y;
  cout << X+Y/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;

int main(){
	lli n;
	cin >> n;
	vector<lli> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	lli ans = 0;
	map<lli, lli> state;
	for(int i=0; i<n; i++){
		ans += state[i-a[i]];
		state[a[i]+i]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b:i--)
//Binomial Coefficients
const long long c_max = 1000003;
const long long mod = 1e9+7;
long long fac[c_max], finv[c_max], inv[c_max];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < c_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;
    }
}
// 二項係数計算
long long COM(long long comn, long long comk){
    if (comn < comk) return 0;
    if (comn < 0 || comk < 0) return 0;
    return fac[comn] * (finv[comk] * finv[comn - comk] % mod) % mod;
}
//Power
long long powmod(long long px, long long py, long long pmod){
	if(py == 0) return 1;
	if(py % 2 == 0) return powmod((px * px) % pmod, py / 2, pmod);
	else return (px * powmod(px, py - 1, pmod)) % pmod;
} 

int main() {
    // your code goes here
    COMinit();
    ll n,k,ans=0;
    cin >> n >> k;
    if(k>=n-1){
        cout << COM(2*n-1,n) << endl;
        return 0;
    }
    rep(i,0,k){
        ans=(ans+COM(n,i)*COM(n-1,i)%mod)%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23680
sq_nums = {i * i for i in range(1, 151)}
N, D = map(int, input().split())
coords = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if sum((y - z) ** 2 for y, z in zip(coords[i], coords[j])) in sq_nums:
            ans += 1
print(ans)


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

const int MOD = 1000000007;

int main() {
  ll n, m;
  cin >> n >> m;

  vector<int> a(m);
  rep(i, m) cin >> a[i];

  vector<int> s(100010);
  rep(i, m) s[a[i]] = 1;

  vector<ll> dp(n + 3);
  dp[0] = 1;

  rep(i, n) {
    if (s[i + 1] != 1) {
      dp[i + 1] += dp[i];
      dp[i + 1] %= MOD;
    }
    if (s[i + 2] != 1) {
      dp[i + 2] += dp[i];
      dp[i + 1] %= MOD;
    }
  }
  cout << dp[n] << endl;
}


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

#define int long long

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

signed main()
{
	long long H, W; cin >> H >> W;

	if (H == 1 or W == 1) {
		cout << 1 << endl;
		return 0;
	}

	int odd_col = (H+1)/2;
	int even_col = H/2;

	int ans;

	if (0) {
		printf("odd_col=%lld,\neven_col=%lld\n",odd_col,even_col);
	}

	if (W % 2 == 0) {
		ans = (odd_col + even_col) * (W/2);
	} else {
		ans = (odd_col + even_col) * (W/2) + odd_col;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
	io;
	ll t,d;
	cin>>t>>d;
	ll cnt=0;
	d=d*d;
	while(t--){
		ll a,b;
		cin>>a>>b;
		ll val=a*a + b*b;
		if(val<=d){
			cnt++;
		}
	}cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3648
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(input())
    c = input()
    countlist = [0]
    count = 0
    for i in c:
        if i == 'W':
            count += 1
            countlist.append(count)
        else:
            countlist.append(count)
    ans = 10**6
    for i in range(N+1):
        lnum = countlist[i]
        rnum = N - i - (countlist[-1] - countlist[i])
        difnum = min(lnum, rnum)
        lnum -= difnum
        rnum -= difnum
        tmp = difnum
        tmp += lnum + rnum
        if tmp < ans:
            ans = tmp
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 87456