akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int len = S.length();
    String s1 = "dream";
    String s2 = "dreamer";
    String s3 = "erase";
    String s4 = "eraser";
    String ans = "YES";
    // dp[i]はSのインデックス0からi-1までの部分文字列に対する判定結果（出来るなら1、出来ないなら0）
    int[] dp = new int[len + 1];
    dp[0] = 1;
    for(int i = 5; i < len + 1; i++) {
      String str5 = "";
      String str6 = "";
      String str7 = "";
      if(i >= 5) {
        str5 = S.substring(i - 5, i);
        if(s1.equals(str5) && (dp[i - 5] == 1)) dp[i] = 1;
        if(s3.equals(str5) && (dp[i - 5] == 1)) dp[i] = 1;
      }
      if(i >= 6) {
        str6 = S.substring(i - 6, i);
        if(s4.equals(str6) && (dp[i - 6] == 1)) dp[i] = 1;
      }
      if(i >= 7) {
        str7 = S.substring(i - 7, i);
        if(s2.equals(str7) && (dp[i - 7] == 1)) dp[i] = 1;
      }
    }
    if(dp[len] == 0) ans = "NO";
    System.out.println(ans);
  }
}

Measured memory_bytes: 40712
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
typedef long long ll;
typedef pair<ll,int> pii;
ll a[maxn],b[maxn];
priority_queue<pii> q;
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&b[i]);
		if(a[i]!=b[i]) q.push({b[i],i});
	}
	ll ans=0;
	while(!q.empty())
	{
		pii t=q.top();q.pop();
		ll ib=t.first;int id=t.second;
		//cout<<id<<" "<<ib<<endl;
		if(ib==a[id]) continue;
		int pre=(id-1+n)%n;int suf=(id+1+n)%n;
		if(pre==0) pre=n;if(suf==0) suf=n;
		//cout<<pre<<" "<<suf<<endl; 
		//cout<<b[pre]<<" "<<b[suf]<<" "<<a[id]<<" "<<ib<<endl;
		if((ib-b[pre]-b[suf]-a[id])<0)
		{
			puts("-1");return 0;
		}
		int stp=(ib-a[id])/(b[pre]+b[suf]);ans+=stp;
		//cout<<ans<<endl;
		ib-=1ll*stp*(b[pre]+b[suf]);
		b[id]=ib;
		if(a[id]!=ib) q.push({ib,id});
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 8944
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int N;
	string S;
	cin>>N>>S;

	long long r=0;
	long long g=0;
	long long b=0;
	long long result = 0;
	//まずRGBで揃えてみる
	for(int i=0; i<N; i++)
	{
		if(S[i]=='R')
		{
			r++;
		}
		if(S[i]=='G')
		{
			g++;
		}
		if(S[i]=='B')
		{
			b++;
		}
	}
	result = r*g*b;
	for(int i=0; i<N; i++)
	{
		for(int offset=1; i+2*offset<N; offset++)
		{
			int j = i+offset;
			int k = i+2*offset;
			if(S[i]!=S[j] && S[j]!=S[k] && S[k]!=S[i])
			{
				result--;
			}
		}
	}
	cout<<result<<endl;
}

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

int main(){
int N,H,W;
cin >> N >> H >> W;
int A;
int B;

int num=0;
for(int i=0;i<N;i++){
    cin>>A>>B;
    if(H<=A&&W<=B){
        num++;
    }
}
cout<<num;
return 0;
}

Measured memory_bytes: 256
ans=0

h,w,m=map(int,input().split())
d=list()
from collections import defaultdict
r=defaultdict(int)
c=defaultdict(int)
r=[0]*(h+1)
c=[0]*(w+1)
for i in range(m):
  a,b=map(int,input().split())
  d+=(a,b),
  r[a]+=1
  c[b]+=1
R=max(r)
C=max(c)

x=0
nr=r.count(R)
nc=c.count(C)
for i in range(m):
    a,b=d[i]
    if r[a]==R and c[b]==C:
        x+=1

ans=R+C
if x==nr*nc:
    ans-=1
print(ans)


