akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
int main(){
    int i;
    char s[3];
    scanf("%s", s);
    if(strcmp(s, "RRR") == 0) printf("3\n");
    else if(strcmp(s, "SRR") == 0 || strcmp(s, "RRS") == 0){
        printf("2\n");
    }else if (strcmp(s, "SSS") == 0) printf("0\n");
    else printf("1\n");
    return 0;
}


Measured memory_bytes: 1664
S = input()
# for i in range(10000):
#     S = str(i).zfill(4)
#     print(S, end=":")
# print(int(S[:2]), int(S[2:]))
if (int(S[:2]) == 0 and int(S[2:]) == 0) or (int(S[:2]) == 0 and int(S[2:]) >= 13) or (int(S[:2]) >= 13 and int(S[2:]) == 0) or (int(S[:2]) >= 13 and int(S[2:]) >= 13):
    print("NA")
elif int(S[:2]) < 13 and int(S[:2]) > 0 and int(S[2:]) < 13 and int(S[2:]) > 0:
    print("AMBIGUOUS")
elif int(S[:2]) < 13 and int(S[:2]) > 0:
    print("MMYY")
else:
    print("YYMM")
    # if i % 1000 == 0:
    #     input("STOP")

Measured memory_bytes: 3064
def main():
    string = input()
    begin_index = -1
    end_index = 0
    for i in range(len(string)):
        if string[i] == "A" and begin_index < 0:
            begin_index = i
        elif string[i] == "Z":
            end_index = i
    print(end_index - begin_index + 1)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3516
N = int(input())
H = [int(i) for i in input().split()]
l = 0
r = 0
ans = 0
while r < N - 1:
    if H[r] >= H[r+1]:
        r += 1
    else:
        ans = max(ans, r-l)
        l = r + 1
        r += 1
ans = max(ans, r-l)
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()

int main() {
   int n;
   string s;
   cin >> n >> s;
   int ans=0;
   rep(i,n){
      string t=s.substr(0,i), u=s.substr(i);
      int cnt=0;
      for(char c='a';c<='z';c++){
         if(t.find(c)!=-1&&u.find(c)!=-1)
         cnt++;
      }
      ans=max(ans,cnt);
   }
   cout << ans << endl;
}

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

