akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,k;cin >> n >> k;
    string s;cin >> s;
    vector<int> res;
    if(s[0] == '0')res.push_back(0);
    for(int i = 0,j;i < n;i = j){
        int tmp = i;
        for(;i < n &&s[i] == s[tmp];i++);
        res.push_back(i-tmp);
        if(i == n)break;
        for(j = i+1;j < n && s[j] == s[i];j++);
        res.push_back(j-i);
    }
    if(s.back() == '0')res.push_back(0);
    // trace(res);
    int m = res.size();
    vector<int> sum(m+1);
    rep(i,m)sum[i+1] = sum[i] + res[i];
    if(2*k+1 > m){
        cout << sum.back() << endl;
        return 0;
    }
    int ret = 0;
    for(int i = 0;i + 2*k+1 <= m;i+= 2){
        ret = max(ret,sum[i+2*k+1] - sum[i]);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 5144
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
  string hanako;
  string tarou;
  int n;
  int tpoint=0;
  int hpoint=0;
  int i;
  
  cin >> n;
  
  for(i=0;i<n;i++)
  {
    cin >> tarou >>hanako;
    
    if(tarou>hanako)
      tpoint+=3;
    if(hanako>tarou)
      hpoint+=3;
    if(hanako==tarou)
    {
      tpoint++;
      hpoint++;
    }
  }
  cout << tpoint <<" "<< hpoint<<"\n";
}

Measured memory_bytes: 1208
#include <stdio.h>

int main()
{
	int N;
	
	scanf("%d", &N);
	if (N % 10 == 9)
		printf("Yes");
	else if (N / 10 % 10 == 9)
		printf("Yes");
	else 
		printf("No");
		
	return 0; 
}

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

//#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

//#define int long long
using namespace std;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MB = 20;

bool cmp(const pair<string, pair<int, int>>& one, const pair<string, pair<int, int>>& two) {
	if (one.first == two.first) return one.second.first > two.second.first;
	return one.first < two.first;
}

void solve() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(m);
	for (int i = 0; i < m; i++) {
		int k;
		cin >> k;
		a[i].resize(k);
		for (int j = 0; j < k; j++) {
			cin >> a[i][j];
			a[i][j]--;
		}
	}

	vector<int> p(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}

	int ans = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		bool good = true;
		for (int i = 0; i < m; i++) {
			int res = 0;
			for (int j : a[i]) {
				if ((mask >> j) & 1) res ^= 1;
			}
			if (res != p[i]) good = false;
		}
		if (good) ans++;
	}
	cout << ans;
}


signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <iostream>
#include <map>
using namespace std;

struct unknown_atom_exception {};
int parse_number(string::const_iterator & first, string::const_iterator last) {
    assert (first != last);
    int n = 0;
    while (first != last and isdigit(*first)) {
        n *= 10;
        n += *first - '0';
        ++ first;
    }
    return n;
}
string parse_atom(string::const_iterator & first, string::const_iterator last) {
    assert (first != last);
    assert (isupper(*first));
    string name;
    name += *first;
    ++ first;
    if (first != last and islower(*first)) {
        name += *first;
        ++ first;
    }
    return name;
}
int parse_molcules(string::const_iterator & first, string::const_iterator last, map<string, int> const & weight);
int parse_molcule(string::const_iterator & first, string::const_iterator last, map<string, int> const & weight) {
    assert (first != last);
    int value;
    if (isalpha(*first)) {
        string atom = parse_atom(first, last);
        if (weight.count(atom)) {
            value = weight.at(atom);
        } else {
            throw unknown_atom_exception {};
        }
    } else {
        assert (*first == '(');
        ++ first;
        value = parse_molcules(first, last, weight);
        assert (*first == ')');
        ++ first;
    }
    if (first != last and isdigit(*first)) {
        value *= parse_number(first, last);
    }
    return value;
}
int parse_molcules(string::const_iterator & first, string::const_iterator last, map<string, int> const & weight) {
    assert (first != last);
    int value = 0;
    while (first != last and *first != ')') {
        value += parse_molcule(first, last, weight);
    }
    return value;
}
int parse(string const & s, map<string, int> const & weight) {
    try {
        auto it = s.begin();
        return parse_molcules(it, s.end(), weight);
    } catch (unknown_atom_exception e) {
        return -1;
    }
}

