akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

struct Pos{
    int x,y;
    Pos(int x,int y):x(x),y(y){}
};

int H,W;
int Ch,Cw;
int Dh,Dw;
string field[1005];
int s[1005][1005];
int d[1000005];
bool v[1000005];
bool visited[1005][1005];
int id;
set<int> E[1000005];


void init(){
    id=0;
    for(int i=0;i<1000003;++i){
        d[i]=INF;
        v[i]=false;
    }
    for(int i=0;i<1003;++i){
        for(int j=0;j<1003;++j){
            s[i][j]=-1;
            visited[i][j]=false;
        }
    }
}

void bfs1(int sx,int sy){
    queue<Pos> que;
    que.push(Pos(sx,sy));
    s[sy][sx]=id;
    while(que.size()){
        Pos p=que.front();
        que.pop();
        visited[p.y][p.x]=true;
        for(int i=0;i<4;++i){
            int nx=p.x+dx[i],ny=p.y+dy[i];
            if(nx<0||nx>=W||ny<0||ny>=H)continue;
            if(visited[ny][nx])continue;
            if(s[ny][nx]!=-1)continue;
            if(field[ny][nx]=='#')continue;
            que.push(Pos(nx,ny));
            s[ny][nx]=id;
        }
    }
    id++;
}

void bfs2(int s){
    queue<int> que;
    que.push(s);
    d[s]=0;
    while(que.size()){
        int p=que.front();
        que.pop();
        v[p]=true;
        for(auto u:E[p]){
            if(v[u])continue;
            //if(d[u]!=INF)continue;
            v[u]=true;
            que.push(u);
            d[u]=d[p]+1;
        }
    }
}

signed main(){
    init();
    cin>>H>>W;
    cin>>Ch>>Cw;
    cin>>Dh>>Dw;
    Ch--,Cw--;
    Dh--,Dw--;
    for(int i=0;i<H;++i)cin>>field[i];
    for(int y=0;y<H;++y){
        for(int x=0;x<W;++x){
            if(field[y][x]=='#')continue;
            if(s[y][x]!=-1)continue;
            bfs1(x,y);
        }
    }
    for(int y=0;y<H;++y){
        for(int x=0;x<W;++x){
            if(field[y][x]=='#')continue;
            for(int i=-2;i<=2;++i){
                for(int j=-2;j<=2;++j){
                    int nx=x+i,ny=y+j;
                    if(nx<0||nx>=W||ny<0||ny>=H)continue;
                    if(s[ny][nx]==s[y][x])continue;
                    if(field[ny][nx]=='#')continue;
                    E[s[y][x]].insert(s[ny][nx]);
                    E[s[ny][nx]].insert(s[y][x]);
                }
            }
        }
    }
    bfs2(s[Ch][Cw]);
    if(d[s[Dh][Dw]]==INF)cout<<-1<<endl;
    else cout<<d[s[Dh][Dw]]<<endl;
}

Measured memory_bytes: 88508
#include<stdio.h>

int main(void){
	//ax+by=c
	//dx+ey=f
	double a,b,c,d,e,f,x,y;
	while((scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f))!=EOF){
	y = (c*d-a*f)/(b*d-a*e)+0.00001;
	x = (c-b*y)/a+0.000001;
	printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = RInt();
            string a = RSt();
            string b = RSt();
            string c = RSt();

            int cnt = 0;

            for (int i = 0 ; i < n ; i++)
            {
                if (a[i] == b[i] && b[i] == c[i] && c[i] == a[i]) continue;
                if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) cnt++;
                else cnt += 2;
            }

            Console.WriteLine(cnt);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


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

int buka[200001];
int main() {
  int n;
  cin >> n;
  rep(i, n) buka[i] = 0;
  rep(i, n-1) {
    int a;
    cin >> a;
    buka[a-1]++;
  }
  rep(i, n) cout << buka[i] << endl;
  return 0;
}

Measured memory_bytes: 4416
# include "iostream"
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  long long L[90];
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i < n + 1; i++) L[i] = L[i - 2] + L[i - 1];
  printf("%lld\n", L[n]);
}

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

using namespace std;

int main() {

    int q;
    cin >> q;

    while ( q-- ) {

	unsigned int b;
	cin >> hex >> b;

	double res = (b&0x7fffffff) >> 7;//整数部の値で初期化
	
	//小数部を加算
	double frac = 0.5;
	for ( int i=6; i>=0; --i ) {
	    if ( (b>>i)&1 ) res += frac;
	    frac *= 0.5;
	}

	//フォーマット
	stringstream ss;
	ss << setprecision(15) << fixed << res;
	string s = ss.str();
	for ( int i=s.size()-1; i>0; --i ) {
	    if ( s[i] != '0' ) {
		s.erase( i+1, s.size() );
		break;
	    }
	}
	     
	cout << ((b>>31)?"-":"") << s << ((b&0x0000007f)?"":"0") << endl;
    }

    return 0;
}



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

