akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
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;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B, C;
  cin >> A >> B >> C;
  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
    print(0);
  else
    print(min({A * B, B * C, C * A}));
}

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

int main() {
  int k,m,d;
  string today[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
  int mon[12]={31,29,31,30,31,30,31,31,30,31,30,31};

  while(cin >>m>>d){
    if(m==0)break;

    for(int i=0;m-1>i;i++) d+=mon[i];

    k=d%7+2;
    cout <<today[k%7]<<endl;

  }
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
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> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}

	struct Store {
	public:
		int index;
		std::string name;
		int point;
	};
}

int main() {

	int n;
	std::cin >> n;
	std::vector<Store> stores(n);
	rep(i, n) {
		std::cin >> stores[i].name >> stores[i].point;
		stores[i].index = i + 1;
	}

	std::sort(allof(stores), [](Store lhs, Store rhs) {
		if (lhs.name == rhs.name) return lhs.point > rhs.point;
		return lhs.name < rhs.name;
		});

	rep(i, n) std::cout << stores[i].index << std::endl;

	return 0;
}

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

string S;
int alpha[27], tmp[27];

int main()
{
    int N;
    cin >> N;

    for(int i=0; i<26; i++)
        alpha[i] = 55;

    while(N--)
    {
        cin >> S;

        memset(tmp, 0, sizeof(tmp));

        for(int i=0; i<S.size(); i++)
            tmp[S[i]-'a']++;

        for(int i=0; i<26; i++)
            alpha[i] = min(alpha[i], tmp[i]);
    }

    for(int i=0; i<26; i++)
        while(alpha[i])
    {
        printf("%c", (char)(i+'a'));
        alpha[i]--;
    }
    
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a, b, c, d;

int main() {
	cin >> n >> a >> b >> c >> d;
	int na = (n / a + (n%a == 0 ? 0 : 1));
	int nc = (n / c + (n%c == 0 ? 0 : 1));
	cout << min(na*b , nc*d) << endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int n,x,a[110];
    scanf("%d%d",&n,&x);
    int i,sum=0;
    for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            sum=sum+a[i];
        }
        int remains,cont=0;
        if(x>=sum)
        cont=n;
        remains=x-sum;
        int mi=a[0];
        for(i=0;i<n;i++)
        {
           if(a[i]<mi)
                mi=a[i];
        }
 
   cont=cont+remains/mi;
   printf("%d",cont);
 
    return 0;
}


Measured memory_bytes: 256
n , m= map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
mod = 10**9+7
def f(N,i):
  return (i*(N-i+1))%mod
def l(L,i):
  return (L[i]-L[i-1])%mod
def lf(L):
  N = len(L)
  return sum([(l(L,i)*f(N-1,i))%mod  for i in range(1,N)])
print(lf(x)*lf(y)%mod)

Measured memory_bytes: 18576
#include <stdio.h>

int main(void){
	int i,j,n;
	int rt[200000],maxmin;
	int maxv,minv;
	int min;
	scanf("%d",&n);
	scanf("%d",&rt[0]);
	scanf("%d",&rt[1]);
	minv=rt[0];
	maxv=rt[1]-rt[0];
	if(rt[1]<minv) minv=rt[1];
	for(i=2;i<n;i++){
		scanf("%d",&rt[i]);
		if(rt[i]-minv>maxv){
			maxv=rt[i]-minv;
		}
		if(rt[i]<minv){
			minv=rt[i];
		}
	}
	printf("%d\n",maxv);
	return 0;
}

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

#define lp(i,n) for(int i=0;i<n;i++)
using namespace std;
int ans[100000],check[100000];
int main(){
  int n;
  cin>>n;
  deque<int> d;
  lp(i,n){
    int a,b,c;
    cin>>a;
    if(a==0){
      cin>>b>>c;
      if(b==0) d.push_front(c);
      if(b==1) d.push_back(c);
    }
    if(a==1){
      cin>>b;
      cout<<d[b]<<endl;
    }
    if(a==2){
      cin>>b;
      if(b==0)d.pop_front();
      if(b==1)d.pop_back();
    }
  }
      
  return 0;
}


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

const int mn=2e5+7;
int a[mn],n;
long long ans;

bool cmp(int a,int b) {return a>b;}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%d",a+i);
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;++i) ans+=a[(i+1)/2];
    printf("%lld",ans-a[1]);
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    int ans;
    for(int i = 1; i*i < n+1; i++){
        ans = i*i;
    }
    std::cout << ans;
    return 0;
}

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