int main() {
    map<string, int> weight;
    while (true) {
        string atom; cin >> atom;
        if (atom == "END_OF_FIRST_PART") break;
        cin >> weight[atom];
    }
    while (true) {
        string expr; cin >> expr;
        if (expr == "0") break;
        int result = parse(expr, weight);
        if (result == -1) {
            cout << "UNKNOWN" << endl;
        } else {
            cout << result << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,p,aa[220000],cntl=0,ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c,cc[220000];
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        while(1){
            if(aa[i]%2==0){
                aa[i]/=2;
                cnt++;
            }else{
                break;
            }
        }
    }
    cout<<cnt;
}

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

int main() {
  int A, B; 
  cin >> A >> B;

  int result = 0;

  if(A >= 13){
    result = B;
  }
  else if(A >= 6 && A <= 12){
    result = B / 2;
  }

  cout << result << endl;
}

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

int main() {
  int N, K, x, l;
  cin >> N;
  cin >> K;
  l=0;
   for (int i=0;i<N;i++) {
     cin >> x;
     if (x*2<K) {
       l += x*2;
     }
     else {
       l += (K-x)*2;
     }
   }
  cout << l << endl;
}

Measured memory_bytes: 256
n = int(input())
r1 = tuple(int(x) for x in input().split())
r2 = tuple(int(x) for x in input().split())
# If d == 0, first it moves down, then it moves right.
candies = (sum(r1[:d+1]) + sum(r2[d:]) for d in range(n))
print(max(candies))


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;


int main(){
    int a, b, c;
    cin >> a >> b >>c;
    cout << a*b/2 << endl;
}


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

vector<int>v[110000];
vector<int>dp(110000,-1);

int func(int x){
    
    if(dp[x]!=-1)return dp[x];
    
    int res=0;
    
    for(int child:v[x]){
        res=max(res,func(child)+1);
    }
    
    return dp[x]=res;
    
    
}

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n,m;
    cin>>n>>m;
    
    
    for(int i=0;i<m;i++){
        
        int x,y;
        cin>>x>>y;
        
        v[x].push_back(y);
        
    }
    
    int ans=0;
    
    for(int i=1;i<=n;i++){
       ans=max(ans,func(i));
    }
    
    cout<<ans<<'\n';
    
    return 0;
    
}

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

int main()
{
	int n, m;
	int ary[101];

	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> ary[i];

	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j < n; j++)
		{
			if ((ary[j] % i) > (ary[j + 1] % i)) swap(ary[j], ary[j + 1]);
		}
	}
	for (int i = 1; i <= n; i++) cout << ary[i] << endl;

	return 0;
}

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

int main(){
	int a[4],b[4];
	int s,t;
	for(int i=0;i<4;i++)cin>>a[i];
	for(int j=0;j<4;j++)cin>>b[j];
	s=a[0]+a[1]+a[2]+a[3];
	t=b[0]+b[1]+b[2]+b[3];
	if(s>t)cout<<s;
	else cout<<t<<endl;
}

Measured memory_bytes: 1160
N=int(input())
C=[0 for i in range(N-1)]
S=[0 for i in range(N-1)]
F=[0 for i in range(N-1)]
for i in range(N-1):
    C[i],S[i],F[i]=map(int,input().split())