int main() {
  int N; cin >> N;
  
  int ans = 0;
  for (int i = 1; i <= N; i+=2) {
    int cnt = 0;
    repi(j,1,i) {
      if (i%j==0) cnt++;
    }
    if (cnt==8) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

/*-----------------------------------------------------------------------------
定義
-------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF			2e9
#define MOD			1e9+7
#define MIN(a, b)	((a) < (b) ? a : b)
#define MAX(a, b)	((a) > (b) ? a : b)
#define IsOdd(x)	(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)	(!IsOdd((x)))					/* 偶数 */

typedef long long int QWORD;
typedef long long int ll;

/*-----------------------------------------------------------------------------
処理
-------------------------------------------------------------------------------*/
int isType(int val)
{
	int type;

	if (val == 0) {
		type = -1;
	} else if ((1 <= val) && (val <= 12)) {
		type = 0;
	} else {
		type = 1;
	}

	return type;
}

int main()
{
	string S;

	cin >> S;

	int val = atoi(S.c_str());
	int valH = (val / 100);
	int valL = (val % 100);

	int typeH = isType(valH);
	int typeL = isType(valL);

	switch (typeH){
	case 1:
		switch (typeL){
		case 1:
			cout << "NA";
			break;
		case -1:
			cout << "NA";
			break;
		case 0:
			cout << "YYMM";
			break;
		}
		break;
	case -1:
		switch (typeL){
		case 1:
			cout << "NA";
			break;
		case -1:
			cout << "NA";
			break;
		case 0:
			cout << "YYMM";
			break;
		}
		break;
	case 0:
		switch (typeL){
		case 1:
			cout << "MMYY";
			break;
		case -1:
			cout << "MMYY";
			break;
		case 0:
			cout << "AMBIGUOUS";
			break;
		}
		break;
	}

	return 0;
}



Measured memory_bytes: 256
s=int(input())
dic={}
dic[s]=dic.get(s,0)+1
i=1
while True:
	if s%2==0:
		s=s//2
	else:
		s=3*s+1
	dic[s]=dic.get(s,0)+1
	if dic[s]>=2:
		print(i+1)
		exit(0)
	i+=1


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T,class U>
ostream& operator<<(ostream& os,const map<T, U> & mp){
	os << "{";
	int i = 0;
	for(auto it : mp){
		if(i) os<<", ";
		os << it;
		i++;
	}
	os << "}";	
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 2e6 + 10;
// const int mod = 998244353;
const int mod = 1e9 + 7;
int fact[N], invfact[N];
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (((ll) x) * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}
void pre(){
	fact[0] = invfact[0] = 1;
	for(int i = 1;i < N; i++) fact[i] = mul(i, fact[i - 1]);
	invfact[N - 1] = inv(fact[N - 1]);
	for(int i = N - 2; i >= 1; i--) invfact[i] = mul(invfact[i + 1], i + 1);
	assert(invfact[1] == 1);
}

inline int C(int n, int k){
	if(n < k || k < 0) return 0;
	return mul(fact[n], mul(invfact[k], invfact[n - k]));
}

int coeff(int a, int i){
	return C(a + i - 1, i);
}

int get(int n, int m, int R){
	int ret = C(R + n, n);
	int diff = 0;
	for(int i = 0; i <= m; i++){
		int factor = C(m, i);
		if(i & 1) factor = sub(0, factor);
		int val = 0;
		for(int z = 0; (z + 1) * (n - m + i) <= R; z++){
			int req = R - (z + 1) * (n - m + i);
			val = add(val, coeff(n + 1, req));
		}
		for(int z = 0; (n - m) * (z + 1) + z * i <= R; z++){
			int req = R - (z + 1) * (n - m) - z * i;
			val = sub(val, coeff(n + 1, req));
		}

		diff = add(diff, mul(factor, val));
	}
	return sub(ret, mul(C(n, m), diff));
}

int main(){
	pre();
	int n, m, L, R;
	sd(n); sd(m); sd(L); sd(R);
	m = n - m;
	printf("%d\n", sub(get(n, m, R), get(n, m, L - 1)));
}

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

int main()
{
  int n,m;
  static int A[300][300];
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      scanf("%d",A[i]+j);
      A[i][j]--;
    }
  }
  int L=0,R=n;
  while(L+1<R){
    int K=(L+R)/2;
    int a[300]={0},b[300]={0};
    bool F=0;
    while(1){
      int c[300]={0};
      for(int i=0;i<n;i++){
	c[A[i][a[i]]]++;
      }
      int J=-1;
      for(int j=0;j<m;j++){
	if(c[j]>K){
	  J=j;
	  break;
	}
      }
      if(J==-1){
	F=1;
	break;
      }
      b[J]=1;
      bool G=0;
      for(int i=0;i<n;i++){
	while(a[i]<m&&b[A[i][a[i]]]){
	  a[i]++;
	}
	if(a[i]==m){
	  G=1;
	  break;
	}
      }
      if(G){
	break;
      }
    }
    if(F){
      R=K;
    }
    else{
      L=K;
    }
  }
  printf("%d\n",R);
  return 0;
}


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

int main(){
  int N;
  cin >>N;
  vector<int> x(N);
  for(int i=0; i<N; i++)
    cin >>x.at(i);
  sort(x.begin(),x.end());
  reverse(x.begin(), x.end());
  int A=0;
  int B=0;
  for(int i=0; i<N;i++){
    if(i%2==0)
      A+=x.at(i);
    else
      B+=x.at(i);
  }
  cout <<A-B <<endl;
}

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

int main() {
  int N, n, x, H;
  x = 0;
  n = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> H;
    if (n <= H) {
      x++;
      n = H;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
#define P 1000000007
long powP (long a, long b) {
  if (b == 1) return a;
  else if (b == 0) return 1;
  else if (b < 0) return powP(a, P + b - 1);
  else return (powP(a, b/2) * powP(a, b/2 + b%2)) % P;
}

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;


int main() {
  string s; cin>>s;
  cout<<s;
  if(s.back()=='s')cout<<"e";
  cout<<"s";
}


/* きょむ〜 */


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;

int main() {
	string s;
	cin >> s;
	int count=0;

	if (s.at(0) == '1')count++;
	if (s.at(1) == '1')count++;
	if (s.at(2) == '1')count++;
	
	cout << count << endl;
}

Measured memory_bytes: 256
let () =
  let check m d1 d10 = d1 >= 2 && d10 >= 2 && d1 * d10 = m in
  Scanf.scanf "%d %d\n" @@ fun m d ->
  let ans = ref 0 in
  for i = 1 to m do
    for j = 10 to d do
      if check i (j mod 10) (j / 10) then ans := !ans + 1
    done;
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    vec a(4); cin >> a;
    Sort(a);
    int ans = llabs(a[0] + a[3] - a[1] - a[2]);
    Out(ans);

    return 0;
}



Measured memory_bytes: 3220
# coding: utf-8
S = input()
ans = [1 for i in range(len(S))]
tmp = []
lr = []
l, r = 0, 0
tl = 0
cnt = 0
for i in range(len(S) - 1):
    if S[i] + S[i+1] == "RL":
        r, l = i, i + 1
    if S[i] + S[i+1] == "LR":
        if cnt != 0:
            tl += 1
        for j in range(tl, i + 1):
            if j == r or j == l:
                continue
            if (j - r) % 2 == 0:
                ans[r] += 1
                ans[j] = 0
            else:
                ans[l] += 1
                ans[j] = 0
        cnt += 1
        tl = i
    if i == len(S) - 2:
        if cnt != 0:
            tl += 1
        for j in range(tl, i + 2):
            if j == r or j == l:
                continue
            if (j - r - 1) % 2 == 0:
                ans[l] += 1
                ans[j] = 0
            else:
                ans[r] += 1
                ans[j] = 0
print(*ans)

Measured memory_bytes: 6408
N, K = map(int, input().split())
num_snack = []
#initiliaze number of snack each people has
for people in range(N):
  num_snack.append(0)
  
#count number of snack each people has
for i in range(K):
  num_people = map(int, input())
  has_snack = list(map(int,input().split()))
  for people in has_snack:
    num_snack[people-1] += 1

#count number of people that doesnt has snack
no_snack = 0
for snacks in num_snack:
  if (snacks == 0):
    no_snack += 1
print(no_snack)
    


Measured memory_bytes: 9184
#include <cstdio>
#define MOD 1000000007
#define sqr(x) ((ll)(x) * (x))
typedef long long ll; 
ll dp[1000005], sum; 
int main()
{
	// freopen("ARC071-F.in", "r", stdin); 
	int n; 
	scanf("%d", &n); 
	dp[1] = n; 
	dp[2] = sqr(n) % MOD; 
	for (int i = 3; i <= n; i++)
	{
		dp[i] = (dp[i - 1] + sqr(n - 1) + sum + n - i + 2) % MOD; 
		(sum += dp[i - 2]) %= MOD; 
	}
	printf("%lld\n", dp[n]);
	return 0;
}


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




int ASCttenannoryaku(const void *a,const void *b) {
	return *(int *)a - *(int *)b;
}
int main(void)
{
	int n;
	int a, b, c;//a = 500,b = 100,c = 10
	int ans = 0, keep = 0;
	scanf("%d%d%d%d",&a,&b,&c,&n);
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				keep = i * 500 + j * 100 + k * 50;
				if (keep == n) {
					ans++;
					//printf("%d*500+%d*100+%d*50 = %d\n",i,j,k,keep);
				}
			}
		}
	}
	printf("%d",ans);
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    int N,A,B; cin >>N>>A>>B;
    
    int ans = min(N*A,B);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int a,b,k;
  cin>>a>>b>>k;
  vector<int> v;
  int n=max(a,b);
  int i;
  for(i=1;i<=n;i++){
  	if(a%i==0&&b%i==0){
  		v.push_back(i);
	  }
  }
  
  sort(v.begin(),v.end(),greater<int>());
  cout<<v[k-1]<<endl;
  
  return 0;
}