int main() {
  string inp;
  
  cin >> inp;
  
  if ( (inp[0] == inp[1] && inp[1] == inp[2]) ||
      (inp[1] == inp[2] && inp[2] == inp[3]) )
    cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		String str[] = br.readLine().split("");

		long sum = 0;

		for (int i = 0; i < str.length; i++) {
			int num = Integer.parseInt(str[i]);
			sum += num;
		}

		if (sum % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 50176
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
using namespace std;
#define len(n) (int)n.length()
#define dump cout
#define pb push_back
#define ll long long

int main()
{
	ios::sync_with_stdio(false);
		
	
	int n, q;
	ll s[10000] = {0};
	ll t[10000] = {0};
	
	cin >> n;
	for (int i = 0; i < n; i++) {
	    cin >> s[i];
	}
	cin >> q;
	ll c = 0;
	for (int i = 0; i < q; i++) {
		cin >> t[i];
		bool isFound = false;
	    for (int k = 0; k < n; k++) {
	        if (t[i] == s[k])
			{
				isFound = true;
				break;
			}
	    }
		if (isFound)
			c++;
	}
	cout <<  c << endl;
	
	
	return 0;
}

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

using namespace std;
typedef long long ll;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string n,m;
    cin>>n>>m;

    int size_n = n.size();
    int size_m = m.size();

    vector<vector<int>> dp(size_n+1,vector<int>(size_m+1));

    for(int i=1;i<=size_n;i++){
        for(int j=1;j<=size_m;j++){
            if(n[i-1]==m[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    int i=size_n,j=size_m;
    string ans="";
    while(i>0&&j>0){
        if(dp[i][j]==dp[i-1][j-1]+1&& dp[i-1][j] + 1 == dp[i][j] && dp[i][j-1] + 1 == dp[i][j]){
            i--;
            j--;
            ans=n[i]+ans;
        }else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }else{
            j--;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 38864
use std::io::*;
mod fenwick_tree {
    use std::ops::*;
    pub struct FenwickTree<T> {
        size: usize,
        data: Vec<T>,
        identity: T,
    }
    impl<T: Copy + Clone + AddAssign + Sub<Output = T>> FenwickTree<T> {
        pub fn new(size: usize, id: T) -> FenwickTree<T> {
            FenwickTree {
                size: size,
                data: vec![id; size + 2],
                identity: id,
            }
        }
        fn prefix_sum(&self, i: usize) -> T {
            let mut res = self.identity;
            let mut idx = i;
            while idx > 0 {
                res += self.data[idx];
                idx -= ((idx as isize) & -(idx as isize)) as usize;
            }
            res
        }
        pub fn update(&mut self, i: usize, x: T) {
            let mut idx = i;
            while idx <= self.size {
                self.data[idx] += x;
                idx += ((idx as isize) & -(idx as isize)) as usize;
            }
        }
        pub fn query(&self, l: usize, r: usize) -> T {
            self.prefix_sum(r) - self.prefix_sum(l - 1)
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut s: Vec<usize> = itr
        .next()
        .unwrap()
        .chars()
        .map(|c| c as usize - 'a' as usize)
        .collect();
    let q: usize = itr.next().unwrap().parse().unwrap();
    let mut count: Vec<fenwick_tree::FenwickTree<i64>> = (0..26)
        .map(|_| fenwick_tree::FenwickTree::new(n + 1, 0))
        .collect();
    for i in 0..s.len() {
        count[s[i]].update(i + 1, 1);
    }

    let mut out = Vec::new();
    for _ in 0..q {
        let c: usize = itr.next().unwrap().parse().unwrap();
        if c == 1 {
            let i: usize = itr.next().unwrap().parse().unwrap();
            let tmp: Vec<char> = itr.next().unwrap().chars().collect();
            let c: usize = tmp[0] as usize - 'a' as usize;
            count[s[i - 1]].update(i, -1);
            count[c].update(i, 1);
            s[i - 1] = c;
        } else {
            let l: usize = itr.next().unwrap().parse().unwrap();
            let r: usize = itr.next().unwrap().parse().unwrap();

            let mut ans = 0i64;
            for i in 0..26 {
                if count[i].query(l, r) > 0 {
                    ans += 1;
                }
            }
            writeln!(out, "{}", ans).ok();
        }
    }
    stdout().write_all(&out).unwrap();
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
  }
  
  long long amount = 1000;
  for (int i=1; i<N; i++) {
     if (a.at(i-1) >= a.at(i)) {
       continue;
     }
     else if (a.at(i-1) < a.at(i)) {
       long long stock = amount / a.at(i-1);
       amount += stock*(a.at(i)-a.at(i-1));
     }
  }
  cout << amount << endl;
}


Measured memory_bytes: 3612
N = int(input())

for i in range(1,N+1):
  t,x,y = map(int,input().split())
  cond1 = t >= (x + y)
  cond2 = (t % 2 == 0 and (x + y) % 2 == 0) or (t % 2 == 1 and (x + y) % 2 == 1)
  if not cond1 or not cond2:
    print("No")
    break
  
  if i == N:
    print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
const int N=2e5+5;
int n,m,a[N],b[N];
vector < pair < pair < int , int > , int > > v;	
bool check(int x) {
	for (int i=1; i<=m; i++) 
		if (a[i]>=x) b[i]=1;
				else b[i]=0;
		
	int len=2,l=0;	
	b[m+1]=-1,b[0]=0;

	v.clear();
	for (int i=1; i<=m+1; i++) {
		if (b[i]!=b[i-1] || i==1) {
			if (len>1) v.push_back({{l,i-1},b[l]});
			len=1;
			l=i;
		}
			else len++;
	}
	
	if (v.size()==1) return b[1];
	v.push_back({{m+1,m+1},0});
	
	for (int i=1; i<v.size(); i++) {
		int l=v[i-1].F.S+1;
		int r=v[i].F.F-1;
		if (l<=r) {
			int mid=(l+r)/2;
			v[i-1].F.S=mid;
			v[i].F.F=mid+1;
		}
	}

	for (int i=1; i<v.size()-1; i++) 
		if (v[i].F.F<=n && n<=v[i].F.S) return v[i].S;
}

main ()  {
	ios::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	
	cin>>n;
	m=2*n-1;
	for (int i=1; i<=m; i++) 
		cin>>a[i];
	
	int l=1,r=m,mid,ans=-1;
	
	while (l<=r) {
		mid=(l+r)/2;
		if (check(mid)) { l=mid+1; ans=mid; }
			else r=mid-1;
	}
	
	cout<<ans<<"\n";
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a;
  cin >> a;
  if(a<1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
}

Measured memory_bytes: 256
import math

A,B,H,M = map(int,input().split())
a = H*30 + M/2
b = M*6
angle = math.radians(a-b)
# print(a,b,angle)
C = math.sqrt(A*A + B*B - 2*A*B*math.cos(angle))
print(C)

Measured memory_bytes: 9496
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int K = in(), S = in();
  int ans = 0;
  rep(X, K + 1) rep(Y, K + 1) {
    int Z = S - X - Y;
    if (0 <= Z && Z <= K) ans++;
  }
  pr(ans);
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>

const int MOD = 1e9 + 7, MAX_N = 2e6 + 5;
typedef long long LL;

LL factorial[MAX_N];
LL inverse_factorial[MAX_N];

LL power_mod(LL x, LL power, LL MOD)
{
    LL answer = 1;

    while(power)
    {
        if(power%2 == 1)
            answer = (answer*x)%MOD;

        x = (x*x)%MOD;
        power = power >> 1;
    }

    return answer;
}

LL choose(LL n, LL r, LL MOD)
{
    LL numerator = factorial[n];
    LL denominator_inverse = (inverse_factorial[r]*inverse_factorial[n - r])%MOD;

    return (numerator*denominator_inverse)%MOD;
}

int main()
{
    const int MOD = 1e9 + 7;

    factorial[0] = 1;
    for(int i = 1; i < MAX_N; i++)
        factorial[i] = (i*factorial[i - 1])%MOD;

    inverse_factorial[MAX_N - 1] = power_mod(factorial[MAX_N - 1], MOD - 2, MOD);
    for(int i = MAX_N - 2; i >= 0; i--)
        inverse_factorial[i] = ( (i + 1)*inverse_factorial[i + 1] )%MOD;

    int no_of_factors, n;
    scanf("%d %d", &no_of_factors, &n);

    LL answer = 1;
    for(int i = 2; i*i <= n; i++)
    {
        int exponent = 0;

        while(n%i == 0)
        {
            n = n/i;
            exponent++;
        }

        LL no_of_ways_of_placing_this_prime = choose(exponent + no_of_factors - 1, exponent, MOD);
        answer = (answer*no_of_ways_of_placing_this_prime)%MOD;
    }

    if(n > 1)
    {
        int exponent = 1;

        LL no_of_ways_of_placing_this_prime = choose(exponent + no_of_factors - 1, exponent, MOD);
        answer = (answer*no_of_ways_of_placing_this_prime)%MOD;
    }

    printf("%lld\n", answer);
    return 0;
}


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

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

using namespace std;

const int MAX_N = 1e6 + 10;
const int INF = 1e9;
int dp1[MAX_N];
int dp2[MAX_N];

int main() {
  vector<int> x, y;
  REP(i, 1, 201) {
    int z = i * (i+1) * (i+2) / 6;
    x.push_back(z);
    if(z&1) y.push_back(z);
  }
  
  rep(i, MAX_N) dp1[i] = dp2[i] = INF;
  dp1[0] = 0;
  dp2[0] = 0;
  for(const auto& a : x) {
    for(int i = 0; i + a < MAX_N; ++i) {
      dp1[i+a] = min(dp1[i+a], dp1[i]+1); 
    }
  }
  for(const auto& a : y) {
    for(int i = 0; i + a < MAX_N; ++i) {
      dp2[i+a] = min(dp2[i+a], dp2[i]+1); 
    }
  }
  int n;
  while(cin >> n) {
    if(n == 0) break;
    cout << dp1[n] << " " << dp2[n] << endl;
  }
  return 0;
}



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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

vector <ll> p(15);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll N;
    cin >> N;

    ll sum = 0;
    ll m = p[0];
    for(ll i=0; i<N; i++)
    {
        cin >> p[i];

        sum+=p[i];
        m = max(m, p[i]);
    }

    cout << sum - m/2 << endl;
    

    return 0;
}

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

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

	int ans = 0;
	ans = max(ans, A + A - 1);
	ans = max(ans, A + B);
	ans = max(ans, B + B - 1);

	cout << ans << endl;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    string s,t;cin >> s  >> t;
    ll ans = 0;
    ll leng = s.size();
    REP(i,leng){
        if(s[i]!=t[i])ans++;
    }
    cout << ans << endl;
}//https://atcoder.jp/contests/abc172/tasks/abc172_b

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

using namespace std;

const int mod = 1e9 + 7;

long long n, dp[3002][3002], sum[3002][3002];
char s[3002];

int main()
{
  cin >> n;
  cin >> (s + 1);
  dp[1][1] = 1;
  sum[1][1] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      if (s[i - 1] == '<')
        dp[i][j] += sum[i - 1][j - 1];
      if (s[i - 1] == '>')
        dp[i][j] += (sum[i - 1][i - 1] - sum[i - 1][j - 1] + mod) % mod;
      dp[i][j] %= mod;
    }
    for (int j = 1; j <= i; j++) {
      sum[i][j] = (sum[i][j - 1] + dp[i][j]) % mod;
    }
  }
  int ans = sum[n][n];
  cout << ans;
  return 0;
}


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

int V[5+(1<<18)];
int W[5+(1<<18)];

int dp[5+(1<<8)][100005];

const int INF = 1012345678;

int S, K;

int rec(int v, int L_rem, int bonus_value){
    if(L_rem < 0){
        return -INF;
    }else if(v < (1<<K)){
        return bonus_value + dp[v][L_rem];
    }

    return max(rec(v>>1, L_rem, bonus_value), rec(v>>1, L_rem-W[v], bonus_value+V[v]));
}


int main(){
    int N;
    scanf("%d", &N);

    for(int i = 1; i <= N; i ++){
        scanf("%d%d", &V[i], &W[i]);
    }

    int Q;
    scanf("%d", &Q);
    K = log2(N)/2;

    //printf("1<<K=%d\n", 1<<K);

    memset(dp, 0, sizeof(dp));
    for(int i = 1; i <= (1<<K); i ++){
        for(int j = 0; j <= 100000; j ++){
            int temp = dp[i>>1][j];
            if(j >= W[i]){
                temp = max(temp, V[i]+dp[i>>1][j-W[i]]);
            }
            dp[i][j] = temp;
        }
    }

    while(Q --){
        int v, L;
        scanf("%d%d", &v, &L);
        printf("%d\n", rec(v, L, 0));
    }

    return 0;
}


Measured memory_bytes: 107896
#include<bits/stdc++.h>
struct postion
{
	int x , y;
};
postion p[4] = {{-1,0},{0,1},{1,0},{0,-1}};
int main()
{
	int n ,i ,j ,t ,cha ,chaa ,x ,y;
	bool lag = true;
	scanf("%d",&n);
	int a[n+1][3];
	a[0][0] = a[0][1] = a[0][2] = 0;
	for(i = 1 ;i <= n;i++)
		scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
	for(i = 1 ;i <= n;i++)
	{
		cha = abs(a[i][1] - a[i-1][1] + a[i][2] - a[i-1][2]);
		t = a[i][0] - a[i-1][0];
		if(t < cha)
		{
			lag = false;
			break;
		}
		for(j = 0 ;j < 4;j++)
		{
			x = a[i][1] + p[j].x;
			y = a[i][2] + p[j].y;
			chaa = abs(a[i-1][1] - x + a[i-1][2] - y);
			chaa = t - chaa ;
			if(chaa >= 1 && chaa % 2)
				break;
		}
		if (j == 4)
			lag = false;
	}
	printf(lag ? "Yes" : "No");
	return 0;
 } 

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
long long n,f[100005][4],a[100005][4];
int main()
{
    cin>>n;
    for (long long i=1;i<=n;++i)
    {
        cin>>a[i][1]>>a[i][2]>>a[i][3];
    }
    f[1][1]=a[1][1];
    f[1][2]=a[1][2];
    f[1][3]=a[1][3];
    for (long long i=2;i<=n;++i)
    {
        for (long long j=1;j<=3;++j)
        {
            if (j==1)
            {
                f[i][j]=max(f[i-1][2],f[i-1][3])+a[i][j];
            } else if (j==2)
            {
                f[i][j]=max(f[i-1][1],f[i-1][3])+a[i][j];
            } else if (j==3)
            {
                f[i][j]=max(f[i-1][1],f[i-1][2])+a[i][j];
            }
        }
    }
    cout<<max(f[n][1],max(f[n][2],f[n][3]));
    return 0;
}

Measured memory_bytes: 9812
a, b = map(int, input().split())
if 0 < a:
    print('Positive')
elif a < 0 < b or a == 0 or b == 0:
    print('Zero')
else:
    if (b-a+1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    A, B, N = [int(i) for i in input().strip().split()]
    ans = 0
    if N >= B:
        if A >= B:
            n = range(B - 1, N + 1, B)[-1]
        else:
            n = range(B - 1, N + 1, B)[0]
        ans = ((A * n) // B) - (A * (n // B))
    else:
        ans = ((A * N) // B) - (A * (N // B))
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9064
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Expired?
            var line = ReadLine();
            int x = line[0];
            int a = line[1];
            int b = line[2];

            if (a >= b)
            {
                Console.WriteLine("delicious");
            }
            else if (x >= b - a)
            {
                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("dangerous");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

h,n = map(int, input().split())
a = np.array(sorted(list(int(i) for i in input().split()), \
      reverse = True))
print('Yes' if a.sum() >= h else 'No')


Measured memory_bytes: 23372
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define N               100005
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fio(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

vi gr[N];
ll dp[N][2];

ll dfs(ll cur, ll par, bool b){

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

    ll ans = 0;
    ll a1 = 1, a2 = 1;
    
    // neigh can be painted white whether cur is black or white
    for(auto &neigh : gr[cur]){
        if(neigh != par) {
            a1 = (a1 * dfs(neigh, cur, false)) % mod;
        }
    }
    ans = (ans + a1) % mod;

    // if curr is not painted black => neigh can be painted black
    if(! b){
        for(auto &neigh : gr[cur]){
            if(neigh != par) {
                a2 = (a2 *  dfs(neigh, cur, true)) % mod;
            }
        }

        ans = (ans + a2) % mod;
    }

    return dp[cur][b] = ans % mod;
}

int main(){
    fio();

    ll n;
    cin>>n;
    for(ll x=1;x<n;x++){
        ll u,v;
        cin>>u>>v;

        gr[u].pb(v);
        gr[v].pb(u);
    }

    memset(dp, -1, sizeof dp);
    cout<<dfs(1,1,false);

    return 0;
}

Measured memory_bytes: 17548
#include<stdio.h>

int main(){
  int h, w;
  int i, j;
  
  while(1){
    scanf("%d %d", &h, &w);
    if(h == 0 && w == 0) break;

    for(i = 0; i < h; i++){
      for(j = 0; j < w; j++){
	if((i + j) % 2 == 0){
	  printf("#");
	}
	else {
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}


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

int main() {
	string r = "yuiophjklmn";
	string s;
	while (cin >> s, s != "#") {
		int cnt = 0;
		bool right = false;
		if ((int)r.find(s[0]) >= 0)right = true;
		for (int i = 1; i < s.size(); i++) {
			bool b = (int)r.find(s[i]) >= 0;
			cnt += b^right;
			right = b;
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3272
from itertools import permutations

N, M, R = map(int,input().split())
r = list(map(int,input().split()))

possible = permutations(r,R)
dist = [[float("inf") for k in range(N)]for i in range(N)]

for i in range(N):
    dist[i][i] = 0

for i in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    dist[a][b] = c
    dist[b][a] = c

for i in range(N):
    for j in range(N):
        for k in range(N):
            dist[j][k] = min(dist[j][k],dist[j][i]+dist[i][k])

Ans = float("inf")
for pos in possible:
    ans = 0
    for i in range(R-1):
        ans += dist[pos[i]-1][pos[i+1]-1]

    Ans = min(Ans,ans)

print(Ans)

Measured memory_bytes: 65624
n = int(input())

#すべての要素が空になっているリストを作成
l = list('' for _ in range(n))

def dfs(i, mx):
    if i == n:
        #リストの要素同士をつなげて出力、次の文字列へ
        print(''.join(l))
        return
    
    for j in range(mx + 1):
        #l[i]はaからj番目の数に決定
        l[i] = chr(ord('a') + j)
        #(i+1)番目に取りうる文字の候補は、i番目の文字として選んだものの次のものまで
        dfs(i+1, max(j + 1, mx))

dfs(0, 0)

Measured memory_bytes: 4340
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var ab = Reads();
            var a = ab[0];
            var b = ab[1];
            if (a <= 0 && b >= 0) Console.WriteLine("Zero");
            if (a > 0 && b > 0) Console.WriteLine("Positive");
            if (a < 0 && b < 0) Console.WriteLine((b - a) % 2 == 0?"Negative":"Positive");

            Console.Out.Flush();
        }
    }
}




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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  int len = 0;
  int ans = 0;
  for(int i = 0; i < s.length() - t.length() + 1; i++){
    len = 0;
    for(int j = i; j < i + t.length(); j++){
      if(s[j] == t[j-i]) len ++;
    }
    // cout << len << endl;
    ans = max(ans, len);
  }
  cout << t.length() - ans << endl;

  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string S;
	cin >> S;
	if (S[5] == '0' && S[6] <= '4')		
		cout  << "Heisei" << endl;
	else
		cout << "TBD" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace  std;
int dfs(int p,int n, int s)
{
	if (s == 0 && n == 0)return 1;
	int ret = 0;
	for (int i = p + 1; i <= 9; i++)
	{
		ret += dfs(i, n - 1, s - i);
	}
	return ret;
}
int main()
{
	int n, s;
	while (cin >> n >> s)
	{
		if (n == 0 && s == 0)break;
		cout << dfs(-1, n, s) << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,k;

int main(){
  cin>>n>>k;
  // 1<=a<=n, 1<=b<=n
  // a % b >= k
  // k <= r=a%b < b
  // 1<= a=b*x+r <= n
  ll ans = 0;
  FOR(b,1,n+1){
    int po = (n+1)/b;
    ans += po * max(0, b-k);
    if(k==0)ans--;
    int yo = (n+1)%b;
    ans += max(0, yo-k);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int a=0;
    int b=0;

    cin >> a >> b;

    if(a==b){
        cout << "Draw" << endl;
    }else if(a>b||a==1){
        if(b!=1){
            cout << "Alice" << endl;
        }else{
            cout << "Bob" << endl;
        }
    }else{
        cout << "Bob" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+10;
const int B=333;
vector<pii> g[maxn];
int n,q;
struct Edge
{
	int a,b,c,d;
	Edge(){}
	Edge(int a,int b,int c,int d):a(a),b(b),c(c),d(d){}
}es[maxn];
int bg[maxn],ed[maxn],DFN,dep[maxn],pa[maxn],fae[maxn],dist[maxn];
vector<int> tsum,tcnt,recsum[maxn],reccnt[maxn];
vector<pii> euler;
void dfs(int x,int fa)
{
	pa[x]=fa;
	dep[x]=dep[fa]+1;
	bg[x]=DFN++;
	if(dep[x]%B==0)
	{
		recsum[x]=tsum;
		reccnt[x]=tcnt;
	}
	euler.push_back(make_pair(dep[x],x));
	for(int i=0;i<g[x].size();i++)
	{
		int to=g[x][i].first;
		if(to==fa)continue;
		fae[to]=g[x][i].second;
		dist[to]=dist[x]+es[g[x][i].second].d;
		tsum[es[g[x][i].second].c]+=es[g[x][i].second].d;
		tcnt[es[g[x][i].second].c]++;
		dfs(to,x);
		tcnt[es[g[x][i].second].c]--;
		tsum[es[g[x][i].second].c]-=es[g[x][i].second].d;
		euler.push_back(make_pair(dep[x],x));
		DFN++;
	}
	ed[x]=DFN;
}
pii st[20][maxn*2];
int lg2[maxn*2];
inline pii rmq(int l,int r)
{
	if(l>r)swap(l,r);
	int len=lg2[r-l];
	return min(st[len][l],st[len][r-(1<<len)]);
}
struct query
{
	int x,y,u,v;
	query(){}
	query(int x,int y,int u,int v):x(x),y(y),u(u),v(v){}
};
vector<query> qs[maxn];
vector<Edge> ces[maxn];
int getans(int x,int qrc,int qry)
{
	int res=0;
	while(dep[x]%B!=0)
	{
		if(pa[x]==0)return res;
		if(es[fae[x]].c==qrc)res+=qry;
		else res+=es[fae[x]].d;
		x=pa[x];
	}
	if(x==0)return res;
	res+=dist[x];
	res-=recsum[x][qrc];
	res+=reccnt[x][qrc]*qry;
	return res;
}
int main()
{
	lg2[1]=0;
	for(int i=2;i<maxn*2;i++)lg2[i]=lg2[i>>1]+1;
	scanf("%d%d",&n,&q);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d%d%d",&es[i].a,&es[i].b,&es[i].c,&es[i].d);
		g[es[i].a].push_back(make_pair(es[i].b,i));
		g[es[i].b].push_back(make_pair(es[i].a,i));
		ces[es[i].c].push_back(es[i]);
	}
	tsum.resize(n);
	tcnt.resize(n);
	dfs(1,0);
	int m=euler.size();
	for(int i=0;i<m;i++)st[0][i]=euler[i];
	for(int k=1;k<20;k++)
	{
		for(int i=0;i+(1<<k)<=m;i++)
		{
			st[k][i]=min(st[k-1][i],st[k-1][i+(1<<(k-1))]);
		}
	}
	for(int i=0;i<q;i++)
	{
		int x,y,u,v;
		scanf("%d%d%d%d",&x,&y,&u,&v);
		int lca=rmq(bg[u],bg[v]).second;
		int ans=getans(u,x,y)+getans(v,x,y)-2*getans(lca,x,y);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 296304
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
    public static int[] dp = new int[50];

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        for(int i = 0; i <= n; i++) dp[i] = -1;
        System.out.println(fib(n));
    }

    public static int fib(int n){
        if(n == 0 || n == 1){
            return dp[n] = 1;
        }
        if(dp[n] != -1) return dp[n];
        return dp[n] = fib(n-1) + fib(n-2);
    }
}

Measured memory_bytes: 24292
#coding: utf-8

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        # xの根を探索
        if self.parents[x] < 0:
            return x
        else:
            # 再帰的に根を探索して経路圧縮
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        # 2つの木をマージする。
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        # xの根の所属するグループの要素数を返す
        return -self.parents[self.find(x)]

    def are_same(self, x, y):
        # 2つの要素の根が同じかどうかを調べる
        return self.find(x) == self.find(y)

    def members(self, x):
        # xと同じ根の要素をリストで出力
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == self.n]

    def roots(self):
        # 根である要素をリストで出力
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{} {}".format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
uf = UnionFind(N)
A, B = [], []
for i in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A = A[::-1]
B = B[::-1]
ans = [N*(N-1)//2]
for a, b in zip(A, B):
    if not uf.are_same(a-1, b-1):
        ans.append(ans[-1] - uf.size(a-1) * uf.size(b-1))
    else:
        # もともと連結なら不便度は変わらない
        ans.append(ans[-1])
    uf.union(a-1, b-1)
print(*ans[::-1][1:], sep="\n")

Measured memory_bytes: 111448
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  REP(i,10) REP(j,10) REP(k,10) {
    int secret[3] = {i,j,k};
    int cnt = 0;
    REP(i,n) {
      if (s[i]-'0' == secret[cnt]) {
        cnt++;
        if (cnt == 3) { ans++; break; }
      }
    }
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define int long long int
 

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	int n,m;
	cin>>n>>m;
	if(n==m)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}



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

vector<int> present(200001, 1);

int getSize(int person, vector<vector<int>>& graph)
{
	if(!present[person]) return 0;
	int ret = 1;
	present[person] = 0;

	for(auto& node: graph[person])
	{
		ret += getSize(node, graph);
	}
	return ret;
}

int main()
{
	int n, m; cin >> n >> m;
	int a, b;
	vector<vector<int>> graph(n+1);
	for(int i = 0; i < m; ++i)
	{
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		present[a] = present[b] = 1;
	}

	int ans = 0;
	for(int i = 1; i <= n; ++i)
	{
		if(present[i])
		{
			ans = max(ans, getSize(i, graph));
		}
	}

	cout << ans;

	return 0;
}

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

vector<int> split(const string &s,char c=' '){
	vector<int> ret;
	stringstream ss(s);
	string t;
	while(getline(ss,t,c)){
		ret.push_back(t.size());
	}
	return ret;
}

bool dp[20000], nxt[20000];

int main(){
	string s;
	int x, y;
	cin >> s >> x >> y;
	vector<int> a = split(s, 'T');
	vector<int> b, c;
	rep(i, 0, a.size()){
		if(i % 2 == 0) b.push_back(a[i]);
		else c.push_back(a[i]);
	}
	int t = 10000;
	dp[t + b[0]] = true;
	rep(i, 1, b.size()){
		rep(j, 0, 20000) nxt[j] = false;
		rep(j, 0, 20000){
			if(dp[j]){
				nxt[j - b[i]] = true;
				nxt[j + b[i]] = true;
			}
		}
		swap(dp, nxt);
	}
	bool ans = true;
	if(dp[t + x] == false) ans = false;
	rep(i, 0, 20000) dp[i] = false;
	dp[t] = true;
	rep(i, 0, c.size()){
		rep(j, 0, 20000) nxt[j] = false;
		rep(j, 0, 20000){
			if(dp[j]){
				nxt[j - c[i]] = true;
				nxt[j + c[i]] = true;
			}
		}
		swap(dp, nxt);
	}
	if(dp[t + y] == false) ans = false;
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

const ll MOD = 1e9 + 7;
const ll MAX_N = 2002;

ll factorial[MAX_N];

ll calc_pow(ll x, ll y) {
    ll z = 1;
    while (y > 0) {
        if (y & 1) {
            z = (z * x) % MOD;
        }
        x = (x * x) % MOD;
        y /= 2;
    }
    return z;
}

ll calc_comb(ll x, ll y) {
    ll divs = (factorial[x - y] * factorial[y]) % MOD;
    return (factorial[x] * calc_pow(divs, MOD - 2)) % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    factorial[0] = 1;
    for (int i = 1; i <= N; i++) {
        factorial[i] = (factorial[i - 1] * i) % MOD;
    }
    for (ll i = 1; i <= K; i++) {
        if (N - K + 1 < i) {
            cout << 0 << endl;
            continue;
        }
        ll k_div = calc_comb(K - 1, i - 1);
        ll all_div = calc_comb(N - K + 1, i);
        ll ans = (k_div * all_div) % MOD;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

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

  string s;
  int w;
  cin >> s >> w;

  for (int i = 0; i < s.size(); ++i) {
    if (i % w == 0)
      cout << s[i];
  }
  cout << endl;
  return 0;
}


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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, m;
vector<vector<int>> graph;
vector<int> d;

int dfs(int x) {
  if (d[x] != 0) return d[x];
  int mx = 0;
  rep(i, graph[x].size()) mx = max(mx, dfs(graph[x][i]) + 1);

  d[x] = mx;
  return mx;
}

int main() {
  cin >> n >> m;
  graph.resize(n);
  d = vector<int>(n, 0);

  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    graph[x].push_back(y);
  }


  int ans = 0;
  rep(i, n) {
    if (d[i] == 0) ans = max(ans, dfs(i));
  }

  cout << ans << endl;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, y;
    cin >> n >> y;
    y /= 1000;
    // 10x + 5y + z = Y/1000
    // x + y + z = n;
    // 9x + 4y = y/1000 - n;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n-i; j++) {
            int k = n-i-j;
            if (10 * i + 5 * j + k == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}



Measured memory_bytes: 256
n,m,c = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)

cnt = 0
a=[]
n.times.each do |i|
  sum = 0
  a[i] = gets.split(" ").map(&:to_i)

  m.times.each do |j|
    sum += a[i][j] * b[j]
  end
  cnt += 1 if sum+c > 0
end
puts cnt

Measured memory_bytes: 1788
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int n = in.nextInt();
            int ans = 0;

            for (int i = 0; i <= a; i++) {
                for (int j = 0; j <= b; j++) {
                    for (int k = 0; k <= c; k++) {
                        if ((i * 500 + j * 100 + k * 50) == n) ans++;
                    }
                }
            }


            out.print(ans);
        }

    }
}



Measured memory_bytes: 22868
n, m = map(int, input().split())
A = list(map(int, input().split()))

line = sum(A)/(4*m)
count = 0
for i in range(n):
    if A[i] >= line:
        count += 1

if count >= m:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

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

int main(){
	int n;
	cin >> n;
	string s, ans = "Yes";
	cin >> s;

	if(n%2 == 0){
		for(int i = 0; i < n/2; i++){
			if(s[i] != s[i + n/2]) ans = "No";
		}
	}else if(n%2 == 1){
		ans = "No";
	}

	cout << ans << endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(0,min(b, d) - max(a, c)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const p=1e9+7;
int f[5005][2],g[5005][2];
int mod(int x){return x>=p?x-p:x;}
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if(a>b)swap(a,b);
    g[1][1]=1;
    for(int i=2;i<b;i++)
    {
        for(int j=1;j<=i-a;j++)
            g[i][0]=mod(g[i][0]+g[j][1]);
        g[i][1]=mod(g[i-1][0]+g[i-1][1]);
    }
    f[0][0]=f[0][1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=max(i-a+1,0);j<i;j++)f[i][0]=mod(f[i][0]+f[j][1]);
        for(int j=max(i-b+1,0);j<i;j++)
        {
            if(i==n)f[i][0]=(f[i][0]+1ll*f[j][0]*g[i-j][0])%p;
            if(j==0)f[i][1]=(1ll*f[i][1]+g[i][0]+g[i][1])%p;
            else f[i][1]=(f[i][1]+1ll*f[j][0]*g[i-j][1])%p;
        }
    }
    int pw=1;
    for(int i=1;i<=n;i++)pw=mod(pw+pw);
    printf("%lld",(1ll*pw+p+p-f[n][0]-f[n][1])%p);
    return 0;
}

Measured memory_bytes: 3896
#include<stdio.h>

int main(){
	int a[11],i,j;
	
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
				int temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}
	
	for(i=0;i<3;i++){
		printf("%d\n",a[i]);
	}
	
	return 0;
}

Measured memory_bytes: 1752
#include <stdio.h>

#define N 10

int main(void){
  int i, j, bi, ci, n;
  int a[N], b[N], c[N];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < N; j++){
      scanf("%d", &a[j]);
    }
    bi = 0;
    ci = 0;
    for(j = 0; j < N; j++){
      if(bi == 0 || a[j] > b[bi-1]){
	b[bi] = a[j];
	bi++;
      }else if(ci == 0 || a[j] > c[ci-1]){
	c[ci] = a[j];
	ci++;
      }else{
	break;
      }
    }
    if(j == N){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 580