O=[0 for i in range(N)]
for i in range(N-1):
    for j in range(i,N-1):
        if O[i]<S[j]:
            O[i]=S[j]
        elif O[i]%F[j]!=0:
            O[i]=F[j]*(O[i]//F[j]+1)
        O[i]+=C[j]

O[N-1]=0
for i in range(N):
    print(O[i])


Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>

int main(){
    int n, ac=0, wa=0, tle=0, re=0;
    scanf("%d", &n);
    char input[5];
    for(int i=0;i<n;i++){
        scanf("%s", input);
        
        if(strcmp(input,"AC")==0){
            ++ac;
        } else if(strcmp(input,"WA")==0){
            ++wa;
        } else if(strcmp(input,"TLE")==0){
            ++tle;
        } else if(strcmp(input,"RE")==0){
            ++re;
         }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
char a[1005][1005];
int dp[1005][1005];
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
	dp[1][1]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#') continue;
			if(a[i-1][j]!='#') dp[i][j]+=dp[i-1][j],dp[i][j]%=MOD;
			if(a[i][j-1]!='#') dp[i][j]+=dp[i][j-1],dp[i][j]%=MOD;
		}
	/*for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			printf("%d ",dp[i][j]); 
		printf("\n");
	}*/
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 5120
judge = False
N, Y = map(int, input().split())
x = -1
while x <= N and (not judge):
    x += 1
    y = z = 0
   # print('x:' + str(x))
    rest = Y - x * 10000
    if rest <= 0:
        if rest == 0 and x == N:
            judge = True
        break
    while x + y <= N and Y - x * 10000 - y * 5000 >= 0:
        z = (Y - x * 10000 - y * 5000) // 1000
      #  print('y:' + str(y) + 'z:' + str(z))
        if x + y + z == N:
            judge = True
            break
        y += 1
if judge:
    print(str(x) + ' ' + str(y) + ' ' + str(z))
else:
    print('-1 -1 -1')


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


int main() {
    int n; cin >> n;
    vector<vector<int> > dp(3, vector<int> (n));
    for (int i = 0; i < 3; i++) {
        cin >> dp.at(i).at(0);
    }
    for (int i = 1; i < n; i++) {
        int a, b, c; cin >> a >> b >> c;
        dp.at(0).at(i) = a + max(dp.at(1).at(i-1), dp.at(2).at(i-1));
        dp.at(1).at(i) = b + max(dp.at(2).at(i-1), dp.at(0).at(i-1));
        dp.at(2).at(i) = c + max(dp.at(0).at(i-1), dp.at(1).at(i-1));
    }
    cout << max(dp.at(0).at(n-1), max(dp.at(1).at(n-1), dp.at(2).at(n-1))) << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#include <string.h>

int main() {

    int n;
    scanf("%d", &n);
    char w[101];
    char arr[n][101];

    for (int i = 0; i < n; i++) {
        scanf("%s", w);
        strcpy(arr[i], w);
    }
    int isCheck = 0;

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            //printf("%s %s\n", arr[i], arr[j]);
            if (strcmp(arr[i], arr[j]) == 0) {
                isCheck = 1;
                break;
            }
        }
    }

    if (isCheck == 0) {
        for (int i = 0; i < n - 1; i++) {
            int l = strlen(arr[i]);
            //printf("%s %s %c %c\n", arr[i], arr[i + 1], arr[i][l - 1], arr[i + 1][0]);
            if(arr[i][l - 1] != arr[i + 1][0]){
                isCheck=1;
                break;
            }

        }

    }

    if(isCheck==0){
        printf("Yes");
    }else{
        printf("No");
    }



    return 0;
}


Measured memory_bytes: 1712
// ?????¬???????????¬?????? (define int long long ?????????)

#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 <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

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

const int INF = 1 << 25;
int R, C;
int board[20][10010];
int inv[20][10010];

int main() {
    while(cin >> R >> C, R || C) {
        rep(i,0,R) rep(j,0,C) {
            cin >> board[i][j];
            inv[i][j] = board[i][j] ^ 1;
        }

        int ans = 0;
        rep(bit,0,1<<R) {
            vector<int> cnt(C);
            rep(i,0,R) {
                rep(j,0,C) {
                    // ?????£????????????????????????
                    if(bit >> i & 1) cnt[j] += inv[i][j];
                    else cnt[j] += board[i][j];
                }
            }

            int tmp = 0;
            rep(i,0,C) {
                tmp += max(cnt[i], R - cnt[i]);
            }
            ans = max(ans, tmp);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3908
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());
        int time = 0;

        time = Math.max(0, Math.min(B, D) - Math.max(A, C));

        PrintWriter out = new PrintWriter(System.out);
        out.println(time);

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 35704
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int total=1;
    int count=0;



    while (total<b) {
      total+=a;
      total-=1;
      count++;
      // System.out.println(total+" "+count);
    }

    System.out.println(count);
  }
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
    string s;
    ll K;
    cin >> s >> K;

    int cnt = 0;
    char m = 0;
    for(ll i = 0; i < min((ll)s.size(), K); i++) {
        if (s[i] == '1') cnt++; else if (m == 0) m = s[i];
    }

    if (K == cnt) {
        cout << 1 << endl;
        return;
    }

    if (K == 1) {
        cout << s[0] << endl;
    } else {
        cout << m << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k;
long long w[109];
long long s[109];
long long dp[109][1000009];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>s[i];
	}
	for(int j=1;j<=100009;j++){
		dp[0][j]=1000000009;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=100009;j++){
			if(j-s[i]<0){
				dp[i][j]=dp[i-1][j];
				continue;
			}
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-s[i]]+w[i]);
		}
	}
	int mx=0;
	for(int i=0;i<=100009;i++){
		if(dp[n][i]>k) continue;
		mx=max(mx,i);
	}
	cout<<mx<<endl;
}