Measured memory_bytes: 107904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.util.Arrays.binarySearch;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        Robot[] robots = new Robot[n];
        for (int i = 0; i < n; i++) {
            long x = in.nextLong();
            long d = in.nextLong();
            robots[i] = new Robot(x, d);
        }
        Arrays.sort(robots, new Comparator<Robot>() {
            public int compare(Robot o1, Robot o2) {
                return (int) (o1.x - o2.x);
            }
        });
        int[] r = new int[n];
        r[n - 1] = n - 1;
        for (int i = n - 2; i >= 0; i--) {
            long x = robots[i].x + robots[i].d;
            int rr = i;
            while (rr + 1 < n && x > robots[rr + 1].x) {
                rr = r[rr + 1];
            }
            r[i] = rr;
        }
        long[] dp = new long[n + 1];
        dp[n - 1] = 2; dp[n] = 1;
        for (int i = n - 2; i >= 0; i--) {
            dp[i] = (dp[i + 1] + dp[r[i] + 1]) % mod;
        }
        out.println(dp[0]);
    }

    public class Robot {
        public long x, d;

        public Robot(long x, long d) {
            this.x = x;
            this.d = d;
        }
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer      tokenizer;

    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll q; cin >> q;
  ll cnt = 0;
  priority_queue<ll> q1;
  priority_queue<ll, Vi, greater<ll>> q2;
  ll med, pos = 0, neg = 0, c = 0;
  REP(i, q){
    ll type; cin >> type;
    if(type == 1){
      ll a, b; cin >> a >> b;
      c += b;
      if(cnt == 0){
        med = a;
        q1.push(a); q2.push(a); pos += a; neg += a;
      }
      else if(cnt % 2 == 0){
        ll x = q1.top(), y = q2.top();
        if(a < x){
          q1.push(a); neg += a;
          q2.push(x); pos += x;
          med = x;
        }
        else if(a < y){
          q1.push(a); neg += a;
          q2.push(a); pos += a;
          med = a;
        }
        else{
          q1.push(y); neg += y;
          q2.push(a); pos += a;
          med = y;
        }
      }
      else if(cnt % 2 == 1){
        ll x = q1.top(), y = q2.top();
        if(a < med){
          q1.push(a); neg += a;
          q1.pop(); neg -= x;
          med = q1.top();
        }
        else{
          q2.push(a); pos += a;
          q2.pop(); pos -= y;
        }
      }
      cnt++;
    }
    else{
      ll ans = c + pos - neg;
      cout << med << ' ' << ans << endl;
    }
  }
}


Measured memory_bytes: 3828
import java.io.*;
import java.util.*;

public class Main {
    static final String YES = "Yes";
    static final String NO = "No";

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        String S;
        S = sc.next();

        final Solver solver = new Solver();
        System.out.println(solver.solve(N, S) ? YES : NO);
    }
}

class Solver {
    public boolean solve(long N, String S) {
        if (N % 2 != 0) return false;

        String first = S.substring(0, (int) N/2);
        String second = S.substring((int) (N/2));

        return first.equals(second);
    }
}



Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int a[100][100];