Measured memory_bytes: 3596
def lcm(a,b):
  lar = max(a, b) 
  small = min(a, b) 
  i = lar 
  while(1) : 
    if (i % small == 0): 
      return i 
    i += lar 

x,y = map(int,input().split())
print(lcm(x,y))

Measured memory_bytes: 3060
n = input()
op = ["-", "+"]

for i in op:
    for j in op:
        for k in op:
            if eval(n[0] + i + n[1] + j + n[2] + k + n[3]) == 7:
                print(n[0] + i + n[1] + j + n[2] + k + n[3] + "=7")
                exit()

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

int main(){
int H, W; cin >> H >> W; string S[H];
for(int i=0; i<H; i++){ cin >> S[i]; }

int yoko[H][W], tate[H][W];
for(int i=0, w=1; i<H; i++){ for(int j=0; j<W; j++){
  if(S[i][j]=='#'){yoko[i][j]=tate[i][j]=0;}
  else{
    if(j==0 || S[i][j-1]=='#'){ w=1; while(j+w<W && S[i][j+w]=='.'){w++;} }
    yoko[i][j]=w;
  }
} }
  
for(int j=0, h=1; j<W; j++){ for(int i=0; i<H; i++){ 
  if(S[i][j]=='.'){
    if(i==0 || S[i-1][j]=='#'){ h=1; while(i+h<H && S[i+h][j]=='.'){h++;} }
    tate[i][j]=h;
  }
} }

int ans=1;
for(int i=0; i<H; i++){ for(int j=0; j<W; j++){ ans=max(ans, yoko[i][j]+tate[i][j]-1); }}
cout << ans << "\n";
}