Measured memory_bytes: 287744
# coding: utf-8
import sys


def readline():
    return sys.stdin.readline().rstrip()


def read(f=int):
    return f(readline())


def reads(f=int):
    return list(map(f, readline().split()))


def read_n(n: int, f=int):
    return [read(f) for _ in range(n)]


def reads_n(n: int, f=int):
    return [reads(f) for _ in range(n)]

N = read()
S = read(str)

slime = 0

prev = None
for s in S:
        if prev == s:
                continue
        slime += 1
        prev = s

print(slime)


Measured memory_bytes: 3316
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	int a,b; cin>>a>>b;
	if(b>=a) puts("unsafe"); else puts("safe");
	return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>
typedef struct Position{
    double x;
    double y;
}position;
void kock(int,position,position);
int main(){
    int n;
    position p1,p2;
    p1.x = 0.0;
    p1.y = 0.0;
    p2.x = 100.0;
    p2.y = 0.0;
    scanf("%d",&n);
    printf("%.8f %.8f\n",p1.x,p1.y);
    kock(n,p1,p2);
    printf("%.8f %.8f\n",p2.x,p2.y);
    return 0;
}
void kock(int n,position p1,position p2){
    position s,t,u;
    if( n==0 ) return ;
    s.x = (p1.x * 2 + p2.x * 1 ) / 3.0;
    s.y = (p1.y * 2 + p2.y * 1 ) / 3.0;
    t.x = (p1.x * 1 + p2.x * 2 ) / 3.0;
    t.y = (p1.y * 1 + p2.y * 2 ) / 3.0;
    u.x = (t.x - s.x ) / 2.0 - ( t.y - s.y ) * sqrt(3) / 2.0 + s.x;
    u.y = (t.x - s.x ) * sqrt(3) / 2.0 + ( t.y - s.y ) / 2.0 + s.y;
 
    kock(n-1,p1,s);
    printf("%.8f %.8f\n",s.x,s.y);
    kock(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    kock(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    kock(n-1,t,p2);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int n,visited[8];
vector<int>adj[8];
int dfs(int i){
    visited[i]=1;
    int flag=1;
    for(int j=0;j<n;++j){
        if(!visited[j]){
            flag=0;
        }
    }
    if(flag){
        return 1;
    }
    int sum=0;
    for(auto x:adj[i]){
        if(!visited[x]){
            sum+=dfs(x);
            visited[x]=0;
        }
    }
    return sum;
}
int main()
{
int i,m;
scanf("%d %d",&n,&m);
while(m--){
    int u,v;
    scanf("%d %d",&u,&v);
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
}
printf("%d",dfs(0));



    return 0;
}


Measured memory_bytes: 3784
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program{
  static void Main(){
    var input = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var n = input[0];
    var m = input[1];
    var input1 = ReadLine().Split(' ').Select(int.Parse).ToArray();
    double b = input1.Sum()/(4.0*m);
   

    var judge = input1.Where(a => a >= b).Count();
    
    if(judge >= m){
    	Write("Yes");
    }else{
    	Write("No");
    }
    
  }
}

Measured memory_bytes: 18960
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<vector<int>> ss(M);
  vector<int> ps(M);
  F0R(i, M) {
    int k;
    cin >> k;
    F0R(j, k) {
      int s;
      cin >> s;
      ss[i].push_back(s-1);
    }
  }
  F0R(i, M) {
    cin >> ps[i];
  }
  int result = 0;
  F0R(b, 1 << N) {
    bool ok = true;
    F0R(i, M) {
      int a = 0;
      F0R(j, ss[i].size()) {
        a += (b >> ss[i][j]) & 1;
      }
      if ((a & 1) == ps[i]) {
        // OK
      }
      else {
        ok = false;
        break;
      }
    }
    if (ok) result++;
  }
  cout << result;
}
#endif


Measured memory_bytes: 3644
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
m,d = readInts()
cnt = 0
for i in range(22,d+1):
    for p in range(1, m+1):
        if i // 10 >= 2 and i % 10 >= 2:
            if p == (i//10) * (i % 10):
                cnt += 1
print(cnt)


Measured memory_bytes: 5276
package main

import (
   "fmt"
)

func solution(n int) int {
   return max(helper(n), helper(dec(n)))
}

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

func helper(n int) int {
   out := 0
   for n > 0 {
        out += n % 10
        n /= 10
   }
   return out
}

func dec(n int) int {
   k := 1
   for n >= 10 {
        n /= 10
        k *= 10
   }
   return n*k - 1

}

func main() {
   var n int
   fmt.Scan(&n)
   fmt.Println(solution(n))
}

Measured memory_bytes: 1768
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

template<typename T>
struct BIT {
	int n;
	vector<T>dat;
	BIT(int n = 0) {
		initialize(n);
	}
	void initialize(int temp) {
		n = temp;
		dat.resize(n);
		rep(i, 0, n)dat[i] = 0;
	}
	T sum(int i) {
		T s = 0;
		while (i >= 0) {
			s += dat[i];
			i = (i & (i + 1)) - 1;
		}
		return s;
	}
	T sum_between(int i, int j) {
		if (i > j)return 0;
		return sum(j) - sum(i - 1);
	}
	void plus(int i, T x) {
		while (i < n) {
			dat[i] += x;
			i |= i + 1;
		}
	}
	int lower_bound(T x) {
		if (sum(n - 1) < x)return -1;
		else if (sum(0) >= x)return 0;
		int ng = 0, ok = n - 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (sum(mid) >= x)ok = mid;
			else ng = mid;
		}
		return ok;
	}
};

ll bub(vector<ll>li){
	ll N = li.size();
	map<int, int>mp;
	for (int i = 0; i < N; i++)mp[li[i]] = i;
	vector<ll>to(N);
	for (int i = 0; i < N; i++)to[i] = mp[i];

	BIT<ll>bit(202020);
	ll ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		ans += bit.sum_between(0,to[i]-1);
		bit.plus(to[i], 1);
	}
	return ans;
}

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

	string S;
	cin >> S;
	set<ll>st[26];
	ll N = S.size();
	for (int i = 0; i < N; i++)st[S[i] - 'a'].insert(i);
	ll cntodd = 0;
	for (int i = 0; i < 26; i++)cntodd += st[i].size()%2;

	if (cntodd >= 2) {
		puts(-1);
		return 0;
	}

	vector<ll>li(N, -1);
	ll cur = 0;
	for (int i = 0; i < N; i++) {
		int num = S[i] - 'a';
		if (li[i] == -1) {
			if (st[num].size() >= 2) {
				int fr = *st[num].begin();
				auto itr = st[num].end();
				itr--;
				int ba = *itr;
				li[fr] = cur;
				li[ba] = N - 1 - cur;
				st[num].erase(fr);
				st[num].erase(itr);
				cur++;
			}
			else {
				li[i] = N/2;
				st[num].erase(i);
			}
		}
	}

	puts(bub(li));

	return 0;
}