#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
#define CLR(arr,val) memset(arr,val,sizeof(arr))

typedef long long LL;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    int ans1=n,ans2=n;
    for(int i=0;i<n;i++){
        if(s[i]=='0') ans1=min(ans1,max(i,n-i-1));
        else ans2=min(ans2,max(i,n-i-1));
    }
    cout<<max(ans1,ans2)<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#define ll long long
using namespace std;

int main()
{
    char s[110];
    ll l;
    while(~scanf("%s",s))
    {
        ll cnt=0;
        l=strlen(s);
        for(ll i=0;i<l/2;i++)
        {
            if(s[i]!=s[l-i-1])
                cnt++;
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
list = []
for i in range(n):
    a,b=input().split()
    list.append([a, int(b)])
lol=[]
S=0
H=13
C=26
D=39
for v in range(n):
    
    if list[v][0]=="S":
        list[v][0]=0
    elif list[v][0]=="H":
        list[v][0]=13
    elif list[v][0]=="C":
        list[v][0]=26
    else:
        list[v][0]=39
    lol.append((list[v][0])+list[v][1])
for i in range(1,53):
    if not (i in lol):
        if i<=13:
            print("S",i)
        elif i<=26:
            print("H",i-13)
        elif i<=39:
            print("C",i-26)
        else:
            print("D",i-39)


Measured memory_bytes: 5620
A[5][4][11],N,i,j,k,t;
main(void){
    for(scanf("%d",&N);scanf("%d%d%d%d",&i,&j,&k,&t),N--;A[i][j][k]+=t);
    for(i=1;i<5;i++){
        for(j=1;j<4;j++)
            for(k=1;k<11;k++)
                printf(" %d%s",A[i][j][k],k==10?"\n":"");
        if(i<4)
        puts("####################");
    }
}

Measured memory_bytes: 1792
#include<iostream>
#define ll long long int
#define ld long long double
using namespace std;

int main(){
  ll n;
  cin >> n;
  ll a[n];
  for(int i = 0; i < n; ++i)
    cin >> a[i];
  ll sum = 0, mul = 1;
  for(int i = 0; i < n; ++i){
    for(int j = i + 1; j < n; ++j){
      mul = a[i] * a[j];
      sum += mul;
    }
  }
  cout << sum;
  return 0;
}

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

typedef long long int64;

int main() {
  int64 n;
  scanf("%lld", &n);

  int64 *h = new int64[n];

  for(int i = 0; i < n; i++){
    scanf("%lld", &h[i]);
  }

  if(h[0] > 0) h[0] -= 1;
  int64 max = h[0];
  int no = 0;
  for(int i = 1; i < n; i++){
    if(h[i] > max){
      h[i] -= 1;
      max = h[i];
    }

    if(h[i-1] > h[i]) {
      no = 1;
      break;
    }
  }

  if(no) printf("No\n");
  else printf("Yes\n");

  delete [] h;

  return 0;
}

Measured memory_bytes: 1024
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/01/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N,A,B,C,D; cin>>N>>A>>B>>C>>D;
  A--; B--; C--; D--;
  string S; cin>>S;

  auto solve = [&]() {
    char p = S[0];
    for (int i = 1; i < N; i++) {
      if (p == '#' and S[i] == '#') {
        if ((i >= min(A,C) and i <= max(A,C)) or (i >= min(B,D) and i <= max(B,D))) {
          return false;
        }
      }
      p = S[i];
    }
    if (A>B) {
      swap(A,B);
      swap(C,D);
    }
    if (C>D) {
      int i = max(B-1, A+1);
      char p[2] = {S[i], S[i+1]};
      i++;
      for (; i <= min(D, C-1); i++) {
        if (p[0] == p[1] and p[1] == S[i+1] and p[0] == '.') {
          return true;
        }
        p[0] = p[1];
        p[1] = S[i+1];
      }
      return false;
    }
    return true;
  };
  cout << (solve() ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 592
package main

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

func solve(sc *scanner, wr *bufio.Writer) {
	n := sc.getRunes()
	k := sc.getInt()

	dp := make([][][]int, len(n)+1)
	for i := range dp {
		dp[i] = make([][]int, 2)
		for j := range dp[i] {
			dp[i][j] = make([]int, k+1)
			for l := range dp[i][j] {
				dp[i][j][l] = 0
			}
		}
	}
	dp[0][0][0] = 1

	for i := 1; i <= len(n); i++ {
		num := int(n[i-1] - '0')
		if num == 0 {
			for j := 0; j <= k; j++ {
				dp[i][0][j] += dp[i-1][0][j]
			}
		} else {
			for j := 0; j <= k; j++ {
				if j < k {
					dp[i][0][j+1] += dp[i-1][0][j]
					dp[i][1][j+1] += dp[i-1][0][j] * (num - 1)
				}
				dp[i][1][j] += dp[i-1][0][j]
			}
		}
		for j := 0; j <= k; j++ {
			if j < k {
				dp[i][1][j+1] += dp[i-1][1][j] * 9
			}
			dp[i][1][j] += dp[i-1][1][j]
		}
	}

	ans := sum(dp[len(n)][0][k], dp[len(n)][1][k])
	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


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

int main(){
    int n;
    cin >> n;
    int count=1;
    int ans=0;
    int check=1;
    while(check!=0){
        count *=2;
        if(count>n){
            ans=count/2;
            check=0;
        } 
    }
    cout << ans << endl;
}


Measured memory_bytes: 3088
#import sys
#sys.setrecursionlimit(500000)　マージテクをちゃんとしていればこんなものはいらないはず……

class UF:
    #経路圧縮＋マージテクのunion find木
    def __init__(self,n):
        self.n = n
        self.parents = [-1] * (n+1) #1-indexedにするために１個足している
        self.rnks = [0] * (n+1)

    def find(self,n):
        if self.parents[n] < 0:
            return n
        else:
            return self.find(self.parents[n])


    def union(self,a,b):
        a_par = self.find(a)
        b_par = self.find(b)

        if a_par == b_par:
            return
        ##union by rank
        #if self.rnks[a_par] < self.rnks[b_par]: #ランクの高い方の根に低い方の根をつける　逆にしないように……！
        #    a_par,b_par = b_par,a_par
        #if self.rnks[a_par] == self.rnks[b_par]:
        #    self.rnks[a_par] += 1
        if self.size(a_par) < self.size(b_par): #parentsの値が負の数のとき、それはその木のサイズを表す。
            a_par,b_par = b_par,a_par
        self.parents[a_par] += self.parents[b_par]
        self.parents[b_par] = a_par

    def size(self,n):
        par = self.find(n)
        return abs(self.parents[par])

    def is_same(self,a,b):
        return self.find(a) == self.find(b)



def main():
    n,m,k = map(int,input().split())
    uf = UF(n)
    block_lst = [0 for _ in range(n+1)]
    friend_lst = [0 for _ in range(n+1)]
    #友達リスト部分
    for i in range(m):
        a,b = map(int,input().split())
        friend_lst[a] += 1
        friend_lst[b] += 1
        uf.union(a,b)
    #print(friend_lst)

    #ブロックリスト部分
    for i in range(k):
        c,d = map(int,input().split())
        if uf.is_same(c,d):#c,dが同じ友達候補グループにない限り、解答には影響しない！
            block_lst[c] += 1
            block_lst[d] += 1
    #print(block_lst)
    #メイン処理
    answer = []

    for i in range(1,n+1):
        f_o_f = uf.size(i)
        answer.append(f_o_f - friend_lst[i] - block_lst[i] - 1)


    print(" ".join(map(str,answer)))






if __name__ == '__main__':
    main()


Measured memory_bytes: 20348
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;

int modd=1e9+7;

vector<int> arr;
vector<vector<long long> > ans;

void update(int l, int r, long long sum){
    if(l>r) return;
    if(ans[l][r]!=-1) return;
    if(l==r) ans[l][r]=arr[l];
    else{
        update(l+1,r,sum-arr[l]); update(l,r-1,sum-arr[r]);
       ans[l][r]=sum-min(ans[l+1][r],ans[l][r-1]);
    }
}

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

    arr.resize(n); long long sum=0;
    for(int i=0; i<n; i++){ cin>>arr[i]; sum+=arr[i]; }

    ans.resize(n);
    vector<long long> temp(n); for(int i=0; i<n; i++) temp[i]=-1;
    for(int i=0; i<n; i++){
        ans[i]=temp;
    }

    update(0,n-1,sum);
    cout<<2*ans[0][n-1]-sum<<endl;

}


Measured memory_bytes: 70912
#include<iostream>
#include<queue>
#include<stdlib.h>
#include<string.h>
using namespace std;

const static int MAX=1000;

char map[MAX][MAX];
int H,W,N;

int startx,starty;
int nextx[4]={0,0,1,-1},nexty[4]={1,-1,0,0};

bool bmap[MAX][MAX];

int res=0,now=1;

void input()
{
	cin>>H>>W>>N;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			cin>>map[i][j];
			if(map[i][j]=='S')
			{
				startx=i;
				starty=j;
			}
		}
	} 
}

int solve()
{
	memset(bmap,0,sizeof(bmap));
	queue<pair<int,int> >q;
	queue<int>dis;
	q.push(make_pair(startx,starty));
	dis.push(0);
	bmap[startx][starty]=true;
	while(!q.empty())
	{
		pair<int,int> tpos=q.front();
		q.pop();
		int tdis=dis.front();
		dis.pop();
		if(atoi(&map[tpos.first][tpos.second])==now)
		{
			
			startx=tpos.first;
			starty=tpos.second;
			now++; 
			return tdis;
		}
		for(int i=0;i<4;i++)
		{
			int tempx=tpos.first+nextx[i];
			int tempy=tpos.second+nexty[i];
			if(tempx>=0&&tempx<H&&tempy>=0&&tempy<W&&map[tempx][tempy]!='X'&&!bmap[tempx][tempy])
			{
				bmap[tempx][tempy]=true;
				q.push(make_pair(tempx,tempy));
				dis.push(tdis+1);
			}
		}
	}
}

int main()
{
	input();
	for(int i=0;i<N;i++)
	{
		res+=solve();
	}
	cout<<res<<endl;
	return 0; 
}





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

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while((line = in.readLine()) != null){
			if(line.equals("0")) break;

			int l = line.length();
			int[] game = new int[l];
			for(int i=0; i<l; i++){
				game[i] = (line.substring(i, i+1).equals("A")) ? 0 : 1;
			}
			
			int[] point = new int[]{ 0, 0 };
			int server = game[0];
			for(int i=1; i<l; i++){
				point[game[i]]++;
				if(server != game[i]){
					server = game[i];
				}
			}
			
			if(point[0] > point[1]){
				point[0]++;
			}
			else{
				point[1]++;
			}
			
			System.out.printf("%d %d\n", point[0], point[1]);
		}
	}
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(x) push_back(x)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int  main() {
	
	int n;
	deque<ll>v;
	string s;

	cin >> n;

	rep(i, n) {
		ll a;
		cin >> a;
		if(i % 2 != n %2)v.push_front(a);
		else v.push_back(a);
	}
	
	rep(i, n) {
		if (i != 0)cout << ' ';
		cout << v[i];
	}

	cout << endl;

	return 0;

}

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

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n; cin >>n; int ac=0,wa=0,tle=0,re=0;
  while(n--){
    string s; cin >>s;
    if(s=="AC") ac++;
    else if(s=="WA") wa++;
    else if(s=="TLE") tle++;
    else re++;
  }
  cout <<"AC x "<<ac<<endl;
  cout <<"WA x "<<wa<<endl;
  cout <<"TLE x "<<tle<<endl;
  cout <<"RE x "<<re<<endl;
return 0;}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;