int main(){
    int H, W, N;
    cin >> H >> W;
    cin >> N;
    queue<int> nl;
    int num;
    for(int i=0; i<N; i++){
        cin >> num;
        nl.push(num);
    } 

    int cnt=0;
    int insert = 1;
    num = nl.front(); nl.pop();

    for(int i=0; i<H; i++){
        if(i % 2 == 0){
            for(int j=0; j<W; j++){
                cnt++;
                a[i][j] = insert;
                if(cnt == num){
                    num = nl.front(); nl.pop();
                    cnt = 0;
                    insert++;
                }
            }
        }else{
            for(int j=W-1; j>=0; j--){
                cnt++;
                a[i][j] = insert;
                if(cnt == num){
                    num = nl.front(); nl.pop();
                    cnt = 0;
                    insert++;
                }
            }
        }
    }

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(j != W-1){
                cout << a[i][j] << " ";
            }else{
                cout << a[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;

struct node
{
	int num,next;
	long long v;
};

node e[400011];
int edge[200011];
int taile;

void add(int xx,int yy,long long vv)
{
	e[taile].num=yy;
	e[taile].v=vv;
	e[taile].next=edge[xx];
	edge[xx]=taile++;
}


int r,c,n;

bool cover[200011];
long long a[200011];

long long m1,m2;

bool dfs(int now,long long val)
{
	cover[now]=1;
	a[now]=val;
	if(now<=r)
	{
		m1=min(m1,a[now]);
	}
	else
	{
		m2=min(m2,a[now]);
	}
	
	int i;
	for(i=edge[now];i!=-1;i=e[i].next)
	{
		if(cover[e[i].num]==0)
		{
			if(!dfs(e[i].num,e[i].v-a[now]))
			{
				return false;
			}
		}
		else
		{
			if(e[i].v!=a[now]+a[e[i].num])
			{
				return false;
			}
		}
	}
	return true;
}

int main()
{
	int i,j,k;
	int xx,yy,zz;
	
	scanf("%d %d",&r,&c);
	scanf("%d",&n);
	
	taile=1;
	memset(edge,-1,sizeof(edge));
	
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&xx,&yy,&zz);
		add(xx,yy+r,zz);
		add(yy+r,xx,zz);
	}
	
	memset(cover,0,sizeof(cover));
	
	for(i=1;i<=r+c;i++)
	{
		if(cover[i]==0)
		{
			m1=m2=0x3f3f3f3f;
			if(!dfs(i,0))
			{
				cout<<"No"<<endl;
				return 0;
			}
			
			if(m1+m2<0)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	
	
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 9088
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;

namespace Yuzuki
{
    class Yukari
    {
        public static void Main(string[] args)
        {
            int a, b, c, k;
            string[] buf = Console.ReadLine().Split();
            a = int.Parse(buf[0]);
            b = int.Parse(buf[1]);
            c = int.Parse(buf[2]);
            k = int.Parse(buf[3]);
            int ans = 0, use = 0;
            use = Min(a, k);
            ans += use;
            k -= use;
            use = Min(b, k);
            k -= use;
            use = Min(c, k);
            ans -= use;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27508
#include <stdio.h>

int f(int n);
int A[45];

int main(){
  int n,i;

  for(i=0;i<45;i++){
    A[i]=-1;
  }
  
  scanf("%d",&n);
  printf("%d\n",f(n));

  return 0;
}

int f(int n){
  if(n==0||n==1){
    return A[n]=1;
  }
  if(A[n]!=-1){
    return A[n];
  }
  return A[n]=f(n-1)+f(n-2);
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 256
#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--)
 
int main() {
  string s;
  cin >> s;
  int s_len = s.size();
  rep (i, s_len) {
    for (int j = 1; j < s_len; j++) {
      if (s[i] == s[i + j]) {
        cout << "no" << endl;
        return 0;
      }
    }
  }
  
  cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n, d; cin >> n >> d;

	int ans = 0;
	FOR_LT(i, 0, n) {
		int64_t x, y; cin >> x >> y;
		if (x * x + y * y <= d * d) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			long ans1 = 0, ans2 = 0;
			for (char c : s) {
				ans1 += (c - '0');
			}

			ans2 = ans2 + (s[0]-'0')-1 + 9*(s.length-1);

			out.println(Math.max(ans1, ans2));

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 23380
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int path[21][21];

int main(){
	int n,m;
	memset(path,0x3,sizeof(path));
	scanf("%d",&n);
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int a,b,cost_ab,cost_ba;
		scanf("%d,%d,%d,%d",&a,&b,&cost_ab,&cost_ba);
		path[a][b] = cost_ab;
		path[b][a] = cost_ba;
	}

	int x1,x2,y1,y2;
	scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);

	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				path[i][j] = min(path[i][k] + path[k][j],path[i][j]);
			}
		}
	}

	printf("%d\n",y1 - path[x1][x2] - path[x2][x1] - y2);
}

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

int main()
{
    int N,ar[100],i,c;
    i = N = c = 0;
    cin>>N;
//    ar[N];

    for(i=1;i<=N;i++)
    {
        cin>>ar[i];
        if( ((ar[i]) % 2 != 0 ) && (i % 2 != 0)  )
        {
            c++;
        }
    }

    cout<<c;
    return 0;
}


Measured memory_bytes: 3564
N, W = map(int, input().split())
w, v = [0]*N, [0]*N
for i in range(N):
    w[i], v[i] = map(int,input().split())
V = sum(v)
dp = [[float('inf')] * (V + 1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for value in range(V+1):
        if 0 <= value - v[i]:
            dp[i+1][value] = min(dp[i][value-v[i]]+w[i],dp[i][value])
        else:
            dp[i+1][value] = dp[i][value]
ans = 0
for i in range(V+1):
    if dp[N][i] <= W:
        ans = i
print(ans)

Measured memory_bytes: 308168
/*
* Author : Omkar Deshmukh
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define all(v) v.begin(), v.end()
#define intvect vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define boolv vector<bool>
#define ld long double
#define deb(x) cout << #x << " " << x << endl;
#define pb push_back
#define pob pop_back
#define F first
#define S second
#define ub upper_bound
#define bs binary_search
#define lb lower_bound
#define ull unsigned long long

// bool flag = 0;
// const ll mod = 1e9 + 7;
// const ll N = (ll)5e5 + 4;
// bool ans = 0;
template <typename... T>
void read(T &... args)
{
    ((cin >> args), ...);
}

template <typename... T>
void write(T &&... args) //rvalue references
{
    ((cout << args), ...);
}

void vjudge()
{
#ifndef ONLINE_JUDGE
    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void solve()
{
    int n;
    read(n);
    if (n >= 30)
        write("Yes");
    else
        write("No");
}

int32_t main()
{
    vjudge();
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}


Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(int loop_dump=0; loop_dump<(int)ar.size(); loop_dump++) cout << "[" << loop_dump << "]:" << ar[loop_dump] << endl
#define DUMPL(ar) for(int loop_dump=0; loop_dump<(int)ar.size(); loop_dump++) { cout << ar[loop_dump]; if(loop_dump<(int)ar.size()-1) cout << ' '; } cout << endl;
#define COUT(x) cout << x << endl
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl
using namespace std;

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

    int a, b, k;
    cin >> a >> b >> k;
    for(int i=0; i<k; i++){
        if(i % 2 == 0){
            if(a % 2 == 1){
                a--;
            }
            b += a /= 2;
        }else{
            if(b % 2 == 1){
                b--;
            }
            a += b /= 2;
        }
    }

    cout << a << ' ' << b << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
  var c [3][3]byte

  scanner := bufio.NewScanner(os.Stdin)
  count := 0
  for scanner.Scan() {
    line := scanner.Text()
    c[count][0] = line[0]
    c[count][1] = line[1]
    c[count][2] = line[2]
    count++
    if count == 3 {
      break
    }
  }
  fmt.Printf("%c%c%c\n", c[0][0], c[1][1], c[2][2])
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define INF -50001
int main(){
int n,m;
cin>>n>>m;
//n本　i回目 残りk本
vector<vector<vector<int> > > dp(n+2,vector<vector<int> >(m+1,vector<int>(9,INF)));
dp[0][m][0]=0;
//for(int i=0;i<9;i++)for(int j=0;j<m+2;j++)for(int k=0;k<m+1;k++)cout<<dp[i][j][k]<<' ';
vector<int> a(n),b(n),c(n);
for(int i=0;i<n;i++){
int d,e,f;
cin>>d>>e>>f;
a[i]=d;
b[i]=e;
c[i]=f;
//cout<<a[i]<<' '<<b[i]<<' '<<c[i]<<endl;
}
for(int i=0;i<n;i++){
	for(int j=0;j<m+1;j++){
		for(int k=0;k<9;k++){
			int tmp =dp[i][j][k];
			if(tmp==INF)continue;
			for(int l=0;l<min(j,8)+1;l++){
				for(int x = 0;x<=l;x++){
					for(int y=0;y<=min(k,8-x);y++){
						int cost=0;
						if(x+y==0)cost=c[i];
						else cost=x*a[i]+y*b[i];
						dp[i+1][j-l][l]=max(dp[i+1][j-l][l],dp[i][j][k]+cost);
					}
		
				}

			}
		//	else cout<<i<<' '<<j<<' '<<k<<endl;
			/*for(int t=0;t<9;t++){
				int tmp2;
				if(t+k<=8)tmp2 =t*max(a[i],0)+k*max(b[i],0);
				else tmp2=max((8-k)*max(a[i],0)+k*max(b[i],0),t*max(a[i],0)+max((8-t),0)*b[i]);
				if(j-t>=0){
				int tmp3=0;
				if(tmp2==0)tmp3=c[i];
			 dp[i+1][j-t][t]=max(dp[i+1][j-t][t],tmp+max(tmp2+tmp3,c[i]));
				}
			}*/
		}
	}
}
int ans =INF;
for(int i=0;i<m+1;i++){
for(int j=0;j<9;j++){
	//cout<<dp[n-1][i][j]<<' '<<dp[n][i][j]<<' '<<i<<' '<<j<<endl;
	ans=max(dp[n][i][j],ans);
	
}

}


cout<<ans<<endl;


}



Measured memory_bytes: 3296
#include<bits/stdc++.h>
#include<string>
#define ll long long
#define lld long double
#define llu unsigned long long int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define mod 1000000007
#define mod1 998244353
#define pi 3.1415926535897
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("B-small-attempt0.in", "r", stdin);freopen("output.txt", "w", stdout);
    //std::cout << std::setprecision(9);
    //std::cout << std::fixed;
    ll n,i;
    cin>>n;
    ll a[n];
    gll(a,n);
    ll ans=0;
    for(i=1;i<n-1;i++)
    {
        if((a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]<a[i-1] && a[i]>a[i+1]))
            ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a, b;
  scanf("%d %d", &a, &b);
  if (a == b) {
    printf("%d\n", (a + a));
  }
  else if (a < b){
    printf("%d\n", (b + b - 1));
  }
  
  else {
   printf("%d\n", (a + a - 1)); 
  }
 
  return 0; 
}

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

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

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

	sort(h.begin(), h.end(), greater <ll> ());

	ll count = 0;
	for (int i = k; i < n; ++i)
	{
		count += h[i];
	}

	cout << count;
}


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

int main()
{
    int W, H, x, y, r;
    int minX, maxX;
    int minY, maxY;

    cin >> W >> H >> x >> y >> r;

    if ((x >= -100 && x <= 100) && (y >= -100 && y <= 100) &&
        (W > 0 && W <= 100) && (H > 0 && H <= 100) && (r > 0 && r <= 100)) {
            minX = x - r;
            maxX = x + r;

            minY = y - r;
            maxY = y + r;
            
            if (minX < 0 || maxX > W || minY < 0 || maxY > H ) {
                cout << "No" << endl;
            } else {
                cout << "Yes" << endl;
            }
    }

    return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int n, col[100007], dp1[100007], dp2[100007], rt, res, mx;
char s[100007];
vector<int>ee[100007], e[100007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int dfs1(int w, int f)
{
	bool is = col[w];
	for (int i = 0, lim = ee[w].size(); i < lim; i++)
		if (ee[w][i] != f)
		{
			bool ok = dfs1(ee[w][i], w);
			if (!ok)e[w].push_back(ee[w][i]), e[ee[w][i]].push_back(w);
			is &= ok;
		}
	return is;
}
int dfs2(int w, int f)
{
	int val = ((e[w].size() + col[w]) & 1) ? 0 : (res++, 2), mx1 = 0, mx2 = 0, is = 0;
	for (int i = 0, lim = e[w].size(); i < lim; i++)
		if (e[w][i] != f)
		{
			dfs2(e[w][i], w);
			is = 1;
			mx = max(mx, max(dp1[e[w][i]] + mx2, dp2[e[w][i]] + mx1) + val);
			mx1 = max(mx1, dp1[e[w][i]]);
			mx2 = max(mx2, dp2[e[w][i]]);
		}
	dp1[w] = mx1 + val;
	dp2[w] = is ? mx2 + val : -1e9;
	return 0;
}
int main()
{
	n = read();
	for (int i = 2; i <= n; i++)
	{
		int a = read(), b = read();
		ee[a].push_back(b);
		ee[b].push_back(a);
	}
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i++)
		if (s[i] == 'B')col[i] = 1;
		else rt = i;
	if (!rt) { cout << 0 << endl; return 0; }
	dfs1(rt, 0);
	for (int i = 1; i <= n; i++)
		res += e[i].size();
	dfs2(rt, 0);
	cout << res - mx << endl;
	return 0;
}

Measured memory_bytes: 20224
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Main
{
    public static class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            int[] ab = GetIntList(Console.ReadLine());
            var a = ab[0];
            var b = ab[1];
            var answer = "NG";

            for(int i = 0;i<b;i++){
                var p = k*(i+1);
                if(a<=p && p<= b){
                    answer ="OK";
                    break;
                }
            }

            Console.WriteLine(answer);

 
        }
        #region libraries
        private static int[] GetIntList(string line)
        {
            return line.Split(' ').Select(x => int.Parse(x)).ToArray();
 
        }
        private static double[] GetDoubleList(string line)
        {
            return line.Split(' ').Select(x => double.Parse(x)).ToArray();
 
        }
        private static ulong[] GetUlongList(string line)
        {
            return line.Split(' ').Select(x => ulong.Parse(x)).ToArray();
        }
        private static long[] GetLongList(string line)
        {
            return line.Split(' ').Select(x => long.Parse(x)).ToArray();
        }
        private static int SearchNearest(this IEnumerable<int> list, int target)
        {
            var min = list.Min(c => Math.Abs(c - target));
            return list.First(c => Math.Abs(c - target) == min);
        }
        public static bool IsOdd(int i)
        {
            return i % 2 == 1 ? true : false;
        }
        public static int Gcd(int a,int b)
        {
            if(a < b)
            {
                Gcd(b, a);
            }
            while (b != 0)
            {
                var rm = a % b;
                a = b;
                b = rm;
            }
            return a;
        }
        #endregion libraries
    }
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task "A"

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;

vector<int> adj[maxn];
int N, M;
int a[maxn];
bool vis[maxn];
int cnt[maxn];
vector<int> pos, val;

void dfs(int u)
{
    pos.pb(u); val.pb(a[u]);
    vis[u] = 1;
    for (int v : adj[u]){
        if (!vis[v]) dfs(v);
    }
}

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }

    cin >> N >> M;
    for (int i=1; i<=N; ++i)
        cin >> a[i];
    while (M--){
        int u, v;
        cin >> u >> v;
        adj[u].pb(v); adj[v].pb(u);
    }
    int res = 0;
    for (int i=1; i<=N; ++i){
        if (!vis[i]){
            pos.clear(); val.clear();
            dfs(i);
            for (auto it : pos){
                cnt[it]++;
            }
            for (auto it : val){
                res += cnt[it];
            }
            for (auto it : pos)
                cnt[it] = 0;
        }
    }
    cout << res << '\n';
}