Measured memory_bytes: 35584
#include<iostream>
int main(void){
  int N;
  std::cin >> N;
  bool b = false;
  for (int i=1;i<10;i++){
    for (int j=i;j<10;j++){
      if (N == i*j) b = true;
    }
  }
  if(b){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3624
N = int(input())
H = list(map(int,input().split()))
k = 0
ans = []
for i in range(N-1):
    if H[i]>H[i+1] or H[i] == H[i+1]:
        k = k+1
    else:
        ans.append(k)
        k = 0
ans.append(k)
print(max(ans))

Measured memory_bytes: 15020
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


Int a[26];

Int solve(int l, int r, int lx, int rx){
    if(l + 1 == r)return 0;
    Int res = LINF;
    for(int k = l+1;k < r;k++){
        res = min(res, solve(l, k, lx, lx+rx) + solve(k, r, lx+rx, rx) + a[k] * (lx+rx));
    }
    return res;
}

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

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const ll N=1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll read()     
{
    ll res=0,ch,flag=0;
    if((ch=getchar())=='-')
        flag=1;		
    else if(ch>='0'&&ch<='9')
        res=ch-'0';
    while((ch=getchar())>='0'&&ch<='9')
        res=res*10+ch-'0';
    return flag?-res:res;
}

int main(){
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0) continue;
        else sum+=i;
    }
    cout<<sum<<endl;

}

Measured memory_bytes: 3624
from collections import deque

n, m = map(int, input().split())

graph = [[] for _ in range(n+1)]

for i in range(m):
  a, b = map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)

flag = [0] * (n+1)
flag[0] = 1
flag[1] = 1

d = deque()
d.append(1)

guidepost = [-1] * (n+1)

while d:
  v = d.popleft()
  for i in graph[v]:
    if flag[i] != 0:
      continue
    flag[i] = 1
    d.append(i)
    if guidepost[i] != -1:
      print("No")
      exit()
    else:
      guidepost[i] = v
  
if not all(guidepost):
  print("No")
  exit()

ans = guidepost[2:]    

print("Yes")
print(*ans, sep="\n")

Measured memory_bytes: 36988
#include<stdio.h>
int main(){
int n,i,a[22222],b[22222],p;
scanf("%d",&n);
for(i=1;i<=n;i++){
a[i]=i*30000;
b[n-i+1]=i*30000;
}
for(i=0;i<n;i++){
scanf("%d",&p);
a[p]+=i;
}
printf("%d",a[1]);
for(i=2;i<=n;i++)
printf(" %d",a[i]);
printf("\n");
printf("%d",b[1]);
for(i=2;i<=n;i++)
printf(" %d",b[i]);
printf("\n");
return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cmath>

using namespace std;

int main() {

    int n = 0;
    cin >> n;

    int val[n][3];
    int  dp[n][3];

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> val[i][j];
            if(i == 0) {
                dp[i][j] = val[i][j];
            }
        }
    }

    for(int i = 1; i < n; i++) {
        for(int j = 0; j < 3; j++) {
            if(j == 0) {
                dp[i][j] = val[i][j] + max(dp[i-1][1], dp[i-1][2]);
            } else if(j == 1) {
                dp[i][j] = val[i][j] + max(dp[i-1][j-1], dp[i-1][j+1]);
            } else {
                dp[i][j] = val[i][j] + max(dp[i-1][1], dp[i-1][0]);
            }
        }
    }
    int maxGain = 0;
    for(int i = 0; i < 3; i++) {
        maxGain = max(maxGain, dp[n-1][i]);
    }
    cout << maxGain << endl;
}

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