Measured memory_bytes: 16148
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

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

	sort(h.rbegin(), h.rend());
	long long ans = 0;
	for (int i = k;i < n;i++) {
		ans += h[i];
	}

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

//BBBBBBBBBBBBBB
//int main() {
//	int h, n;
//	cin >> h >> n;
//	vector<int> a(n);
//	for (int i = 0;i < n;i++) {
//		cin >> a[i];
//	}
//
//	for (int i = 0;i < n;i++) {
//		h -= a[i];
//		if (h <= 0) {
//			cout << "Yes" << endl;
//			return 0;
//		}
//	}
//
//	cout << "No" << endl;
//
//	return 0;
//}

//AAAAAAAAAAAAA
//int main() {
//	int h,a;
//	cin >> h >> a;
//
//	if (h % a != 0)
//		cout << h / a + 1 << endl;
//	else cout << h / a << endl;
//	
//	return 0;
//}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n = 5;
    lli a[n];
    ncin1(n, a);
    lli x = 10;
    lli min_i = -1;
    REP(i, 0, n) {
        if (x > a[i] % 10 && a[i] % 10 != 0) {
            min_i = i;
            x = a[i] % 10;
        }
    }
    REP(i, 0, n) {
        if(i == min_i)
            continue;
        if (a[i] % 10 == 0)
            continue;
        a[i] += 10;
        a[i] -= a[i] % 10;
    }

    lli ans = 0;
    REP(i, 0, n) {
        ans += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

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

    int ans = 0;
    for(int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) ans++;
    }

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