Measured memory_bytes: 10532
#include <stdio.h>

int main(){
  for(;;){
    int H,W,x,y,z,w;
    scanf("%d %d",&H ,&W);
    if(H==0 && W==0){
      return 0;
    }
    for(x=0;x<W;x++){
      printf("#");
    }
    printf("\n");
    for(z=0;z<(H-2);z++){
      printf("#");
      for(y=0;y<(W-2);y++){
      printf(".");
      }
      printf("#");
      printf("\n");
    }
    for(w=0;w<W;w++){
      printf("#");
    }
    printf("\n");
    printf("\n");
  }
}

Measured memory_bytes: 2536
import java.io.*;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while (!(buf = br.readLine()).equals("0")) {
				int n = Integer.parseInt(buf);
				int mat[][] = new int[n][n];
				int sq[][] = new int[n][n];
				int max = 0;
				for (int i=0;i<n;i++) {
					String str = br.readLine();
					for (int j=0;j<n;j++) {
						if (str.charAt(j)=='.') mat[i][j] = 1;
						else mat[i][j] = 0;
					}
					sq[i][0] = mat[i][0];
					if (max<sq[i][0]) max = sq[i][0];
				}
				for (int i=1;i<n;i++) {
					sq[0][i] = mat[0][i];
					if (max<sq[0][i]) max = sq[0][i];
				}
				for (int i=1;i<n;i++) {
					for (int j=1;j<n;j++) {
						if (mat[i][j]==0) {
							sq[i][j] = 0;
						} else {
							int min = (sq[i-1][j]<sq[i][j-1]) ? sq[i-1][j] : sq[i][j-1];
							min = (min<sq[i-1][j-1]) ? min : sq[i-1][j-1];
							sq[i][j] = min+1;
							if (max<sq[i][j]) max = sq[i][j];
						}
					}
				}
				System.out.println(max);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 56768
#include<bits/stdc++.h>
using namespace std;
int main(){
	long N;cin>>N;
	long sum=0;long j;
	for(long i=1;i*i<=N;i++){
		if(N%i==0){
			j=N/i;
			if(j-i>=2){
				sum+=j-1;
			}else{
				break;
			}
		}
	}cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
const double PI = 3.14159265359;

int main(void) {
	int n, k, q; cin >> n >> k >> q;
	vector<ll> v(q);
	vector<ll> aa(n, k);
	ll xx = 0;
	rep(i, q) {
		cin >> v[i];
		aa[v[i] - 1]++;
		xx++;
	}
	rep(i, n) {
		if (aa[i]-xx <= 0)cout << "No" << endl;
		else cout << "Yes" << endl;	
	}
	return 0;
}

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

int main() {
  ll N, M = 2, ret = 0;
  cin >> N;

  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 1; M <= N; i++) {
    M *= 5;
    ret += N / M;
  }
  cout << ret << endl;
}

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

int main(void)
{
    int L, R, d;

    cin >> L >> R >>d;

    int ans = 0;

    for(int i = L; i <= R; ++i)
    {
        if(i%d == 0) ++ans;
    }

    cout << ans << endl;

    

    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int sum1 = vec.at(0);
  int sum2 = vec.at(1);
    
  for (int i = 2; i < N; i+= 2) sum1 += vec.at(i);
  for (int i = 3; i < N; i+= 2) sum2 += vec.at(i);

  cout << sum1 - sum2 << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;
set<int> st = { 0, 1, 6, 8 };

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	n %= 10;
	if (n == 3) cout << "bon\n";
	else if (st.count(n)) cout << "pon\n";
	else cout << "hon\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#define MAX 1000000
using namespace std;
string a,b,z;
int d;
string ans;
bool flgA[MAX];
bool flgB[MAX];

void rec(int x){

  ans.push_back('(');

  if(flgA[x*2]==true){
    rec(x*2);
  }
  ans.push_back(',');
  if(flgA[x*2+1]==true){
    rec(x*2+1);
  }

  ans.push_back(')');
}


int main(){
  while(cin>>z){

    cin>>a;
    for(int i=0;i<MAX;i++)flgA[i]=flgB[i]=false;
    flgA[1]=flgB[1]=true;
    
    d=1;
    for(int i=0;i<(int)a.size();i++){
      if(d>=MAX)continue;
      if(a[i]=='('){
	flgA[d]=true;
	d*=2;
      }else if(a[i]==','){
	d=d+1;
      }else{
	d/=2;
      }
    }
    
      cin>>b;
      d=1;
      for(int i=0;i<(int)b.size();i++){
	if(d>=MAX)continue;
      if(b[i]=='('){
	flgB[d]=true;
	d*=2;
      }else if(b[i]==','){
	d=d+1;
      }else{
	d/=2;
      }
    }
    

    for(int i=0;i<MAX;i++){
      if(flgB[i]==false){
	if(z=="i"){
	  flgA[i]=false;
	}
      }else{
	if(z=="u"){
	  flgA[i]=true;
	}
      }
    }

    ans="";
    rec(1);
    cout<<ans<<endl;

  }
  return 0;
}

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

int main(){
  vector<int> A;
  int a;
  for(int i=0;i<3;i++){
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(),A.end());
  if(A[0]==A[1] && A[1]!=A[2]){
   cout << "Yes" << endl;
  }
  else if(A[1]==A[2] && A[0]!=A[1]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  int N,count=0,c,e,f;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L.at(i);
  }
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  for(int x=0;x<N-2;x++){
    for(int y=x+1;y<N-1;y++){
      for(int z=y+1;z<N;z++){
        if(L.at(x)<L.at(y)+L.at(z)){
          count++;
          //cout<<"ok:";
        }else{
          break;
        }
        //cout<<L.at(x)<<" "<<L.at(y)<<" "<<L.at(z)<<endl;
      }
    }
  }
  cout<<count<<endl;
  return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    char a;
    cin >> a;
    if (isupper(a)) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for(int i=(a);i<(b);++i)
#define foreach(i, n) for (__typeof(n.begin()) i = n.begin(); i != n.end(); ++i)
#define sqr(x) ((x)*(x))
#define clr(a, b) memset(a, b, sizeof(a))
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
#define all(a) (a).begin(),(a).end()
#define inf 0x3f3f3f3f
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-8;
int dcmp(double x) { if (x < -eps) return -1; else return x > eps;}
#define se(x) cout<<#x<<" = "<<x<<endl

#ifdef CHEN_PC
	#define debug(...) printf(__VA_ARGS__)
	// #define debug(...)
#else 
	#define debug(...)
#endif

const int N = 200010;
const int mod = 1000000007; // 10^9+7
int n;
char str[N];

int solve(char *s) {
	n = strlen(s);
	s--;
	if (s[n] == '1' || s[1] == '0') {
		printf("-1\n");
		return 0;
	}
	forab (i, 1, n)  {
		debug("%c", s[i]);
		if (s[i] != s[n - i]) {
			printf("-1\n");
			return 0;
		}
	}
	debug("\n");
	vector<pii> ans;
	int cur = 2;
	int rt = 1;
	forab (i, 1, n) {
		if (s[i] == '1') {
			ans.push_back(MP(rt, cur));
			rt = cur;
		} else {
			ans.push_back(MP(rt, cur));
		}
		cur++;
	}
	forn (i, SZ(ans)) {
		printf("%d %d\n", ans[i].first, ans[i].second);
	}
	return 1;
}

int main(int argc, char *argv[]) {
#ifdef CHEN_PC
	freopen("E.in", "r", stdin);
#endif

	while (scanf("%s", str) != EOF) {
		solve(str);
		debug("\n");
		// int ret = solve();
		// printf("%d\n", ret);
	}
	return 0;
}



Measured memory_bytes: 2420
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

##* union-find
##pre union_find
class UnionFind:
    def __init__(self, node_count):
        self.group_count = node_count
        self.par = [-1] * node_count
    def root(self, x):
        if self.par[x] < 0:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]
    def connect(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        self.group_count -= 1
        if self.par[y] < self.par[x]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x
        return True
    def same(self, x, y):
        return self.root(x) == self.root(y)
    def get_size(self, x):
        return -self.par[self.root(x)]
    def get_groupsize(self):
        return self.group_count


n,m=getints()
uf = UnionFind(n)

for i in range(m):
    x,y,_=getints()
    uf.connect(x-1,y-1)

print(uf.group_count)


Measured memory_bytes: 5716
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int inf = 1 << 30;

int main()
{
	int N, X, Y;
	cin >> N >> X >> Y;
	--X;
	--Y;

	vector<vector<int>> d(N, vector<int>(N, inf));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			d[i][j] = abs(j - i);
			d[i][j] = min(d[i][j], abs(X - i) + abs(j - Y) + 1);
			d[i][j] = min(d[i][j], abs(Y - i) + abs(j - X) + 1);
		}
	}

	vector<int> ans(N);
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			++ans[d[i][j]];
		}
	}
	for (int k = 1; k < N; ++k) {
		cout << ans[k] << endl;
	}
}