vector<vector<int>> edges;

void update(vector<int> &tree, vector<bool> &tree_check, int root, int accm) {
    if (tree_check[root])
        return;
    tree_check[root] = true;
    tree[root] += accm;
    vector<int> child = edges[root];
    // for (std::vector<int>::iterator it = child.begin() ; it != child.end(); ++it) {
    for (auto it = child.begin() ; it != child.end(); ++it) {
        update(tree, tree_check, *it, tree[root]);
    }
}

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

    edges.resize(n + 1);
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> tree(n + 1);
    vector<bool> tree_check(n + 1);
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        tree[p] += x;
    }
    for (int i = 1; i <= n; i++) {
        tree_check[i] = false;
    }

    update(tree, tree_check, 1, 0);
    for (int i = 1; i <= n; i++) {
        cout << tree[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 32896
#include<bits/stdc++.h>
#define p 1000000007
#define ll long long
using namespace std;
ll n,k; 
ll a[2010];
ll tot[2010];
ll f[2010];
ll ans=0;
int main()
{
	cin>>n>>k;
	for(ll i=1;i<=n;i++) cin>>a[i];
	for(ll i=1;i<=n;i++)
	for(ll j=1;j<=n;j++)
	if(a[i]>a[j])
	{
		tot[i]++;
		if(i<j) f[i]++;
	}
	for(ll i=1;i<=n;i++)
	ans+=(k*(k-1)/(ll)2)%(ll)p*tot[i]%(ll)p,ans%=(ll)p,ans+=f[i]*k,ans%=(ll)p;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  string s;
  cin >> s;
  set<char> st;
  rep(i, s.size()) st.insert(s[i]);
  if (st.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 1e9;
  for (auto e : st) {
    string s1 = s;
    while (1) {
      string s2;
      bool flag = true;
      rep(i, s1.size()-1) {
        if (s1[i] == e || s1[i+1] == e)
          s2 += e;
        else {
          s2 += s1[i];
          flag = false;
        }
      }
      if (flag) {
        chmin(ans, int(s.size()-s2.size()));
        break;
      } else
        s1 = s2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005];
vector< ll > adj[100005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first
#define mp make_pair

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    string s;
    cin >> s;
    string k = s;
    ll ctr = 0;
    sort(s.begin(), s.end());
    for(int i = 0 ; i < n ; i++){
    	if( s[i] == 'R' and k[i] != 'R' )
    		ctr++;
    }
    cout << ctr << endl;
	return(0);
}


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

main(){
  int a,b,c,d,e,f;
  cin>>a;
  b=a/100;
  c=a-b*100;
  d=c/10;
  e=c-d*10;
  f=b+d+e;
  cout<<f<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll n;
void DFS(ll p,ll q,string s){
  if(p==n){
    cout << s << endl;
    return;
  }
  for(ll i=0;i<=q+1;i++){
    DFS(p+1,max(i,q),s+char('a'+i));
  }
}
/*文字列の長さ、最大の文字、現在の文字列の三変数でDFSを作る*/
int main() {
  cin >> n;
  DFS(0,-1,"");
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, gcd, ans;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> a >> b;
while (b){
	c=b;
	b=a%b;
	a=c;
}
gcd=a; ans++; 
for (int i=2;i<=sqrt(gcd); i++){
	if (gcd%i==0){
		ans++;
		while (gcd%i==0){
			gcd/=i;
		}
	}
}
if (gcd>1) ans++;
cout << ans;
return 0;
}

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

int main(void){
    int N,T;
    cin >> N >> T;
    int c[N],t[N];
    for(int i=0;i<N;i++) cin >> c[i] >> t[i];
    
    long long min_c = INF;
    
    for(int i=0;i<N;i++){
        if(t[i]<=T){
            if(min_c>c[i]) min_c = c[i];
        }
    }
    
    if(min_c==INF) cout << "TLE";
    else cout << min_c;
    
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  double n, k;
  cin >> n >> k;
  vector<double> sum(n);
  rep(i,n){
    double x;
    cin >> x;
    if(i>0) sum[i] += sum[i-1] + (x+1.0)/2;
    else sum[i] = (x+1.0)/2;
  }
  double ans = 0;
  if(ans<sum[k-1]) ans = sum[k-1];
  rep(i,n-k){
    double x = sum[i+k]-sum[i];
    if(ans<x) ans = x;
  }
  cout << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std ;
#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

int main() {

  int a , b ;
  string str ;
  cin >> a >> b ;
  cin >> str ;
  if( a + b + 1 != sz( str ) ){
    cout << "No\n" ;
    return 0 ;
  }

  vector < int > pos ;
  forn( int , i , 0 , sz( str ) ) {
    if( str[ i ] == '-' ) pos.pb( i ) ;
  }

  if( sz( pos ) == 1 && pos.back() + 1 == a + 1 ){
    cout << "Yes\n" ;
  } else cout << "No\n" ;

  return 0 ;;;;;
}


Measured memory_bytes: 256
def linked_merge_sort(l): #マージソート
    if len(l) == 1:
        return
    q, r = divmod(len(l), 2)
    left = [l.pop() for _ in range(q)]
    right = [l.pop() for _ in range(q + r)]
    
    linked_merge_sort(left)
    linked_merge_sort(right)
    
    left.reverse()
    right.reverse()
    while left and right:
        if left[-1] <= right[-1]:
            l.append(left.pop())
        else:
            l.append(right.pop())
    while left:
        l.append(left.pop())
    while right:
        l.append(right.pop())
    return

n,k=map(int,input().split())
p=list(map(int,input().split()))
linked_merge_sort(p)
ans = 0
for i in range(k):
    ans += p[i]
print(ans)


Measured memory_bytes: 73940
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

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

int H, W, K;
int sx, sy, gx, gy;

vector<string> s;
vector<vector<int>> dist;

signed main() {
  cin >> H >> W >> K;

  cin >> sx >> sy >> gx >> gy;
  sx--; sy--; gx--; gy--;

  s.resize(H);
  REP(i, H) cin >> s[i];


  dist = vector<vector<int>>(H, vector<int>(W, INF));
  dist[sx][sy] = 0;

  queue<pair<int, int>> q;
  q.emplace(sx, sy);

  while(!q.empty()){
    auto [x, y] = q.front(); q.pop();
    REP(i, 4){
      FOR(j, 1, K+1){
        int nx = x+dx[i]*j;
        int ny = y+dy[i]*j;
        if(OUT(0, nx, H) || OUT(0, ny, W)) break;
        if(s[nx][ny] == '@') break;
        if(dist[nx][ny] <= dist[x][y]) break;
        if(dist[nx][ny] > dist[x][y]+1){
          dist[nx][ny] = dist[x][y]+1;
          q.emplace(nx, ny);
        }
      }
    }
  }

  if(dist[gx][gy] == INF) dist[gx][gy] = -1;
  cout << dist[gx][gy] << "\n";

  return 0;
}


Measured memory_bytes: 19840
#include <cstdio>
#include <algorithm>

const int maxn = 100000 + 10;
int n, ans; char ss[maxn];

int main(int argc, const char *argv[])
{
  scanf("%d", &n);
  scanf("%s", ss);
  ans = 1;
  for(int i = 1; i < n; ++i) if( ss[i] != ss[i - 1] ) ++ans;
  return 0 & printf("%d\n", ans);
}

Measured memory_bytes: 256
answers = []

def get_answer(taro, hanako, answers)
  taro
  hanako
  temp_ans = []
  taro_sum = 0
  hanako_sum = 0
  taro.each do |t|
    taro_sum += t
  end
  hanako.each do |h|
    hanako_sum += h
  end
  taro.each do |t|
    hanako.each do |h|
      if (taro_sum - t + h) == (hanako_sum + t -h)
        temp_ans << [t, h, t+h]
        return answers << "#{t} #{h}"
      end
    end
  end
  return answers << (-1) if temp_ans.length == 0
  mini_num = 300
  temp_ans.each_with_index do |a, i|
    if mini_num < a[2]
      mini_num = a[2]
      mini_index = i
    end
  end
  return answers << "#{temp_ans[mini_index][0]} #{temp_ans[mini_index][1]}"

end


while true
  array = gets.chomp.split(" ").map(&:to_i)
  n = array[0].to_i
  m = array[1].to_i
  break if n == 0 && m == 0
  taro =[]
  hanako = []
  n.times do
    taro << gets.to_i
  end
  m.times do
    hanako << gets.to_i
  end
  answers = get_answer(taro, hanako, answers)
end

answers.each do |ans|
  puts ans
end

Measured memory_bytes: 8736
MAXA = 10**6+1
N = int(input())
A = list(map(int,input().split()))
A.sort()
A.append(0)
hurui = [0]*(MAXA)
ans = 0
for i in range(N):
    a = A[i]
    if hurui[a] == 0:
        if A[i] != A[i+1]:
            ans += 1
    else:
        continue
    for j in range(a,MAXA,a):
        hurui[j] = 1
print(ans)

Measured memory_bytes: 106128
#include<stdio.h>
#include<math.h>

typedef struct {
  double x, y;
} Point;

void print(Point );
void kock(int n, Point p1, Point p2){

  Point s, t, u;
  double rad = 60.0*(acos(-1)/180.0);

  if (n==0) return;

  s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;
  u.x = (t.x - s.x) * cos(rad) - (t.y - s.y ) * sin(rad) + s.x;
  u.y = (t.x - s.x) * sin(rad) + (t.y - s.y ) * cos(rad) + s.y;

  kock(n-1, p1, s);
  print(s);
  kock(n-1, s, u);
  print(u);
  kock(n-1, u, t);
  print(t);
  kock(n-1, t, p2);
}

int main(){
  Point p1, p2;
  int a;

  scanf("%d", &a);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  print(p1);
  kock(a, p1, p2);
  print(p2);

  return 0;
}
void print(Point p){
  printf("%.8f %.8f\n", p.x, p.y);
}



Measured memory_bytes: 2020
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;

	void run() {
		for (;;) {
			int N = sc.nextInt();
			if (N == 0) {
				return;
			}
			while (N-- > 0) {
				int x1 = sc.nextInt();
				int y1 = sc.nextInt();
				int z1 = sc.nextInt();
				int w1 = sc.nextInt();
				int x2 = sc.nextInt();
				int y2 = sc.nextInt();
				int z2 = sc.nextInt();
				int w2 = sc.nextInt();

				int a0 = x1 * x2 - y1 * y2 - z1 * z2 - w1 * w2;
				int b0 = x1 * y2 + x2 * y1 - w1 * z2 + z1 * w2;
				int c0 = x1 * z2 + x2 * z1 + w1 * y2 - y1 * w2;
				int d0 = x1 * w2 + x2 * w1 - z1 * y2 + y1 * z2;
				System.out.println(a0 + " " + b0 + " " + c0 + " " + d0);
			}
		}
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

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

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 18204
#include<cstdio>
int a[200005],b[100005],c[100005];
int main()
{
    int i,i0,n,m,p1,p2;
    while(scanf("%d",&n)!=EOF)
    {
        p1=p2=1;
        for(i=1;i<=n;i++)scanf("%d",&a[i]);
        for(i=1;i<=n;i++)
        {
            if(i&1)b[p1++]=a[i];
            else c[p2++]=a[i];
        }
        if(!(n&1))
        {
            for(i=p2-1;i;i--)printf("%d ",c[i]);
            for(i=1;i<p1;i++)
            {
                printf("%d",b[i]);
                if(i==p1-1)printf("\n");
                else printf(" ");
            }
        }
        else
        {
            for(i=p1-1;i;i--)printf("%d ",b[i]);
            for(i=1;i<p2;i++)
            {
                printf("%d",c[i]);
                if(i==p2-1)printf("\n");
                else printf(" ");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3712
def max_heapify(i):
    left = i * 2
    right = i * 2 +1
    
    if left <= H and A[left] > A[i]:
        largest = left
    else:
        largest = i
    if right <= H and A[right] > A[largest]:
        largest = right
    
    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        max_heapify(largest)

def build_maxheap():
    for i in range((H+1)//2, 0, -1):
        max_heapify(i)
    
H = int(input())
A = [None]
A.extend(list(map(int, input().split())))

build_maxheap()
print(" " + " ".join(map(str, A[1:])))


Measured memory_bytes: 64268
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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


//Tはアーベル群
template<class T> class WeightedUnionFind{
    std::vector<int> par;
    std::vector<int> rank;
    std::vector<int> membnum;
    std::vector<T> diff_weight;

public:
    WeightedUnionFind(){}
    WeightedUnionFind(int n, T UNITY = 0): par(n), rank(n), membnum(n), diff_weight(n){
        for(int i(0); i < n; ++i){
            par[i] = i;
            rank[i] = 0;
            membnum[i] = 1;
            diff_weight[i] = UNITY;
        }
    }

    void  resize(int n, T UNITY = 0){
        int m(par.size());
        par.resize(n);
        rank.resize(n, 0);
        membnum.resize(n, 1);
        diff_weight.resize(n, UNITY);
        for(int i(m); i < n; ++i) par[i] = i;
    }

    int find(int x){
        if(x == par[x]) return x;
        int r(find(par[x]));
        diff_weight[x] += diff_weight[par[x]];
        return par[x] = r;
    }

    T weight(int x){
        find(x);
        return diff_weight[x];
    }

    //weight(y) = weight(x) + w
    bool unit(int x, int y, T w){
        w += weight(x); w -= weight(y);
        x = find(x); y = find(y);
        if(x == y) return false;

        if(rank[x] < rank[y]){
            par[x] = y;
            diff_weight[x] = -w;
            membnum[y] += membnum[x];
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) ++rank[x];
            diff_weight[y] = w;
            membnum[x] += membnum[y];
        }
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int howmany(int x){ //同じグループに属すものの個数(自分を含む)
        return membnum[find(x)];
    }
};


int main(){
    int N, M; std::cin >> N >> M;
    WeightedUnionFind<int> wuf(N);
    int L, R, D;
    for(int i(0); i < M; ++i){
        std::cin >> L >> R >> D;
        --L; --R;
        if(wuf.same(L, R)){
            if(wuf.weight(R) - wuf.weight(L) != D){
                std::cout << "No" << std::endl;
                return 0;
            }
        }
        else wuf.unit(L, R, D);
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


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

using namespace std;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	
	string s;
	cin >> s;

	int c = 0;
	if (s[0] == '1')c++;
	if (s[1] == '1')c++;
	if (s[2] == '1')c++;

	cout << c << "\n";

	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BSmallAndLargeIntegers {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b, k;
        in >> a >> b >> k;
        set<int> S;
        FOR(i, 0, k) {
            S.insert(min(a + i, b));
            S.insert(max(b - i, a));
        }
        trav(x, S) {
            out << x << '\n';
        }
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BSmallAndLargeIntegers solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    for (;;) {
        int N, M; cin >> N >> M;
        if (N == 0 && M == 0) break;
        vector<int> A(N), W(M);
        for (auto &a : A) cin >> a;
        for (auto &w : W) cin >> w;
        set<Int> S;
        for (int i = 0, ma = pow(3, M); i < ma; i++) {
            int t = i;
            Int val = 0;
            for (int j = 0; j < M; j++) {
                val += (t % 3 == 0 ? 0 : t % 3 == 1 ? W[j] : -W[j]);
                t /= 3;
            }
            if (val >= 0) S.insert(val);
        }
        vector<int> rest;
        for (auto a : A) if (!S.count(a)) rest.push_back(a);
        if (rest.empty()) {
            cout << 0 << '\n';
        } else {
            Int ans = 1e18;
            auto f = [&](int x) {
                if (x <= 0 || x >= ans) return;
                bool ok = true;
                for (auto r : rest) {
                    if (!S.count(r - x) && !S.count(r + x) && !S.count(x - r)) {
                        ok = false;
                        break;
                    }
                }
                if (ok) ans = x;
            };
            for (auto a : S) {
                for (auto r : rest) {
                    f(r - a); // a + x == r
                    f(a - r); // a - x == r
                    f(r + a); // x - a == r
                }
            }
            if (ans == 1e18) ans = -1;
            cout << ans << '\n';
        }
    }
    return 0;
}



Measured memory_bytes: 4652
#include<iostream>
#include<cstdio>

using namespace std;

int sum[50];

int main()
{
    int n, m;
    int a, b;

    cin >> n >> m;
    for( int i = 0; i < m; i++)
    {
        scanf("%d%d", &a, &b);
        sum[a]++, sum[b]++;
    }
    for( int i = 1; i <= n; i++)
        cout << sum[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int W,H,x,y;
    scanf("%d%d%d%d",&W,&H,&x,&y);
    printf("%lf %d\n",double(W)*double(H)/2,x+x==W&&y+y==H);
}


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


typedef struct E_TAG{
    int type;
    int value;
} M;


int main(){
    while(true){
    int x,y,z;
    cin >> x >> y >> z;
    if(x==0&&y==0&&z==0) return 0;
    vector<vector<double> > DP(y+1,vector<double>(5001,0));
    vector<M> V;
    vector<int> R;

    for(int i=0;i<x;i++){
        int temp;
        cin >> temp;
        R.push_back(temp);
    }
    for(int i=0;i<y+1;i++){
        V.push_back({0,0});
    }
    for(int i=0;i<z;i++){
        int n,e,a;
        cin >> n >> e >> a;
        V[n] = {e,a};
    }
    DP[0][0] = 1.0;
    for(int i=0;i<V.size()-1;i++){
        for(int j=0;j<5001;j++){
            if(DP[i][j] == 0) continue;
            for(int z=0;z<R.size();z++){
                int nex = min(y,i+R[z]);
                int now = j;
                if(V[nex].type == 1) nex += V[nex].value;
                else if(V[nex].type == 2) now += V[nex].value;
                else if(V[nex].type == 3) now -= V[nex].value;
                if(now < 0) now = 0;
                if(nex > y) nex = y;
                DP[nex][now] += (DP[i][j] / R.size());
            }
        }
    }
    double out = 0;
    for(int i=0;i<5001;i++){
        out += i * DP[y][i];
    }
    cout << (int)out << endl;
    }
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

int main(){
	IOS;
	int q=1;
	//cin>>q;
	while(q--){
		string s,t;
		cin>>s>>t;
		int b=1,n=s.size();
		for(int i=0;i<n;i++){
			if(s[i]!=t[i])
				b=0;
		}	

		if(b)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3612