using namespace std;

const int maxN = 1e2+10;
int A, B, C;
int dd[maxN];

int main()
{
    cin >> A >> B >> C;
    int x = A;
    while (!dd[x]) dd[x] = 1, x = (x+A)%B;
    puts(dd[C] ? "YES" : "NO");
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k, r, s, p int
	fmt.Scan(&n, &k)
	fmt.Scan(&r, &s, &p)
	var t string
	fmt.Scan(&t)

	T := make([]string, len([]rune(t)))

	for pos, value := range t {
		T[pos] = string(value)
	}

	mp := make(map[string]int, 4)

	mp["s"] = r
	mp["p"] = s
	mp["r"] = p
	mp["m"] = 0


	m := (n-1)/k + 1
	ans := 0
	for i:=0; i<m; i++{
		for j:=0; j < k; j++ {
			if i*k+j >= len(T) {
				break
			}

			if i!=0 {
				if T[i*k+j] == T[(i-1)*k+j]{
					T[i*k+j] = "m"
				}
			}

			ans += mp[T[i*k+j]]
		}
	}

	fmt.Printf("%d", ans)
}

Measured memory_bytes: 4200
#include <bits/stdc++.h>
#define ps push_back
using namespace std;
const int maxn=2e5+5;
char s[maxn];
int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);
    int n, i, j;
    cin>>n;
    scanf("%s", s);
    int num1=0, num2=0;
    for(int i=0; s[i]; i++)
    {
        if(s[i]=='R')num1++;
    }
    for(int i=0; i<num1; i++)
    {
        if(s[i]=='R')num2++;
    }
    printf("%d\n", num1-num2);
    return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  
  if(n%2==0) cout << n << endl;
  else cout << 2*n << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	string s,t;
	int ba=0;
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		{
			ba++;
		}
	}
	cout<<ba;
	return 0;
} 

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