Measured memory_bytes: 16000
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  cin >> N;
  if (N%2==1){
    cout << 0 << endl;
    return 0;
  }
  ll num5 = N;
  ll bunbo = 10;
  ans = 0;
  while(bunbo <= N){
    ans += N/bunbo;
    bunbo*=5;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;


int main(){
  ll N,ans=0,a;cin>>N;
  REP(i,0,N){
    cin>>a;
    ans+=a-1;
  }
  print(ans)

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
map<string,int>mp;
vector<string>vec;

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(mp.count(s)==0){
      vec.push_back(s);
      mp[s]=1;
    }
    else{
      mp[s]++;
    }
  }
  sort(vec.begin(),vec.end());
  int mx=0;
  for(int i=0;i<vec.size();i++){
    mx=max(mx,mp[vec[i]]);
  }
  for(int i=0;i<vec.size();i++){
    if(mp[vec[i]]==mx){
      cout<<vec[i]<<endl;
    }
  }
  return(0);
}


Measured memory_bytes: 28784
from operator import itemgetter

n = int(input())
S = []
P = []
for i in range(n):
    s, p = map(str, input().split())
    S.append(s)
    P.append(int(p))

def index_Multi(List,liter):
    index_L = []
    for val in range(0,len(List)):
        if liter == List[val]:
            index_L.append(val)
    return index_L

for i in sorted(set(S)):
    indexes = index_Multi(S, i)
    L = []
    d = {}
    for j in indexes:
        d[j+1] = P[j]
    d = sorted(d.items(), key=lambda x:x[1], reverse=True)
    for k in d:
        print(k[0])

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

int cnt[10][10];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    FOR(i,1,N){
        string s = to_string(i);
        int x = s[0]-'0';
        int y = s[s.size()-1]-'0';
        cnt[x][y]++;
    }
    ll ans=0;
    rep(i,10)FOR(j,0,9){
        ans+=(ll)cnt[i][j]*cnt[j][i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3700