Measured memory_bytes: 3572
from itertools import permutations


N, M = [int(i) for i in input().split()]
D = [[False] * N for _ in range(N)]
for _ in range(M):
    a, b = [int(i) for i in input().split()]
    D[a - 1][b - 1] = True
    D[b - 1][a - 1] = True
perm = [[0] + list(p) for p in list(permutations(range(1, N)))]

cnt = 0
for p in perm:
    flg = True
    for i in range(N - 1):
        if not D[p[i]][p[i + 1]]:
            flg = False
            break
    if flg:
        cnt += 1
print(cnt)


Measured memory_bytes: 10020
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

#define forsn(i,s,n) for(int i=(s); i<(int)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define F first
#define S second

int main() {
	int n, k; cin >> n >> k;
	int m = 0, gcd = 0;
	forn(i,n) { int t; cin >> t; m = max(m, t); gcd = __gcd(gcd, t);}

	if (k <= m && !(k % gcd)) cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define MOD 1000000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
ll int power(ll int x, ll int y, ll int p)  
{  
   ll int res = 1;     // Initialize result  
 
    x = x % p; // Update x if it is more than or  
                // equal to p
   
    if (x == 0) return 0; // In case x is divisible by p;
 
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
 
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

int main()
{
   ll int T;
T=1;


    while(T--)
    {
      ll int a,b,c,d;
      cin>>a>>b>>c>>d;
      ll int ans = max({b*d,a*c,b*c,a*d});
      cout<<ans<<endl;
    }

    return 0;
       }

Measured memory_bytes: 3632
#include <iostream>

using namespace std;
typedef long long LL;
const LL p = 1e9 + 7;

LL pow(LL a, LL b, LL p) {
    LL ans = 1;
    a %= p;
    while (b) {
        if (b & 1) {
            ans = (ans % p) * (a % p) % p;
        }
        b /= 2;
        a = (a % p) * (a % p) % p;
    }
    ans %= p;
    return ans;
}

LL inv(LL x, LL p) {
    return pow(x, p - 2, p);
}

LL C(LL n, LL m, LL p) {
    if (m > n) {
        return 0;
    }
    LL up = 1, down = 1;
    for (int i = n - m + 1; i <= n; i++) {
        up = up * i % p;
    }
    for (int i = 1; i <= m; i++) {
        down = down * i % p;
    }
    return up * inv(down, p) % p;
}

LL Lucas(LL n, LL m, LL p) {
    if (m == 0) {
        return 1;
    }
    return C(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}

int main() {
    LL n, a, b, ans = 0;
    cin >> n >> a >> b;
    LL cnt = pow(2, n, p);
    ans = (cnt - 1 - C(n, a, p) - C(n, b, p) + (p << 1)) % p;
    //ans = (cnt - 1 - Lucas(n, a, p) - Lucas(n, b, p) + (p << 1)) % p;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

vector<int> edge[100010];
vector<int> sum[100010];
bool done[100010];
long long ss[100010], sig[100010];
bool muri, murikamo;
long long kuso;

void dfs(int v, int si, long long unti)
{
	done[v]=true;
	ss[v]=unti;
	sig[v]=si;
	rep(i, edge[v].size())
	{
		int u=edge[v][i];
		long long s=sum[v][i];
		if(!done[u]) dfs(u, -si, s-unti);
		else
		{
			if(ss[u]!=s-unti || -si!=sig[u])
			{
				murikamo=true;
				if(-si == sig[u]) muri=true;
				else kuso = (s-unti-ss[u])/(2*si);
			}
		}
	}
}

int main()
{
	int n, m;
	cin >> n >> m;
	int u, v;
	long long s;
	for(int i=0; i<m; i++)
	{
		cin >> u >> v >> s;
		u--;
		v--;
		edge[u].push_back(v);
		edge[v].push_back(u);
		sum[u].push_back(s);
		sum[v].push_back(s);
	}
	dfs(0, 1, 0);
	if(muri) cout << '0' << endl;
	else if(murikamo)
	{
		long long yaru[100010];
		rep(i, n)
		{
			yaru[i]=ss[i]+kuso*sig[i];
			if(yaru[i]<=0) muri=true;
		}
		rep(i, n)rep(j, edge[i].size())
		{
			if(yaru[i]+yaru[edge[i][j]]!=sum[i][j]) muri=true;
		}
		if(muri) cout << '0' << endl;
		else cout << '1' << endl;
	}
	else
	{
		long long mx=1000000000, mn=1;
		rep(i, n)
		{
			if(sig[i]>0) mn=max(mn, 1-ss[i]);
			else mx=min(mx, ss[i]-1);
		}
		if(mn>mx) cout << '0' << endl;
		else cout << mx-mn+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 20608
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
const int MAX = 500050;
typedef pair<int, int>P;

double dp[500050];
signed main() {
	int N, M, d;
	cin >> N >> M >> d;
	double c = N - d;
	if (d == 0)c /= 2.0;
	double ans = (2 * c / (double)(N * N)) * (M - 1);
	cout << setprecision(10) <<ans<< endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll n;
  cin>>n;
  if(n)
    cout<<64-__builtin_clzll(n)<<endl;
  else
    cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 1196
a, = [list(map(int, s.split())) for s in open(0)]

flag = True
c = a[0]
while flag:
    p = int(c ** 0.5) + 1
    for i in range(2, p):
        if c % i == 0:
            c += 1
            break
    else:
        flag = False
print(c)

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

int main() {
  int D, T, S;
  cin >> D >> T >> S;

  if (D <= T * S) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	static ArrayList<Integer> listX = new ArrayList<Integer>();
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		while(sc.hasNext()) {
			double a = Double.parseDouble(sc.next());
			double sum = a;
			for(int i = 2; i <= 10; i++) {
				if(i % 2 == 0) {
					a *= 2;
				}
				else {
					a /= 3;
				}
				sum += a;
			}
			out.println(sum);
		}
		out.flush();
	}

	
	
	
	
}
	
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 15084
#include<stdio.h>
 
 int main(){
  int n, a; 
  int y=0;
  int l, m, k;
  scanf("%d", &n);
  int data[n];
  char c[12];
  int i;
 for(i=0;i<n;i++){
    scanf("%s %d",c,&a);
    if(c[0]=='i'){
    data[i]=a;
    }
 else if(c[6]=='F'){
    i-=2;
    n-=2;
    }
 else if(c[6]=='L'){
    i--;
    n--;
    y++;
  }
 else{
    i--;
    n--;
    l=0;
    int j;
    for(j=i;j>=0;j--){
    if(l>0) break;
    if(a==data[j]){
      k=0;
      m=i-j;
      l++;
      while(m!=k++)
    data[j+k-1]=data[j+1+k-1];
      i--;
      n--;
        }  
      }
    }
  }
  for(i=0;i<n-y;i++){
    if(i==n-y-1)
      printf("%d\n",data[n-1-i]);
    else
      printf("%d ",data[n-1-i]);
  }
  return 0;
}

Measured memory_bytes: 6064
#include <bits/stdc++.h>
#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 chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n, d;
	cin >> n >> d;
	int ans = 0;
	rep(i, n) {
		long long x, y;
		cin >> x >> y;
		long double dist = sqrt(x * x + y * y);
		if (dist <= d)
			ans++;
	}
	cout << ans << endl;
}

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

	solve();
}


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

int main(void){
    char c;
    cin >> c;
    int d = (int)(c-'a');
    if(d>=0 && d<26) cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt() * 2;
		List<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(sc.nextInt());
		}

		Collections.sort(list);
		int plusNum = 0,result = 0;
		if(list.size() % 2 != 0) plusNum += 1;
		for(int i = 0; i < list.size() / 2; i++) {
			result += list.get((i * 2) + plusNum);
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define first fst
#define second scd
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  int n,d;
  vector<int> a,b,c;
  int ans=0;
  int p,q;
  cin>>n;
  rep(i,n){cin>>d;a.push_back(d);}
  rep(i,n){cin>>d;b.push_back(d);}
  rep(i,n){cin>>d;c.push_back(d);}
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  rep(i,n){
    int f=b[i];
    p=lower_bound(a.begin(),a.end(),f)-a.begin();
    q=upper_bound(c.begin(),c.end(),f)-c.begin();
    
    
    ans+=p*(n-q);
  }
  cout<<ans<<endl;

  return 0;
}




Measured memory_bytes: 3316
//#include<bits/stdc++.h>
//using namespace std;
//typedef long long ll;
//const ll mod=1e9+7;
//ll a[100000];
//
//ll GCD(ll a,ll b)
//{
//    return b==0?a:GCD(b,a%b);
//}
//int main()
//{
//    ll n;
//    ll max1,x;
//    cin>>n;
//
//    ll ans=1;
//    for(ll i=0;i<n;i++)
//    {
//
//        cin>>x;
//        a[i]=x;
//        ans=x/GCD(ans,x)*ans;
//    }
//    //cout<<ans<<endl;
//
//    ll sum=0;
//    for(ll j=0;j<n;j++)
//    {
//        sum=sum+ans/a[j];
//        sum=sum%mod;
//    }
//    cout<<sum<<endl;
//    return 0;
//}
//
//
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int fun(int n)
{
	int m=n,cnt=0;
	while(n)
	{
		cnt++;
		n/=10;
	}
	return m/pow(10,cnt-1);
}
int main()
{
	int n,m;
	ll s[200010];
	int cnt=0,dp[100][100];
	s[0]=0;
	memset(dp,0,sizeof dp);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%10==0) 
		{
			s[i]=s[i-1];
			continue;
		}
		int x=fun(i),y=i%10;
	//	cout<<x<<' '<<y<<endl;
		s[i]=s[i-1]+2*dp[y][x];
		if(x==y) s[i]++; 
		dp[x][y]++;
	}
	cout<<s[n];
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct State{
    int y,x,t,b;
};

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int M = (1<<10)-1;

int h,w,n;
string s[10];

const int INF = 19191919;
int dp[10][10][10][1<<10];

bool IN(int y, int x){
    return 0<=y && y<h && 0<=x && x<w;
}

int main(){
    cin >>h >>w >>n;
    rep(i,h) cin >>s[i];

    int sy=0,sx=0;
    int by[5],bx[5];
    rep(i,h)rep(j,w){
        if(s[i][j] == 'S'){
            sy = i;
            sx = j;
        }
        if(islower(s[i][j])){
            int ID = s[i][j]-'a';
            by[ID] = i;
            bx[ID] = j;
        }
    }

    int sb = 0;
    int py = sy, px = sx;
    rep(i,5){
        int d = 0;
        while(d<4){
            int ny = py+dy[d], nx = px+dx[d];
            if(ny == by[i] && nx == bx[i]) break;
            ++d;
        }
        sb |= d<<(2*i);
        py = by[i];
        px = bx[i];
    }

    rep(i,10)rep(j,10)rep(k,10)rep(l,1<<10) dp[i][j][k][l] = INF;
    queue<State> que;
    dp[sy][sx][0][sb] = 0;
    que.push({sy,sx,0,sb});
    while(!que.empty()){
        State c = que.front();
        que.pop();

        int D = dp[c.y][c.x][c.t][c.b];
        // printf(" %d %d %d %d == %d\n", c.y, c.x, c.t, c.b,D);

        int tmask = c.b;
        py = c.y, px = c.x;
        by[0] = py;
        bx[0] = px;
        rep(i,4){
            int dir = tmask&3;
            tmask >>= 2;
            py += dy[dir];
            px += dx[dir];
            by[i+1] = py;
            bx[i+1] = px;
        }

        rep(i,4){
            int ny = c.y+dy[i], nx = c.x+dx[i];
            if(!IN(ny,nx)) continue;
            if(s[ny][nx] == '#') continue;

            bool body = false;
            rep(j,5)if(ny==by[j] && nx==bx[j]) body = true;
            if(body) continue;

            int nb = c.b;
            nb <<= 2;
            nb |= (i^2);
            nb &= M;

            int nt = c.t;
            if(s[ny][nx] == '0'+1+c.t) ++nt;

            if(dp[ny][nx][nt][nb] > D+1){
                dp[ny][nx][nt][nb] = D+1;
                que.push({ny,nx,nt,nb});
            }
        }
    }

    int ans = INF;
    rep(i,h)rep(j,w)rep(mask,1<<10) ans = min(ans, dp[i][j][n][mask]);
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}



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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int rdx[8] = {1,0,-1,0,1,1,-1,-1};
int rdy[8] = {0,-1,0,1,1,-1,-1,1};

int main() {
    string s;cin >> s;
    for(int i=0;i<s.size();i++)cout << 'x';
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int s, A = 0, B = 0;
  for(int i = 0; i < 4; ++i) {
	cin >> s;
	A += s;
  }
  for(int i = 0; i < 4; ++i) {
	cin >> s;
	B += s;
  }
  cout << (A >= B ? A : B) << endl;
  return 0;
}

Measured memory_bytes: 3088