akhauriyash/Code-Regression huggingface dataset:
H, W = tuple(int(i) for i in input().split())
As = [input() for i in range(H)]

a = [i for i in As if "#" in i]
b = ["".join(j[i] for j in a) for i in range(W)]
b_ = [i for i in b if "#" in i]
a_ = ["".join(j[i] for j in b_) for i in range(len(b_[0]))]

for i in a_:
  print(i)


Measured memory_bytes: 3064
n,k = map(int,input().split())
d = list(map(int,input().split()))
sset = set(i for i in range(1,10)) - set(d)

while True:
    for x in d:
        if str(x) in str(n):
            n += 1
            break
    else:
        print(n)
        break


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int m;
  cin >> m;
  cout << 48 - m;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t N;
  cin >> N;
  
  vector<int64_t> A(N);
  int64_t m = 0;
  for(int64_t i = 0 ; i < N ; i++){
    cin >> A.at(i);
    m = max(m, A.at(i));
  }
  
  vector<int64_t> list(m);
  for(int64_t i = 0; i < N; i++){
    list.at(A.at(i) - 1)++;
  }
  
  vector<int64_t> com(m);
  int64_t sum = 0;
  for(int64_t i = 0; i < m; i++){
    int64_t a = list.at(i);
    com.at(i) = a * (a-1) /2;
    sum += com.at(i);
  }
/*  
  for(int i = 0; i < m; i++){
    cout << list.at(i) << " ";
  }
  cout << endl;
*/  
  for(int64_t k = 0; k < N; k++){
    int64_t a = list.at(A.at(k) - 1);
    int64_t b = a-1;
    int64_t memo = sum;
    sum -= a * (a-1) / 2;
    sum += b * (b-1) / 2;
    cout << sum << endl;
    sum = memo;
  }
  
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;