int main() {
	int h, w; cin >> h >> w;
	char a[100][101], b[102][102];
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			b[i][j] = '#';
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			b[i + 1][j + 1] = a[i][j];
		}
	}
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			cout << b[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        Integer[] t = new Integer[n];
        for (int i = 0; i < n; i++) {
            t[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        Arrays.sort(t);
        int result = 0;
        int count = 0;
        int nextDepartureTimeIndex = 0;
        int nextDepartureTime = t[nextDepartureTimeIndex] + k;
        for (int i = 0; i < n; i++) {
            boolean isBefore = t[i] <= nextDepartureTime;
            if (isBefore) {
                count++;
            }
            while (nextDepartureTime <= t[i] && 0 < count) {
                result++;
                int minus = Math.min(count, c);
                count -= minus;
                nextDepartureTimeIndex += minus;
                if (n - 1 < nextDepartureTimeIndex) {
                    count += n - i;
                    break;
                }
                nextDepartureTime = t[nextDepartureTimeIndex] + k;
            }
            if (!isBefore) {
                count++;
            }
        }
        if (0 < count) {
            result += Math.ceil((double) count / c);
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 61212
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	NKAF=np.array(read().split(),np.int64)
	N=NKAF[0]
	K=NKAF[1]
	AF=NKAF[2:]
	A,F=np.split(AF,2)
	A.sort()
	F.sort()
	F=F[::-1]
	
	lt=0
	rt=10**12+1
	
	Asum=A.sum()
	
	while rt-lt>1:
		mid=(rt+lt)//2
		if Asum-np.minimum(A,mid//F).sum()<=K:
			rt=mid
		else:
			lt=mid
	print(rt if Asum-K>0 else 0)
	
if __name__ == '__main__':
	main()

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }

ll func(ll x){
    if(x<=1){ return 1;}
    else{ return func(x/2)+1; }
}

ll inf = 1e9+7;

int main(){
    ll N; cin>>N;
    ll a[N];
    ll ord_max = 0;
    REP(i,N){
        cin >> a[i];
        chmax(ord_max, func(a[i]));
    }
    ll ans = 0;
    REP(ord,ord_max){
        ll temp = 0;
        REP(i,N){
          if( (a[i]>>ord)&1 ){++temp;}
        }
        ans += ( ((temp)*(N-temp)%inf) * ((1LL<<ord)%inf) )%inf;
        ans %= inf;
    }
    cout << ans <<"\n";
}

Measured memory_bytes: 2560
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int h,w,d;
    cin>>h>>w>>d;
    int a[h][w];
    vector<P> c(h*w+1);
    rep(i,h) rep(j,w){
        cin>>a[i][j]; // 1~h*w
        c[a[i][j]]=P(i,j);
    }

    vec b(90000+100);
    for(int i=1;i<=d;i++){
        int memo=i;
        b[memo]=0;
        while(memo+d<=h*w){
            b[memo+d]=b[memo]+abs(c[memo+d].fs-c[memo].fs)+abs(c[memo+d].sc-c[memo].sc);
            memo+=d;
        }
    }


    int q;
    cin>>q;
    rep(i,q){
        int l,r; cin>>l>>r;
        int ans=b[r]-b[l];
        cout<<ans<<endl;
    }
    
    
}

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

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

int main(){
  int N[3];
  for (int i = 0; i < 3; i++) {
    cin >> N[i];
  }
  sort(N, N + 3,greater<int>());
  int ans = N[0]*10 + N[1] + N[2];
  cout << ans << endl;
}

Measured memory_bytes: 256
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s, t;
    cin>>s>>t;
    int c = 0;
    f0(i,3) c+=s[i]==t[i];
    cout << c;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(n);
    REP(i,n) cin >> a[i];
    vvll dp(n+1,vll(3,0));
    dp[1][0] = 0;
    dp[1][1] = 0;
    dp[1][2] = a[0];
    for(int i=1;i<n;++i){
        if((i+1)%2==0){
            dp[i+1][0] = max(dp[i][1], dp[i-1][0]+a[i]);
            dp[i+1][2] = max(dp[i-1][2]+a[i], dp[i][2]);
            dp[i+1][1] = dp[i+1][2];

        }else{
            dp[i+1][1] = max(dp[i][2], dp[i-1][1]+a[i]);
            dp[i+1][0] = dp[i+1][1];
            dp[i+1][2] = dp[i-1][2]+a[i];
        }
    }
    cout << dp[n][1] << endl;
    return 0;
}

Measured memory_bytes: 15592
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

	a := N / 100
	c := N % 10

	if a == c {
		out("Yes")
	} else {
		out("No")
	}

}


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 9)