int main(void){
    long n;
    vector <int> a;
    long x = 0;
    long sub;
    long sum = 0;
    long ans = INT_MAX;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> sub;
        a.push_back(sub);
        sum += sub;
    }
    
    for(int i = 0; i < n - 1; i++){
        x += a[i];
        ans = min(abs(ans), abs(sum - 2 * x));
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1400
N , X = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
a = 0
for i in range(N):
  a += A[i]
  if a > X:
    break
if i == N - 1:
  if a == X:
    print(i + 1)
  else:
    print(i)
if i < N - 1:
  print(i)


Measured memory_bytes: 8952
#include <stdio.h>

int main(void){

	int a,b,c;
    scanf("%d %d %d", &a ,&b, &c);
    if(a < b){
    	if(b < c){
    	    printf("Yes\n");
    }
        else{
    	    printf("No\n");
    }
    }	else{
    		printf("No\n");
    	}
	return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = String.valueOf(sc.next().charAt(0)).toUpperCase();
        String b = String.valueOf(sc.next().charAt(0)).toUpperCase();
        String c = String.valueOf(sc.next().charAt(0)).toUpperCase();

        System.out.println(a + b + c);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 21332
def deep_copy(a)
  Marshal.load(Marshal.dump(a))
end

def change(h,w)
  c=deep_copy(C)
  H.times do |i|
    next if h[i].zero?
    W.times do |j| c[i][j]=?R end
  end
  W.times do |j|
    next if w[j].zero?
    H.times do |i| c[i][j]=?R end
  end
  c.flatten.join
end

H,W,K=gets.split.map(&:to_i)
C=H.times.map{gets.chop.chars}
res=[]
0.upto(2**H) do |h|
  0.upto(2**W) do |w|
    r=change(h,w)
    res<<r if K==r.count(?#)
  end
end
p res.uniq.size


Measured memory_bytes: 14280
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n;
  cin>>n;
  long long cnt=0;
  long long a;
  long long ans=0;
  REP(i,n){
    cin>>a;
    if(a==0){
      ans += cnt/2;
      cnt = 0;
    }else{
      cnt += a;
    }
    if(i==n-1){
      ans += cnt/2;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> C(N,1e10),S(N,1e10),F(N,1e10);
    vector<pair<ll,ll>> memo(N,pair<ll,ll>(1e10,0));
    rep(i,N-1){
        cin >> C[i] >> S[i] >> F[i];
    }
    rep(i,N){
        ll t = 0;
        for(int j = i;j<N-1;j++){
            if(t <= S[j]) t=S[j];
            else if(t%F[j]) t +=F[j]-(t % F[j]);
            t += C[j];
        }
        cout << t << endl;
    }

    /*
    memo[N-1].first = 0;
    memo[N-2].first = S[N-2] + C[N-2];
    memo[N-2].second = S[N-2];
    /*S[N-1] = 0;
    F[N-1] = 1;
    C[N-1] = 0;

    for(int i=N-3;i>=0;i--){
        if(S[i] + C[i] <= memo[i+1].second){
            memo[i].first = min(memo[i].first, memo[i+1].first);
            memo[i].second = ll((memo[i+1].second - C[i])/F[i])*F[i];
        }else{
            ll cnt = (S[i] + C[i] + F[i+1] - 1) / F[i+1];
            memo[i].first = min(memo[i].first, cnt*F[i+1]-S[i+1]+memo[i+1].first);
            memo[i].second = S[i];
        }
        //memo[i].second = max(S[i],memo[i+1].second);
        //cout << memo[i].second << endl;
    }
    rep(i,N){
        cout << memo[i].first << endl;
    }
    */
}


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

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

typedef unsigned long long ull;
const ull b=10007;

string t,p;

int main(void){
	cin >> t >> p;
	int n=t.size(),m=p.size();
	ull ph=0;
	rep(i,m) ph=ph*b+p[i];
	ull th=0;
	rep(i,m) th=th*b+t[i];
	ull fix=1;
	rep(i,m) fix*=b;

	for(int i=0;i+m<=n;++i){
		if(ph==th) cout << i << endl;
		th=th*b-fix*t[i]+t[i+m];
	}
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,K;
	cin >> N >> K;
	double ans = 0;
	rep1(i,N){
		double p = 1.0/N;
		int c = i;
		while(c<K) c*=2,p/=2;
		ans += p;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int x; int y; int s;
  int sum1,sum2;
  int max_price;

  while(1){
    scanf("%d %d %d",&x,&y,&s);
    if(x==0 && y==0 && s==0) break;

    sum1=0; sum2=0;
    max_price=0;
    for(int i=1;i<s;i++){
      for(int j=1;j<s;j++){
        sum1=i*(100+x)/100+j*(100+x)/100;

        if(sum1==s){
          sum2=i*(100+y)/100+j*(100+y)/100;
          if(max_price<sum2) max_price=sum2;
        }

      }
    }
    printf("%d\n",max_price);
  }
  return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

const int MAX_N=1005;

int id[MAX_N][MAX_N];

void makeid(){
  int ctr=0;
  rep(i,MAX_N){
    rep(j,MAX_N){
      if(i<j)id[j][i]=ctr++;
      else id[i][j]=ctr++;
    }
  }
}

int toid(int i,int j){
  if(i<j)swap(i,j);
  return id[i][j];
}
 
int main(){
  makeid();
  int n;cin>>n;
  vector<int> G[MAX_N*(MAX_N-1)];
  int a[n][n-1];
  
  rep(i,n){
    rep(j,n-1){
      cin>>a[i][j];a[i][j]--;
    }
  }
  
  int h[MAX_N*(MAX_N-1)]={};
  rep(i,n){
    rep(j,n-2){
      int b=toid(i,a[i][j]);
      int c=toid(i,a[i][j+1]);
      G[b].push_back(c);
      h[c]++;
    }
  }
  //cout<<-1<<endl;exit(0);
  vector<int> st;
  rep(i,MAX_N*(MAX_N-1)){
    if(h[i]==0)st.push_back(i);
  }
  vector<int> tsort;
  while(st.size()){
    int i=st.back();st.pop_back();
    tsort.push_back(i);
    for(auto v:G[i]){
      h[v]--;
      if(h[v]==0)st.push_back(v);
    }
  }
  if((int)tsort.size()!=MAX_N*(MAX_N-1)){
    cout<<-1<<endl;exit(0);
  }
  int dp[MAX_N*(MAX_N-1)]={};
  rep(i,tsort.size()){
    for(auto v:G[tsort[i]]){
      chmax(dp[v],dp[tsort[i]]+1);
    }
  }
  int ans=0;
  rep(i,MAX_N*(MAX_N-1)) chmax(ans,dp[i]);
  cout<<ans+1<<endl;
}


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

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

    long long n;
    cin >> n;

    map<long long, int> mp;
    long long tmp = n;

    for(long long i = 2; i <= (long long)sqrt(n); i++){
        int cnt = 0;
        while(tmp % i == 0){
            cnt++;
            tmp /= i;
        }
        if(cnt > 0){
            mp[i] = cnt;
        }
    }
    if(tmp != 1) mp[tmp] = 1;


    vector<int> OK;
    int diff = 3;
    OK.push_back(2);
    for(int i = 0; i < 1000; i++){
        OK.push_back(OK[i] + diff);
        diff++;
    }

    sort(OK.begin(), OK.end());

    long long ans = 0;
    for(auto &x: mp){
        ans++;

        int idx = upper_bound(OK.begin(), OK.end(), x.second - 1) - OK.begin();
        ans += idx;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;


int main() {
    long long n ;
    cin >> n  ;
    string s ;
  
    long long m,a,r,c,h ;
    m=a=r=c=h=0 ;
  
    for(int i=0;i<n;i++){
      cin >> s ;
      if(s[0]=='M') m++ ;
      if(s[0]=='A') a++ ;
      if(s[0]=='R') r++ ;
      if(s[0]=='C') c++ ;
      if(s[0]=='H') h++ ;
    }

    long long d[5] ;
    d[0] = m ;
    d[1] = a ;
    d[2] = r ;
    d[3] = c ;
    d[4] = h ;
  
    long long ans = 0 ;
    for(int i=0;i<5;i++)
    {
      for(int j=i+1;j<5;j++)
      {
        for(int k=j+1;k<5;k++)
        {
          long long tmp = d[i]*d[j]*d[k] ;
          ans+=tmp ;
        }
      }
    }
  
    cout << ans << endl ;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
#include <map>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int n; cin >> n;
    map<int, int> problems;
    while (n--) {
        int a; cin >> a;
        ++problems[a];
    }
    int m; cin >> m;
    while (m--) {
        int a; cin >> a;
        auto find = problems.find(a);
        if (find == problems.end() || find->second-- == 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  int L[M], R[M];
  for(int i=0; i<M; i++) {
    cin >> L[i] >> R[i];
  }
  int cnt=0;
  sort(L,L+M);
  sort(R,R+M);
  reverse(L,L+M);
  for(int i=1; i<=N; i++) {
    if(L[0]<=i&&R[0]>=i) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> xs(n), ys(m);
	for (int i = 0; i < n; ++i) cin >> xs[i];
	for (int j = 0; j < m; ++j) cin >> ys[j];
	
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());

	if (xs[n - 1] >= ys[0] || ys[0] <= x || xs[n - 1] >= y) {
		cout << "War" << endl;
	} else {
		cout << "No War" << endl;
	}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[1010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	sort(A,A+N);
	double B=0;
	FOR(i,N) {
		B+=1.0/A[i];
	}
	_P("%.12lf\n",1/B);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        
        int count = 0;
        
        for (int i = 0; i < N; i++) {
            int d1 = sc.nextInt();
            int d2 = sc.nextInt();
            
            if (d1 == d2) {
                count++;
                if (count == 3) {
                    System.out.println("Yes");
                    return;
                }
            } else {
                count = 0;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 35944
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() 
{
     ll n;
     cin>>n;
     ll ar[n];
     map<ll,ll> ma;
     ll su = 0;
     for(int i=0;i<n;i++)
     {
     	cin>>ar[i];
     	su+=ar[i];
     	ma[ar[i]]++;
     }
     ll q;
     cin>>q;
     ll b,c;
     while(q--)
     {
     	cin>>b>>c;
     	ll fi_cnt = ma[b];
     	ll dif = c-b;
     	ma[c]+=fi_cnt;
     	ma[b] = 0;
     	su+=(fi_cnt*dif);
     	cout<<su<<"\n";
     }
}

Measured memory_bytes: 10172
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	var N = parseInt(input[0][0], 10);
	var arr_TA = [];
	for (var i = 0; i < N; i++){
		arr_TA.push(input[i + 1].map(e => parseInt(e, 10)));
		arr_TA[i][0] = BigInt(arr_TA[i][0]);
		arr_TA[i][1] = BigInt(arr_TA[i][1]);
	}
	var tmp = [0n, 0n];
	var n;
	for (var i = 0; i < N; i++){
		if (arr_TA[i][0] >= tmp[0] && arr_TA[i][1] >= tmp[1]){
			tmp = [arr_TA[i][0], arr_TA[i][1]];
		} else if (arr_TA[i][0] >= tmp[0] && arr_TA[i][1] < tmp[1]){
			n = tmp[1] / arr_TA[i][1];
			if (tmp[1] % arr_TA[i][1] !== 0n) n = n + 1n;
			tmp = [arr_TA[i][0] * n, arr_TA[i][1] * n];
		} else if (arr_TA[i][0] < tmp[0] && arr_TA[i][1] >= tmp[1]){
			n = tmp[0] / arr_TA[i][0];
			if (tmp[0] % arr_TA[i][0] !== 0n) n = n + 1n;
			tmp = [arr_TA[i][0] * n, arr_TA[i][1] * n];
		} else if (arr_TA[i][0] < tmp[0] && arr_TA[i][1] < tmp[1]){
			n = tmp[0] / arr_TA[i][0];
			if (tmp[0] % arr_TA[i][0] !== 0n) n = n + 1n;	
			if (arr_TA[i][1] * n >= tmp[1]) ;
			else {
				n = tmp[1] / arr_TA[i][1];
				if (tmp[1] % arr_TA[i][1] !== 0n) n = n + 1n;
			}
			tmp = [arr_TA[i][0] * n, arr_TA[i][1] * n];
		}
	}
	console.log((tmp[0] + tmp[1]).toString());
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 30128
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
	int num,num1;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	num=min(b,d)-max(a,c);
	if(num<0)
	cout<<0<<endl;
	else
	cout<<num<<endl; 
}

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

using namespace std;

int main(void) {
  int ans = 700;
  string s; cin >> s;

  if (s == "ooo") {
    cout << 1000;
  } else if (s == "oox" || s == "oxo" || s == "xoo") {
    cout << 900;
  } else if (s == "oxx" || s == "xxo" || s == "xox") {
    cout << 800;
  } else {
    cout << 700;
  } cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw3(15,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,14) pw3[i]=3*pw3[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll R,G,B,N; cin>>R>>G>>B>>N;
    ll ans=0;
    rep(i,N/R+1)rep(j,N/G+1){
        ll rem=N-i*R-j*G;
        if(rem>=0 && rem%B==0) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3680
n,m = map(int, input().split())

l = [0]*m

for i in range(n):
    a = list(map(int,input().split()))
    for j in range(1,len(a)):
        l[a[j]-1]+=1

ans = 0
for i in range(m):
    if l[i]==n:
        ans += 1
print(ans)


Measured memory_bytes: 38256
#include <stdio.h>

int main() {

  int hana,taro,sum;
  int hn,tn;
  int tc[150];
  int hc[150];
  int i,j,k,l;
  int hsum,tsum;
  int min;
  int a,b,c,d;

  while(1) {
    a = -1;
    b = -1;
    hsum = 0;
    tsum = 0;
    min = 300;

    scanf("%d %d",&tn,&hn);

    if(tn == 0 && hn == 0) {
      break;
    }

    for(i = 0; i < tn ; i++) {

      scanf("%d",&tc[i]);
      tsum = tsum + tc[i];

    }
    for(i = 0;i<hn ; i++) {

      scanf("%d", &hc[i]);
      hsum += hc[i];
    }

    for(j = 0; j<hn; j++ ) {
      for( i=0; i<tn; i++) {

	if(tsum-tc[i]+hc[j] == hsum-hc[j] + tc[i]) {
	  if(min > tc[i] + hc[j]) {
	    min = tc[i] + hc[i];
	    a =i;
	    b= j;
	  }
	}
      }
    }
    if(a == -1 && b == -1 ) {
      printf("-1\n");
    } else {
    printf("%d %d\n",tc[a],hc[b]);
    }

  }

  return 0;

}

      

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    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 line
    #define trace(...)
#endif

//int dx[] = {-1, 0, 1, 0},                  dy[] = {0, 1, 0, -1};                  // 4 Direction
//int dx[] = {-1, 0, 1, 0, -1, 1, 1, -1},    dy[] = {0, 1, 0, -1, -1, 1, -1, 1};    // 8 Direction

inline ll power(ll a, ll p){
    ll res = 1, x = a;
    while (p){
        if (p & 1) res = (res * x);
        x = (x * x), p >>= 1;
    }
    return res;
}
inline ll big_mod(ll a, ll p, ll m){
    ll res = 1 % m, x = a % m;
    while (p){
        if (p & 1) res = (res * x) % m;
        x = (x * x) % m, p >>= 1;
    }
    return res;
}

const ll INF = 1e15;


int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;

    int n;
    cin >> n;

    int odd = (n + 1) / 2;

    cout << odd / (1.0 * n) << endl;

    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    a, b, c = input().split()
    print("A" + b[0] + "C")


if __name__ == '__main__':
    main()


Measured memory_bytes: 4072
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
signed main(){
    string s;
    int k;
    cin>>s>>k;
    int ans=0;
    int n=s.size();
    int cnt=1;
    vector<int> t;
    for(int i=1;i<n;i++){
        if(s[i-1]!=s[i]){
            t.push_back(cnt);
            cnt=1;
        }else{
            cnt++;
        }
    }
    t.push_back(cnt);
    if(t.size()==1){
        ans=n*k/2;
    }else if(s[0]==s[n-1]){
        ans+=(t[0]+t[t.size()-1])/2*(k-1);
        ans+=t[0]/2;
        ans+=t[t.size()-1]/2;
        for(int i=1;i<t.size()-1;i++){
            ans+=t[i]/2*k;
        }
    }else{
        for(int i=0;i<t.size();i++){
            ans+=t[i]/2*k;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 3);
  (v[0], v[1], v[2])
}

fn main() {
  use std::cmp::min;
  let (a, b, n) = read_touple::<usize>();
  let t = min(a, b);
  let mut ans = 0;
  if n < b - 1 {
    ans = (a*n) / b - a*(n/b);
  } else {
    ans = (a*(b-1))/b - a*((b-1)/b);
  }

  println!("{}", ans);
}


Measured memory_bytes: 2112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _072
{
    class Program
    {
        static void Main(string[] args)
        {
            ProblemC.Solve();

        }
    }

    class ProblemC
    {
        public static void Solve()
        {
            string N = Console.ReadLine();

            int[] array = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            // 数の個数を取得。
            Dictionary<int, int> cntMap = new Dictionary<int, int>();

            for (int i = 0; i < array.Length; i++)
            {
                if (cntMap.ContainsKey(array[i]))
                {
                    cntMap[array[i]]++;
                }
                else
                {
                    cntMap[array[i]] = 1;
                }
            }

            int max = 0;
            foreach (var key in cntMap.Keys)
            {
                int cnt = cntMap.ContainsKey(key - 1) ? cntMap[key - 1] : 0;
                cnt += cntMap[key];
                cnt += cntMap.ContainsKey(key + 1) ? cntMap[key + 1] : 0;

                if (cnt > max)
                {
                    max = cnt;
                }
            }

            Console.WriteLine(max);

            return;


        }

        
    }
}


Measured memory_bytes: 20960
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int a,b;
  while(cin >> a >> b) {
    vector<int> zi(200);
    zi[a]++;
    zi[b]++;
    while(cin>>a>>b,a+b) {
      zi[a]++;
      zi[b]++;
    }
    int i;
    for(i=3;i<200;i++) {
      if (zi[i] % 2)
        break;
    }
    if (zi[1]%2 && zi[2]%2 && i==200)
      cout << "OK" << endl;
    else
      cout << "NG" <<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long t=0,i=0,j=0,A,B,C;
  string ans;
  
  cin >> A >> B >> C;

  if (A==B&&B==C&&A==C||A!=B&&A!=C&&B!=C)
  {
    ans="No";
  }
  else
  {
    ans="Yes";
  }
  
  

  //printf ("%lld\n",ans);
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
 © 2020-01-31 19:54:48 crystaalroo all Rights Reserved
*/
#include <bits/stdc++.h>
#define fore(i, a, b) for(int i = (a); i <(b); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
#define sz(x) (int) (x).size()
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long lli;
typedef pair<lli,lli > ii;
#define ENDL '\n'
#define deb(x) cout << #x": " << (x) << endl;
const int INF=1e9+5;
const lli mod = 1e9+7;
const int N = 1e5+5;


int main(){_
  lli n,w; cin>>n>>w;
  vector<ii>k(n);
  fore(i,0,n) cin >> k[i].f >> k[i].s;
  lli dp[N];
  fore(j,0,N)dp[j]=INF;
  dp[0]=0;
  sort(all(k));
  fore(i,0,n){
     for(lli j = N; j>k[i].s;j--)if(dp[j-k[i].s]!=INF)if(dp[j]>dp[j-k[i].s]+k[i].f and dp[j-k[i].s]+k[i].f<=w)dp[j]=dp[j-k[i].s]+k[i].f;
     if(dp[k[i].s]!=INF)dp[k[i].s]=min(dp[k[i].s],dp[k[i].s]+k[i].f);
     else dp[k[i].s]=k[i].f;
  }
  for(int i = N-1; i>=0;i--)if(dp[i]!=INF){cout<<i<<ENDL; return 0;}

}


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

int main() {
	int len, ans = 0, temp = 0, angka;
	char teks[100010];
	scanf("%s", teks);
	len = strlen(teks);
	for (int i = 0; i < len; i++) {
		angka = teks[i] - '0';
		if (angka != (i % 2))
			ans++;
	}
	for (int i = 0; i < len; i++) {
		angka = teks[i] - '0';
		if (angka == (i % 2))
			temp++;
	}
	if (temp < ans)
		ans = temp;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if ((N % 1000)%111 == 0){
    cout << "Yes" <<endl;
  }
  else if (N % 1110 <=9){
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 256
/* 
 * エラトステネスの篩を使った問題
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1172&lang=jp
 */
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl
#define PRIME_MAX 123456*2

using namespace std;

int main() {
	int N;
	bool prime[PRIME_MAX+1];

	prime[0] = true;
	prime[1] = true;
	REP(i,2,PRIME_MAX+1) prime[i] = true;

	//エラトステネスの篩
	REP(i,2,PRIME_MAX+1) {
		if (prime[i]) {  
			for (int j=i+i; j<PRIME_MAX+1; j+=i) prime[j] = false; 
		}
	}

	int prime_cnt;
	while(cin >> N && N) {
		prime_cnt=0;
		REP(i,N+1,2*N+1) { //n < i <= 2*n
			if (prime[i]) {
				prime_cnt++;
			}
		}
		cout << prime_cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1400
import sys

s=input()
t=input()
s1,t1="",""

for i in range(len(s)):
  if i!=0:
    if s1[0]>=s[i]:
      s1=s[i]+s1
    
    else:
      s1+=s[i]
      
  else:
    s1=s[i]
    
for i in range(len(t)):
  if i!=0:
    if t1[0]<=t[i]:
      t1=t[i]+t1
    
    else:
      t1+=t[i]
      
    if t1>s1:
      print("Yes")
      sys.exit()
      
  else:
    t1=t[i]
    
print("No")  

Measured memory_bytes: 3188
//
//  abc057C.cpp
//  
//
//  Created by 楊承昊 on 2017/3/26.
//
//


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    long long int N;
    while(cin>>N)
    {
        long long int qw=sqrt(N),mm=0;
        while(N%(qw-mm)!=0)
        {
            mm++;
        }
        long long int sum=N/(qw-mm),ans=0;
        while(sum>0)
        {
            sum/=10;
            ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    ll mod = 1e9 + 7;
    ll ans = 1;
    for (int i = 1; i <= n; i++) {
        ans *= i;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		solver();
	}

	final long MODULO = 924844033;
	final long root = 5;
	int[] size;
	ArrayList<Integer>[] g;

	void solver() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		size = new int[n + 1];
		g = new ArrayList[n];
		for (int i = 0; i < n; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < n - 1; ++i) {
			int a = Integer.parseInt(sc.next())- 1;
			int b = Integer.parseInt(sc.next()) - 1;
			g[a].add(b);
			g[b].add(a);
		}

		dfs(-1, 0);

		int[] a = new int[n + 1];
		for (int i = 1; i < n; ++i) {
			++a[size[i]];
			++a[n - size[i]];
		}
		long[] fac = new long[n + 1];
		long[] invfac = new long[n + 1];
		fac[0] = 1;
		for (int i = 1; i <= n; ++i) {
			fac[i] = (fac[i - 1] * i) % MODULO;
		}
		invfac[n] = inv(fac[n]);
		for (int i = n - 1; i >= 0; --i) {
			invfac[i] = (invfac[i + 1] * (i + 1)) % MODULO;
		}
		long[] f = new long[n + 1];
		long[] h = new long[n + 1];
		for (int i = 0; i <= n; ++i) {
			f[i] = a[i] * fac[i] % MODULO;
			h[i] = invfac[n - i];
		}
		f = mul(f, h);
		for (int k = 1; k <= n; ++k) {
			long ans = n * fac[n] % MODULO * invfac[n - k] % MODULO * invfac[k] % MODULO;
			ans -= inv(fac[k]) * f[n + k] % MODULO;
			if (ans < 0)
				ans += MODULO;
			System.out.println(ans);
		}

	}

	void dfs(int pre, int cur) {
		size[cur] = 1;
		for (int dst : g[cur]) {
			if (dst != pre) {
				dfs(cur, dst);
				size[cur] += size[dst];
			}
		}
	}

	long[] mul(long[] a, long[] b) {
		int n = Integer.highestOneBit(a.length + b.length) << 1;
		a = Arrays.copyOf(a, n);
		b = Arrays.copyOf(b, n);
		a = fft(a, false);
		b = fft(b, false);
		for (int i = 0; i < n; ++i) {
			a[i] = (a[i] * b[i]) % MODULO;
		}
		a = fft(a, true);
		long inv = pow(n, MODULO - 2);
		for (int i = 0; i < n; ++i) {
			a[i] = (a[i] * inv) % MODULO;
		}
		return a;
	}

	long[] fft(long[] a, boolean inv) {
		int n = a.length;
		int c = 0;
		for (int i = 1; i < n; ++i) {
			for (int j = n >> 1; j > (c ^= j); j >>= 1)
				;
			if (c > i) {
				long d = a[c];
				a[c] = a[i];
				a[i] = d;
			}
		}

		for (int i = 1; i < n; i *= 2) {
			long w = pow(root, (MODULO - 1) / (2 * i));
			if (inv)
				w = pow(w, MODULO - 2);
			for (int j = 0; j < n; j += 2 * i) {
				long wn = 1;
				for (int k = 0; k < i; ++k) {
					long u = a[k + j];
					long v = (a[k + j + i] * wn) % MODULO;
					a[k + j] = (u + v) % MODULO;
					a[k + j + i] = (u - v + MODULO) % MODULO;
					wn = (wn * w) % MODULO;
				}
			}
		}
		return a;
	}

	long pow(long a, long n) {
		long ret = 1;
		for (; n > 0; n >>= 1, a = (a * a) % MODULO) {
			if (n % 2 == 1) {
				ret = (ret * a) % MODULO;
			}
		}
		return ret;
	}

	long inv(long a) {
		return pow(a, MODULO - 2);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 134012
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  long long A[222222], S = 0, T = 0;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> A[i];

    (S += A[i]) %= MOD;
  }

  for (int i = 0; i < N; i ++) {
    S = (S - A[i] + MOD) % MOD;

    (T += A[i] * S % MOD) %= MOD;
  }

  std::cout << T << std::endl;

  return 0;
}


Measured memory_bytes: 5184
n = gets.to_i
ans = []
(1..n-1).each do |a|
  b = n - a
  sum_a = a.to_s.chars.map(&:to_i).inject(:+)
  sum_b = b.to_s.chars.map(&:to_i).inject(:+)
 
  ans << (sum_a + sum_b)
end
puts ans.min

Measured memory_bytes: 2684
#include <stdio.h>

long long prime[1000] = {}, coeff[1000001] = {}, sum[1000001] = {};

int factorize(long long n, long long p[], int m[])
{
	int i, k;
	for (i = 0, k = 0; prime[i] * prime[i] <= n; i++) {
		if (n % prime[i] != 0) continue;
		p[k] = prime[i];
		for (m[k] = 0; n % p[k] == 0; m[k]++, n /= p[k]);
		k++;
	}
	if (n > 1) {
		p[k] = n;
		m[k++] = 1;
	}
	return k;
}

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int main()
{
	int i, N;
	long long A[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	
	int j, k;
	for (i = 2, k = 0; i <= 1010; i++) {
		for (j = 0; j < k; j++) if (i % prime[j] == 0) break;
		if (j == k) prime[k++] = i;
	}
	
	int h, l[100], m[100];
	long long p[100], n[2];
	for (i = 1; i <= N; i++) {
		sum[0] = (sum[0] + A[i]) % 998244353;
		k = factorize(A[i], p, m);
		for (j = 1, l[0] = 1; j <= k; j++) l[j] = 0;
		n[0] = p[0];
		n[1] = 1 - p[0];
		while (l[k] == 0) {
			coeff[n[0]] = n[1];
			sum[n[0]] = (sum[n[0]] + A[i] / n[0]) % 998244353;
			
			for (j = 0; j < k && l[j] == m[j]; j++);
			if (j < k) {
				n[0] *= p[j];
				if (l[j] == 0) n[1] *= 1 - p[j];
			}
			for (l[j--]++; j >= 0; l[j--] = 0) {
				for (h = 0; h < l[j]; h++) n[0] /= p[j];
				if (l[j] > 0) n[1] /= 1 - p[j];
			}
		}
	}
	
	long long ans = sum[0] * (sum[0] - 1) % 998244353;
	for (i = 2; i <= 1000000; i++) {
		if (coeff[i] != 0) ans = (ans + ((sum[i] * sum[i] % 998244353) * i % 998244353) * coeff[i] % 998244353 + 998244353) % 998244353;
	}
	
	printf("%lld\n", div_mod(ans, 2, 998244353));
	fflush(stdout);
	return 0;
}

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


int main(int argc, const char * argv[])
{
    char str[21], tmp;
    int i, len;
    for (i = 0; i < 21; i++) {
        scanf("%c", &str[i]);
        if (str[i] == '\n') {
            break;
        }
    }
    len = strlen(str);
    
    for (i = 0; i < len / 2; i++) {
        tmp = str[i];
        str[i] = str [len - 2 - i];
        str [len - 2 - i] = tmp;
    }
    
    for (i = 0; i < len; i++) {
        printf("%c", str[i]);
    }
    
    
    return 0;
}

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

# define pi 3.1415926535897932384626

void solve() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double t1 = 2 * pi * (h + m / 60) / 12;
	double t2 = 2 * pi * (m) / 60;
	double x1, x2, y1, y2;
	x1 = a * cos(t1);
	y1 = a * sin(t1);
	x2 = b * cos(t2);
	y2 = b * sin(t2);
	cout << fixed << setprecision(20) << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif
	solve();
	return 0;
}

Measured memory_bytes: 4180
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int dayCount = scan.nextInt();

		// 日数、活動種別、満足度及び累積満足度
		int dp[][][] = new int[dayCount][3][2];

		for (int i = 0; i < dayCount; i++) {

			for (int j = 0; j < 3; j++) {

				dp[i][j][0] = scan.nextInt();
			}
		}

		for (int j = 0; j < 3; j++) {

			dp[0][j][1] = dp[0][j][0];
		}

		// 配る方式
		for (int i = 0; i < dayCount - 1; i++) {

			for (int j = 0; j < 3; j++) {

				for (int k = 0; k < 3; k++) {

					if (k != j) {

						dp[i + 1][k][1] = Math.max(
								dp[i + 1][k][1],
								dp[i][j][1] + dp[i + 1][k][0]);
					}
				}
			}
		}

		int answer = 0;

		for (int j = 0; j < 3; j++) {

			answer = Math.max(
					answer,
					dp[dayCount - 1][j][1]);
		}

		System.out.println(answer);
	}
}


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

int main(){
    int d,n;
    cin>>d>>n;
    if(n==100) n++;
    if(d==0) cout<<n<<"\n";
    else if(d==1) cout<<100*n<<"\n";
    else if(d==2) cout<<10000*n<<"\n";
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> hi(n);
    int ent = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> hi.at(i);
        if (hi.at(i) >= k)
        {
            ent++;
        }
    }

    cout << ent << endl;
    return 0;
}

Measured memory_bytes: 640
main = do
  [n, k] <- map read . words <$> getLine
  print $ prob n k

prob n k = (fromIntegral $ sum $ map ((2 ^) . ((times 1) -) . times) [1..n])
    / (fromIntegral $ n * 2 ^ (times 1))
  where
    times i = length $ takeWhile (< k) $ iterate (*2) i

Measured memory_bytes: 1020
int main(void)
{
        int i,j,wide,height;
        int h[10000],w[10000];
        i = 1;
        while(1){
                scanf("%d %d",&h[i],&w[i]);
                if(h[i] == 0 && w[i] == 0){
                        break;
                }
                i++;
        }
        for(j = 1;j < i;j++){
                for(height = 1;height <= h[j];height++){
                        for(wide = 1;wide <= w[j];wide++){
                                printf("#");
                        }
                        printf("\n");
                }
                printf("\n");
        }
        return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll




signed main(){
  int b;

  while(true){
    cin>>b;
    if(b==0) break;
    rrep(i,(int)1e6){
      if((2*b-i*(i-1))%(2*i)==0){
        int a = (2*b-i*(i-1))/(2*i);
        if(a<=0) continue;
        cout<<a<<' '<<i<<endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 3060
s = input()
t = input()

s_to_t = {}
t_to_s = {}
enable = True
for i in range(len(s)):
    char_s = s[i]
    char_t = t[i]
    if char_s in s_to_t and char_t != s_to_t[char_s]:
        enable = False
        break
    if char_t in t_to_s and char_s != t_to_s[char_t]:
        enable = False
        break
    s_to_t[char_s] = char_t
    t_to_s[char_t] = char_s

if enable:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, y;
    cin >> n >> y;
    y /= 1000;
    for (int i = 0; i * 10 <= y; i++)
    {
        for (int j = 0; j + i * 10 <= y; j++)
        {
            int k = n - i - j;
            if (k >= 0 && 10 * i + 5 * j + k == y)
            {
                printf("%d %d %d\n", i, j, k);
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

vector <vector <int> > edge;
vector <ll> ans;
vector <int> cannot, c, cnt;
int n;
inline int dfs_cnt (int v, int p = -1) {
    cnt[v] = 1;
    for (int to : edge[v]) {
        if (to != p) {
            cnt[v] += dfs_cnt(to, v);
        }
    }
    return cnt[v];
}
inline void dfs (int v, int p = -1) {
    ans[c[v]] += cnt[v] * 1ll * (n - cnt[v] - cannot[c[v]] + 1ll);
    int have = cannot[c[v]];
    cannot[c[v]] = n - cnt[v] + 1;
    int sum = cnt[v] - 1;
    for (int to : edge[v]) {
        if (to == p) continue;
        ans[c[v]] += cnt[to] * 1ll * (sum - cnt[to]);
        sum -= cnt[to];
        cannot[c[v]] = n - cnt[v] + 1 + cnt[v] - 1 - cnt[to];
        dfs(to, v);
    }
    cannot[c[v]] = have + cnt[v];
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    edge.resize(n);
    ans.resize(n);
    cannot.resize(n);
    c.resize(n);
    cnt.resize(n);
    for (auto &i : c) {
        cin >> i;
        --i;
    }
    for (int i = 1, a, b; i < n; i++) {
        cin >> a >> b;
        --a, --b;
        edge[a].pb(b);
        edge[b].pb(a);
    }
    dfs_cnt(0);
    dfs(0);
    for (auto &i : ans) cout << i << '\n';
}


Measured memory_bytes: 33764
function Main(input) {
  input=input.trim();
  var A = input.split(" ")[0];
  var B = input.split(" ")[1];
  if(A == "H"){
    console.log(B);
  }else{
    console.log((B === "H") ? "D" : "H");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int a[] = {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 << a[K-1] << endl;
}

Measured memory_bytes: 256