n, m = map(int, input().split())


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

    def find(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.root[x] += self.root[y]
        self.root[y] = x

    def size(self, x):
        return -1 * self.root[self.find(x)]


union_find = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    union_find.unite(a, b)

ans = 0
for i in range(n):
    ans = max(ans, union_find.size(i))

print(ans)


Measured memory_bytes: 35884
from math import radians, sin, cos

def datasets():
    while True:
        ss = raw_input().split(',')
        dis = int(ss[0])
        deg = int(ss[1])
        if dis == deg == 0:
            return
        yield dis, deg

# result
x = 0
y = 0

# current angle
ang = radians(90)

for dis, deg in datasets():
    rad = radians(deg)
    x += dis * cos(ang)
    y += dis * sin(ang)
    ang -= rad
print int(x)
print int(y)

Measured memory_bytes: 5672
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:
int h,w,n;
const int limit = 200010;
int x[limit],y[limit];

set<int> object;
set<int> objects[limit];

int main(void){
	cin >> h >> w >> n;
	rep(i, n) cin >> x[i] >> y[i];
	rep(i, n) x[i]--,y[i]--;

	rep(i, n) objects[y[i]].insert(x[i]);


	object.insert(h);
	for(auto &elem: objects[0]){
		object.insert(elem);
	}

	int ans = 0, cur = 0;
	
	rep(i, 1, h + 1){
		if(object.find(i) != end(object)){
			cout << ans + 1 << endl;
			return 0;
		}
		ans++;
		
		if(cur + 1 < w and objects[cur + 1].find(i) == end(objects[cur + 1])){
			cur++;
			for(auto &elem: objects[cur]){
				object.insert(elem);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 29824
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = solve(n, a)
    print(ans)


def solve(n, a):
    x = {}
    for i in range(n):
        tmp = i - a[i] + 1
        if tmp >= 0:
            if tmp in x:
                x[tmp] += 1
            else:
                x[tmp] = 1
    ans = 0
    for i in range(n):
        tmp = a[i] + i + 1
        if tmp in x:
            ans += x[tmp]
    return ans


if __name__ == '__main__':
    main()

Measured memory_bytes: 32376
import           Control.Applicative
import           Control.Monad

sort' :: ([Int], [Int]) -> IO ([Int], [Int])
sort' (ns, []    ) = return (ns, [])
sort' (ns, o : os) = do
  let ns1 = insert' o ns
  let os1 = os
  putStrLn $ disps (ns1, os1)
  sort' (ns1, os1)

insert' :: Int -> [Int] -> [Int]
insert' n ts = h ++ [n] ++ t
 where
  h = takeWhile (<= n) ts
  t = dropWhile (<= n) ts

disps :: ([Int], [Int]) -> String
disps ([], os) = disp os
disps (ns, []) = disp ns
disps (ns, os) = disp ns ++ " " ++ disp os

disp :: [Int] -> String
disp xs = unwords $ map show xs

main = do
  n  <- readLn
  ts <- map (read :: String -> Int) . take n <$> fmap words getLine
  sort' ([], ts)



Measured memory_bytes: 4176
fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    val length = s.size
    
    val ls = IntArray(length)
    val rs = IntArray(length)
    var gather = IntArray(length)
    
    for (i in length - 2 downTo 0) {
        if (s[i + 1] == 'L') {
            ls[i] = ls[i + 1] + 1
        }
    }
    
    for (i in 1 until length) {
        if (s[i - 1] == 'R') {
            rs[i] = rs[i - 1] + 1
        }
    }
    
    for (i in 0 until length) {
        val l = ls[i]
        val r = rs[i]
        
        if (l == 0 && r == 0) {
            continue
        }
        
        if (i != 0 && i != length - 1 && s[i - 1] == s[i] && s[i + 1] == s[i]) {
            continue
        }
        
        val gatherEven = l / 2 + r / 2 + 1
//        val gatherOdd = l / 2 + r / 2 + if (l % 2 == 1) 1 else 0 + if (r % 2 == 1) 1 else 0
        gather[i] = gatherEven
    }
    
    println(gather.joinToString(" "))
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 39936
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

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

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll a, b;
	cin >> a >> b;
	ll target = gcd(a, b);
	ll res = target;
	vector<ll>ans;
	ans.push_back(1);
	for (ll i = 2;i < sqrt(target) + 1;++i) {
		while (res % i == 0) {
			res /= i;
			ll n = ans.size();
			if (ans[n - 1] != i) {
				ans.push_back(i);
			}
		}
	}
	if (res != 1) {
		ans.push_back(res);
	}
	cout << ans.size() << endl;
	return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll X,A;
    cin >> X >> A;        

    if(A <= X)
        cout << 10 << endl;
    else
        cout << 0 << endl;

}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;
int main(){
    int n;
    cin >> n;
    map<int,int> a;
    for(int i(0);i<n;i++){
        int x;
        cin >> x;
        a[x] = i+1;
    }

    for(int i(1);i<=n;i++){
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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

signed main() {
    cin >> N;
    vi a(N), b(N);
    REP(i, N)
    cin >> a[i] >> b[i];
    sort(ALL(a));
    sort(ALL(b));

    if (N & 1) {
        ll mn = a[N / 2];
        ll mx = b[N / 2];
        cout << mx - mn + 1 << endl;
    } else {
        ll mn = a[N / 2 - 1] + a[N / 2];
        ll mx = b[N / 2 - 1] + b[N / 2];
        dump(a, b);
        cout << mx - mn + 1 << endl;
    }
}

Measured memory_bytes: 4840
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <functional>
 
using namespace std;

int main() {
    static const int ary[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<ary[k-1];
}

Measured memory_bytes: 256