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

int dp[100001];

vector<int> graph[100000+1];

int solve(int src){
    
    if(dp[src]!=-1)
        return dp[src];
    bool leaf = 1;
    int bestlen = 0;
    
    for(int child : graph[src]){
        leaf = 0 ;
        bestlen = max(bestlen,solve(child));
    }
    
    return dp[src] = leaf ? 0 : 1+bestlen;
}

int main() {
	// your code goes here
	
	int n,m;
	cin>>n>>m;
	
	
	
	int x , y;
	for(int i=1;i<=m;i++){
	    cin>>x>>y;
	    graph[x].push_back(y);
	}
	
	memset(dp,-1,sizeof(dp));
	
	int ans = 0;
	
    for(int i=1;i<=n;i++){
        ans=max(ans,solve(i));
    }
	
    cout<<ans<<endl;

	
	return 0;
}


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

using namespace std;

int x, y, s;

int main(int argc, char const *argv[]) {
    while(cin>>x>>y>>s, x||y||s) {
        double tax_before = x / 100.0;
        double tax_after = y / 100.0;
        // cout<<"tax_before = "<<tax_before<<endl;
        // cout<<"tax_after = "<<tax_after<<endl;
        int ans = 0;
        for (int i = 1; i < s; ++i) {
            for (int j = 1; j < s; ++j) {
                int before_i = i + i * tax_before;
                int before_j = j + j * tax_before;
                int sum_before = before_i + before_j;
                //cout<<"sum_before = "<<sum_before<<endl;
                if ( sum_before == s ) {
                    // cout<<"i = "<<i<<", j = "<<j<<endl; 
                    int after_i = i + i * tax_after;
                    int after_j = j + j * tax_after;
                    // cout<<"after_i = "<<after_i<<endl;
                    // cout<<"after_j = "<<after_j<<endl;
                    int sum_after = after_i + after_j;
                    ans = max (ans, sum_after);
                }
            }
        }

        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3064
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main() {
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int X, Y, Z, ans = 0;
	cin >> X >> Y >> Z;

	X -= Z;
	ans = X / (Y + Z);

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if c < a {
		a, b, c, d = c, d, a, b
	}
	if b < c {
		fmt.Println(0)
		return
	}
	if d < b {
		fmt.Println(d - c)
		return
	}
	fmt.Println(b - c)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int counter(int n) {
	int sum = 0;
	while (n > 0) {
		sum = sum + n % 10;
		n = n / 10;
	}
	return sum;
 
}
int main() {
	int N ,a, b,total=0;
	cin >> N >> a >> b;
	for (int i = 1; i <= N;  i++) {
		int sum = counter(i);
		if (a <= sum && sum <= b)
			total = total + i;
	
	
	
	}
 
	cout << total<< endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int gcd(int a, int b){
    if(!b) return a;
    return gcd(b, a%b);
}

int main (){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    int mx = 0;
    for(int &a:A){
        cin >> a;
        mx = max(mx, a);
    }
    if(mx < K){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    
    int g = A[0];
    for(int i=1; i<N; i++){
        g = gcd(g, A[i]);
    }
    
    for(int i=0; i<N; i++){
        if(abs(A[i]-K)%g==0){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    
    cout << "IMPOSSIBLE" << endl;
    return 0;
}



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

int main()
{
    int n,T,i,j,k;
    cin>>n;
    vector<long long>v(n+3);
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }
    cin>>T;
    while(T--)
    {
        long long b,m,e;
        cin>>b>>m>>e;
        rotate(v.begin()+b,v.begin()+m,v.begin()+e);
    }
    long long ans=0;
    for(i=0;i<n;i++,ans++)
    {
        if(ans!=0)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;

ll sum[200010];
vector<int>graph[200010];

void dfs(int vertex,int root){
    for(int i=0;i<(int)graph[vertex].size();i++){
        int now=(int)graph[vertex][i];
        if(now!=root){
            sum[now]=sum[now]+sum[vertex];
            dfs(now,vertex);
        }
    }
}

int main(void){
    int n,q,a,b,p,x;
    cin>>n>>q;
    for(int i=1;i<=n-1;i++){
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        cin>>p>>x;
        sum[p]+=x;
    }
    dfs(1,1);
    for(int i=1;i<=n;i++){
        if(i==n)cout<<sum[n]<<endl;
        else cout<<sum[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 30464
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   
   int sum = 0;
   if(A>B){
    sum += A;
    A = A-1;
   }
   else
   {
    sum += B;
    B = B-1; 
   }
   if(A>B){
    sum += A;
    A = A-1;
   }
   else
   {
    sum += B;
    B = B-1; 
   }
   System.out.println(sum);
 }
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    string S;

    cin >> S;

    if(S.substr(2,1) == S.substr(3,1) && S.substr(4,1) == S.substr(5,1)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    
    return 0;

}

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

#define ll long long int 
ll mod=1e9+7;

// vector<int> g[200005];
// int vis[200005];
// queue<int> q;
// int level[200005];

// void dfs(int i)
// {
//     vis[i] = 1;
//     for(int j=0;j<g[i].size();j++)
//     {
//         int child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(int i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         int top = q.front();
//         int len_adj = g[top].size();
//         int j;
//         for(j=0;j<len_adj;j++)
//         {
//             int v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    int t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j,k;
        
        ll K;
        cin >> K;
        ll ans = 0;

        for(i=1;i<=K;i++)
        {
            for(j=1;j<=K;j++)
            {
                for(k=1;k<=K;k++)
                {
                    ll temp = __gcd(j,k);
                    ll gc = __gcd(i,temp);
                    ans += gc;
                }
            }
        }

        cout << ans  << '\n';
    }

    
    
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int n; cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }

    vector<pair<ll,int>> ab(n);
    rep(i,n) ab[i] = make_pair(a[i] + b[i],i); 
    sort(all(ab));
    reverse(all(ab));

    ll taka=0,ao=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            taka += a[ab[i].second];
        }else{
            ao += b[ab[i].second];
        }
    }
    cout << taka - ao << endl;
}


Measured memory_bytes: 3328
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    t = 0
    mt = 10 ** 10
    a = list(map(int, input().rstrip('\n').split()))
    s = sum(a)
    for i in range(n-1):
        t += a[i]
        mt = min(mt, abs(s - t - t))
    print(mt)


if __name__ == '__main__':
    slove()


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  vector<bool> prime(300000, true);
  prime.at(0) = prime.at(1) = false;
  for (int i = 2; i < 300000; i++) {
    if ((i % 7 == 1 || i % 7 == 6) && prime.at(i)) {
      for (int j = 2; j * i < 300000; j++) {
        prime.at(j * i) = false;
      }
    }
    else prime.at(i) = false;
  }
  
  vector<int> keep;
  for (int i = 2; i < 300000; i++) {
    if (prime.at(i)) keep.emplace_back(i);
  }
  
  while (true) {
    int n;
    cin >> n;
    if (n == 1) break;
    
    vector<int> ans;
    for (int i = 0; i < keep.size(); i++) {
      if (n % keep.at(i) == 0) ans.emplace_back(keep.at(i));
    }
    
    cout << n << ":";
    for (int i = 0; i < ans.size(); i++) cout << " " << ans.at(i);
    cout << '\n';
  }
}


Measured memory_bytes: 3288
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0

for i in range(N):
    if a[i] <= x:
        x -= a[i]
        cnt += 1
    else:
        break

if cnt == N and x!=0:
    cnt -=1

print(cnt)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  
  int A;
  int B;
  int C;
  cin >>A>>B>>C;
  int D=B/A;
  if( D>=C) {
cout << C<< endl;
  }
else if(D<C) {
cout << D << endl;
}
}
  

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

int main() {
  int a, b, ans = 0;

  cin >> a >> b;

  for (int i = a; i <= b; i++) {
    if (i % 10 == i / 10000 % 10 && i / 10 % 10 == i / 1000 % 10) {
      ans++;
    }
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 256
import java.io.*;class Main{public static void main(String[]g)throws Exception{BufferedReader B=new BufferedReader(new InputStreamReader(System.in));double x=0,y=0,a=0;for(Integer n=1,m=1;n>0||m!=0;){g=B.readLine().split(",");n=m.valueOf(g[0]);x+=n*Math.cos(Math.toRadians(a));y+=n*Math.sin(Math.toRadians(a));a+=m=n.valueOf(g[1]);}System.out.println((int)y+"\n"+(int)x);}}


Measured memory_bytes: 24336
def main():
    N = int(input())
    H = [int(a) for a in input().split()]
    
    cnt = 0
    for i in range(max(H)):
        S = [False for i in range(len(H))]
        for j in range(len(H)):
            if H[j] != 0 and S[j] == False:
                for k in range(j, len(H)):
                    if H[k] != 0 and S[k] == False:
                        H[k] -= 1
                        S[k] = True
                    else:
                        break
                cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int d = sc.nextInt();
        int d1 = d%10;
        int d10 = d/10;
        int ans = 0;
        for (int i = 4; i <= m; i++) {
            OUTER:for (int j = 2; j <= d10; j++) {
                for (int k = 2; k <= 9; k++) {
                    if(j == d10 && d1 < k) break OUTER;
                    if(i == j * k) ans++;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

using Mint = modint998244353;

struct S{
    Mint a;
    int size;
};

struct F {
    Mint a, b;
};

S op(S s1, S s2){
    return S{s1.a + s2.a, s1.size + s2.size};
}

S e(){
    return S{0, 0};
}

S mapping(F f, S s){
    return S{s.a * f.a + f.b * s.size, s.size};
}

F composition(F f1, F f2){
    return F{f1.a * f2.a, f1.a * f2.b + f1.b};
}

F id(){
    return F{1, 0};
}

int main(void) {
    ll n, q;
    cin >> n >> q;
    vector<S> a(n);
    rep(i, n){
        ll tmp;
        cin >> tmp;
        a[i] = S{tmp, 1};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> lst(a);
    while(q--){
        ll t;
        cin >> t;
        if(t == 0){
            ll l, r, b, c;
            cin >> l >> r >> b >> c;
            lst.apply(l, r, F{b, c});
        }else{
            ll l, r;
            cin >> l >> r;
            co(lst.prod(l, r).a.val());
        }
    }

    return 0;
}

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

int main(){
  string s, t;
  cin>>s;
  cin>>t;
  int cnt=0;
  for(int i=0;i<3;i++){
    if(s[i]==t[i]){
      cnt++;
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 256
program read
  implicit none
  character(len=10) S, T, U
  integer A, B
  read *, S, T, A, B, U
  if ( U == S ) then
  	A = A - 1
  else if ( U == T ) then
  	B = B - 1
  end if
  
  print *, A, B
end program read

Measured memory_bytes: 256
/*
A0409.c Floor
@kankichi57301

 */
#include <stdio.h>
#define LIM 34
int rect[100][4];   //0:x,1:y,2:size,3:color

void prepare()
{
  int i,siz;
  rect[0][0]=0;
  rect[0][1]=0;
  rect[0][2]=1;
  rect[0][3]=1;
  
  rect[1][0]=1;
  rect[1][1]=0;
  rect[1][2]=1;
  rect[1][3]=2;
  
  for(i=2,siz=1;i<LIM;i++)
  {
      if(i<=1)
	siz=1;
      else
        siz=rect[i-2][2]+rect[i-1][2];

    switch (i%4)
      {
      case 1:// east
	{
	  rect[i][0]=rect[i-1][0]+rect[i-1][2];
	  rect[i][1]=rect[i-1][1];
	  break;
	}
      case 2: //north
	{
	  rect[i][0]=rect[i-2][0];
	  rect[i][1]=rect[i-2][1]+rect[i-2][2];
	  break;
	}
      case 3: //west
	{
	  rect[i][0]=rect[i-3][0]-siz;
	  rect[i][1]=rect[i-2][1];
	  break;
	}
      case 0: //south
	{
	  rect[i][0]=rect[i-1][0];
	  rect[i][1]=rect[i-1][1]-siz;
	  break;
	}
      }
    rect[i][2]=siz;
    rect[i][3]=1+(i%3);
  }
}
int solve(int x,int y)
{
  int i;
  for(i=0;i<LIM;i++)
    if(x >= rect[i][0] && x< rect[i][0]+rect[i][2] && y >= rect[i][1] && y< rect[i][1]+rect[i][2])
      return(rect[i][3]);
  return(-1);  // never reach
}
void dump()
{
  int i;
  for(i=0;i<LIM;i++)
    printf("%d:%d:%d:%d \n",rect[i][0],rect[i][1],rect[i][2],rect[i][3]);
}
int main()
{
  int ret,x,y;
  prepare();
  //dump();
  scanf("%d %d",&x,&y);
  ret=solve(x,y);
  printf("%d\n",ret);
  return 0;
}



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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int i(0);i<N;i++){
    cin>>A[i];
  }
  vector<int> dp(N,1);

  for(int i(0);i<N;i++){
    for(int j(i+1);j<min(i+1000,N);j++){
      if(abs(A[i]-A[j]) <= K) {
        dp[j] = max(dp[j], dp[i]+1);
      }
    }
  }
  int ans(0);
  for(int i(0);i<N;i++){
    ans = max(dp[i], ans);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 5644
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int n,f[maxn],ans[maxn];
char s[maxn];
int popcount(int x){
    int ans = 0;
    for(int i = 0;i <= 20; ++i){
        if(x&(1<<i)) ans += 1;
    }
    return ans;
}
int solve(int x){
    if(f[x] != -1) return f[x];
    return f[x] = solve(x%popcount(x))+1;
}
LL qpow(LL a,LL x,LL mod){
    LL res = 1;
    while(x){
        if(x&1) res = res * a % mod;
        a = a*a%mod;
        x >>= 1;
    }
    return res;
}
int sum[maxn][2];
int main(){
    memset(f,-1,sizeof(f)); f[0] = 0;
    for(int i = 1;i < maxn; ++i){
        if(f[i] == -1) f[i] = solve(i);
    }
    scanf("%d %s",&n,s+1); int mod = 0;
    for(int i = 1;i <= n; ++i){
        if(s[i] == '1') mod += 1;
    }
    for(int i = n;i > 0; --i){
        sum[i][0] = sum[i+1][0];
        sum[i][1] = sum[i+1][1];
        if(s[i] == '1'){
            if(mod > 1) sum[i][0] = (sum[i][0]+qpow(2,n-i,mod-1))%(mod-1);
            sum[i][1] = (sum[i][1]+qpow(2,n-i,mod+1))%(mod+1);
        }
    }
    int per0 = 0,per1 = 0;
    for(int i = 1;i <= n; ++i){
        if(s[i] == '1'){
            if(mod == 1) continue;
            int x = (per0+sum[i+1][0])%(mod-1);
            ans[i] = f[x]+1;
            if(mod > 1) per0 = (per0+qpow(2,n-i,mod-1))%(mod-1);
            per1 = (per1+qpow(2,n-i,mod+1))%(mod+1);
        }
        else{
            int x = (per1+sum[i+1][1]+qpow(2,n-i,mod+1))%(mod+1);
            ans[i] = f[x]+1;
        }
    }
    for(int i = 1;i <= n; ++i) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 7128
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (S[i] == '1') {
      ans++;
    }
  }
  
  cout << ans << endl;
}

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

int main(){
	
	
	int i,k=0,count;
	char S[100010],invS[100010],s1[]="maerd",s2[]="remaerd",s3[]="esare",s4[]="resare";
	scanf("%s",S);
	
	for(i=0;i<strlen(S);i++){
		invS[i]=S[strlen(S)-i-1];
	}
	
	
	while(k<=strlen(S)-1){
		count=0;
		for(i=0;i<strlen(s1);i++){
			if(invS[i+k]!=s1[i]){
				break;
			}
			if(i==strlen(s1)-1){
			k+=strlen(s1);
			count++;
			}
		}
		for(i=0;i<strlen(s2);i++){
			if(invS[i+k]!=s2[i]){
				break;
			}
			if(i==strlen(s2)-1){
			k+=strlen(s2);
			count++;
			}
		}
		for(i=0;i<strlen(s3);i++){
			if(invS[i+k]!=s3[i]){
				break;
			}
			if(i==strlen(s3)-1){
			k+=strlen(s3);
			count++;
			}
		}
		for(i=0;i<strlen(s4);i++){
			if(invS[i+k]!=s4[i]){
				break;
			}
			if(i==strlen(s4)-1){
			k+=strlen(s4);
			count++;
			}
		}
		if(count==0){
			printf("\n\nNO\n\n");
			return 0;
		}
		
		}
	
	printf("\n\nYES\n\n");
	
	return 0;
}

Measured memory_bytes: 384
//
// Created by moono on 2018/10/27.
//

#include <stdlib.h>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;


int main() {
    string buf;
    cin >> buf;
//    string buf = "999999999";
    int n = stoi(buf);

    //
    int m = n, s_n = 0;
    while(m > 0){
        s_n += m % 10;
        m = m / 10;
    }

    //
    if( s_n != 0 && n % s_n == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
int main()
{
    string s1,s2;
    llin(s1);
    llin(s2);
    int i,x=0;
    rep(i,3)
        if(s1[i]==s2[i])x++;
    out(x);
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M, K := sc.nextInt(), sc.nextInt(), sc.nextInt()
	fr := NewUnionFind(N)
	frCount := make([]int, N)
	ans := make([]int, N)
	for i := 0; i < M; i++ {
		a, b := sc.nextInt()-1, sc.nextInt()-1
		fr.unite(a, b)
		frCount[a]++
		frCount[b]++
	}
	for i := 0; i < N; i++ {
		ans[i] = fr.getSize(i) - frCount[i]
	}
	for i := 0; i < K; i++ {
		c, d := sc.nextInt()-1, sc.nextInt()-1
		if fr.isSame(c, d) {
			ans[c]--
			ans[d]--
		}
	}
	for i := 0; i < N; i++ {
		if i != 0 {
			fmt.Fprint(wtr, " ")
		}
		fmt.Fprint(wtr, ans[i]-1)
	}
	fmt.Fprintln(wtr)
}

type UnionFind struct {
	parent []int
	size   []int
}

func NewUnionFind(n int) *UnionFind {
	p := make([]int, n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = i
		s[i] = 1
	}
	return &UnionFind{p, s}
}

func (a *UnionFind) root(x int) int {
	if a.parent[x] == x {
		return x
	} else {
		a.parent[x] = a.root(a.parent[x])
		return a.parent[x]
	}
}

func (a *UnionFind) isSame(x, y int) bool {
	return a.root(x) == a.root(y)
}

func (a *UnionFind) unite(x, y int) {
	x = a.root(x)
	y = a.root(y)
	if x == y {
		return
	} else {
		a.parent[x] = y
		a.size[y] += a.size[x]
	}
}

func (a *UnionFind) getSize(x int) int {
	return a.size[a.root(x)]
}


Measured memory_bytes: 15360
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b)
{
int*x = (int*)a;
int*y = (int*)b;
if(*x > *y)
return -1;
else if(*x < *y)
return 1;
else
return 0;
}

int main()
{
int i, ara[10];
for(i = 0; i < 10; i++)
scanf("%d", &ara[i]);

qsort(ara, 10, sizeof(int), &cmp);
for(i = 0; i < 3; i++)
printf("%d\n", ara[i]);
return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(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 repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

ll n,m;

int main(){
	FAST;
	cin >> n >> m;
	if (n>m) swap(n,m);

	if (n==1) {
		if (m==1) {
			cout << 1 << LF;
			return 0;
		}
		else {
			cout << m-2 << LF;
			return 0;
		}
	}
	cout << (n-2)*(m-2) << LF;

	return 0;
}

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

int main() {
   
   int N, M, X;
   std::cin >> N >> M >> X;
   int A[M];
   int count_0 = 0;
   int count_N = 0;
   for (int i = 0; i < M; i++) {
      std::cin >> A[i];
      if (A[i] > X) count_N++;
      if (A[i] < X) count_0++;
   }
   std::cout << std::min(count_N, count_0) << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int a[n][m];
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < m;j++) {
            a[i][j] = 0;
        }
    }
    for(int i = 0;i < n;i++) {
        int k;
        cin >> k;
        for(int j = 0;j < k;j++) {
            int num;
            cin>>num;
            a[i][num-1] = 1;
        }
    }

    int count = 0;
    for(int i = 0;i < m;i++) {
        int flag = 0;
        for(int j = 0;j < n;j++) {
            if(a[j][i] != 1) {
                flag = 1;
            }
        }
        if(flag==0) {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll n, m;
  cin >> n >> m;
  map<ll,bool> mp;
  vector<ll> dp(n + 10, 0), a(m+2);
  rep(i, m) {
    cin >> a[i];
    mp[a[i]] += 1;
  }
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    if (mp[i]) {
      continue;
    }
    if (!mp[i+1]) {
      dp[i+1] += (dp[i]) % MOD;
      dp[i+1] %= MOD;
    } 
    if (!mp[i+2]) {
      dp[i+2] += (dp[i]) % MOD;
      dp[i+2] %= MOD;
    }
  }

  cout << dp[n] << endl;
}


Measured memory_bytes: 8064
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int int_cmp(const int *a, const int *b)
{
    if (*a < *b)
        return (1);
    else if (*a > *b)
        return (-1);
    return (0);
}

int main(){
    int a[100010],b[100010];
    int n,num;
    int count = 0;
    int f = 1;
    int maxa = 0;
    int maxb = 0;
    int numa = -1,numb = -2;

    FOR(i,0,100010){
        a[i] = 0;
        b[i] = 0;
    }

    cin >> n;

    FOR(i,0,n/2){
        cin >> num;
        a[num]++;
        cin >> num;
        b[num]++;
    }

    FOR(i,0,100010){
        if(a[i] != b[i]){
            f = 0;
        } else if(a[i] != 0)count++;
        if(maxa < a[i]){
            maxa = a[i];
            numa = i;
        }
        if(maxb < b[i]){
            maxb = b[i];
            numb = i;
        }
    }

    if(f == 1 && count == 1)cout << n/2;
    else{
        qsort(a,100010,sizeof(int),(int(*)(const void*, const void*))int_cmp);
        qsort(b,100010,sizeof(int),(int(*)(const void*, const void*))int_cmp);

        if(numa != numb)cout << n - a[0] - b[0];
        else cout << n - a[0] - max(a[1],b[1]);
    }

    return 0;
}


Measured memory_bytes: 1364
#include <iostream>

using namespace std;

int main() {

    int A, B, C, D, E, F;

    cin >> A >> B >> C >> D >> E >> F;

    double max_dense = -1;
    int water;
    int sugar;

    for (int ai = 0; 100 * ai * A <= F; ++ai) {
        for (int bi = 0; 100 * ai * A + 100 * bi * B <= F; ++bi) {
            for (int ci = 0; 100 * ai + A * 100 * bi * B + ci * C <= F; ++ci) {
                for (int di = 0; 100 * ai * A + 100 * bi * B + ci * C + di * D <= F; ++di) {
                    if (ai == 0 && bi == 0 && ci == 0 && di == 0) {
                        continue;
                    }
                    double dense = 100. * (ci * C + di * D) / (100 * ai * A + 100 * bi * B + ci * C + di * D);

                    if (dense <= (100. * E)/(100 + E) && max_dense < dense) {
                        max_dense = dense;
                        water = 100 * ai * A + 100 * bi * B;
                        sugar = ci * C + di * D;
                    }

                }
            }
        }
    }

    cout << (water + sugar) << " " << sugar << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

int main()
{
  int n;
  scanf("%d", &n);
  if(n % 2 == 0) {
    printf("%d\n", n);
  } else {
    printf("%d\n", n * 2);
  }
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c;
  cin >> a;
  cin >> b;
  cout <<(a-1)*(b-1)<<endl;
  
   return 0;
}


Measured memory_bytes: 256
/* ex 9_1
series2 */
#include <stdio.h>
#include <stdlib.h>
#define SIZE 10
//条件　文字列を格納するスタックを定義、push,pop
typedef struct stack {
    int size;
    int count;        //現在格納されている文字数
    char data[SIZE];  //データ内容そのもの
    char *top;  //外部からのアクセス部はdata配列の一番後ろの番地のアドレスをさす
} stack;

void init_stack(stack *stk) {
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}
void push(stack *stk, char data) {
    if (stk->count <
        stk->size) {  //用意したstackの要領未満の時、入力文字をトップアドレスに追加する
        stk->top--;
        *(stk->top) = data;
        stk->count++;
    }
}
char pop(stack *stk) {
    char latest;
    if (stk->count > 0) {  //文字が残っている時
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    } else {
        latest = '\0';  //文字が残っていない時null文字を返す
    }
    return latest;
}

// stackなので、再帰的に呼び出すことで正しい順にする。(直接呼び出すのは、stackとしての設計に反する)
void printout(stack *stk) {
    char out = pop(stk);
    if (out) {  // outがnull文字でない時
        printout(stk);
        printf("%c", out);
    }
}

int main(void) {
    stack stk;
    init_stack(&stk);
    char inp = ' ';
    while (inp != '\n') {
        scanf("%c", &inp);
        if (inp == 'B') {
            pop(&stk);
        } else if (inp != '\n') {
            push(&stk, inp);
        }
    }
    printout(&stk);
    printf("\n");

    return 0;
}


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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	string s,t;
	cin>>s>>t;
	int f=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			f=1;
			break;
		}
	}	
	if(f){
		cout<<"No\n";
	}
	else{
		cout<<"Yes\n";
	}
	return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;

namespace ABC_042
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int L = int.Parse(str[1]);
            string[] S = new string[N];

            for(int i=0; i< N; i++)
            {
                S[i] = Console.ReadLine();
            }

            Array.Sort(S);

            string ans = "";
            for(int i=0; i<N; i++)
            {
                ans += S[i];
            }

            Console.WriteLine(ans);
        }

    }
}


Measured memory_bytes: 4312
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <tuple>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 110;

int n;
int maxson[N], dep[N];
bool vis[N];
vector<int> g[N];

void dfs(int u) {
  vis[u] = true;
  int sons = 0;
  for (int v : g[u])
    if (!vis[v]) {
      ++sons;
      dep[v] = dep[u] + 1;
      dfs(v);
    }
  maxson[dep[u]] = max(maxson[dep[u]], sons);
}

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

  cin >> n;
  vector<pair<int, int>> edges;
  for (int rep = 1; rep < n; ++rep) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    edges.emplace_back(u, v);
  }
  pair<int, ll> ans(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    memset(maxson, 0, sizeof(maxson));
    memset(vis, 0, sizeof(vis));
    memset(dep, 0, sizeof(dep));
    dep[i] = 0;
    dfs(i);
    int a1 = *max_element(dep + 1, dep + n + 1);
    ll a2 = 1;
    for (int i = 0; i < a1; ++i) a2 *= maxson[i];
    ans = min(ans, make_pair(a1 + 1, a2));
  }
  for (const auto& pr : edges) {
    int u = pr.first, v = pr.second;
    memset(maxson, 0, sizeof(maxson));
    memset(vis, 0, sizeof(vis));
    memset(dep, 0, sizeof(dep));
    vis[u] = vis[v] = true; dep[u] = dep[v] = 0;
    dfs(u); dfs(v);
    int a1 = *max_element(dep + 1, dep + n + 1);
    ll a2 = 2;
    for (int i = 0; i < a1; ++i) a2 *= maxson[i];
    ans = min(ans, make_pair(a1 + 1, a2));
  }
  cout << ans.first << ' ' << ans.second << '\n';

  return 0;
}


Measured memory_bytes: 256
//let input = "6 20 7";

function main(input){
  input = input.trim();
  let list = input.split(" ");
  let min = parseInt(list[0])-1;
  let max = parseInt(list[1]);
  let a = parseInt(list[2]);
  let dai = Math.floor(max/a);
  let syou = Math.floor(min/a);
  let answer = dai - syou;
  console.log(answer);
}
//main(input);
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

signed main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int anso=A*B;
  int anst=C*D;
  cout<<max(anso,anst)<<endl;
  return 0;
}

Measured memory_bytes: 3616
N, M = map(int, input().split())

memo = {key:0 for key in range(1, N+1)}
AC = 0
WA = 0

# print(memo)

for _ in range(M):
    pi, Si = input().split()
    pi = int(pi)
    if memo[pi] != "AC":
        if Si == "WA":
            memo[pi] += 1
        elif Si == "AC":
            AC += 1
            WA += memo[pi]
            memo[pi] = "AC"

print(AC, WA)


Measured memory_bytes: 15084
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};

template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}

extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

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

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}

int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<PII>> g(n);
	VI pos(n,INF);
	VB root(n,1);
	REP(i,m)
	{
		int l,r,d;
		cin>>l>>r>>d;
		l--;r--;
		if(d==0)
		{
			if(l>r)
				swap(l,r);
		}
		g[l].push_back(PII(r,d));
		root[r]=0;
	}
	VB reach(n);
	bool flag=1;
	function<void(int)> dfs=[&](int v)
	{
		for(auto&& e:g[v])
		{
			int r,d;
			tie(r,d)=e;
			if(pos[r]==INF)
				pos[r]=pos[v]+d;
			else
			{
				if(pos[r]!=pos[v]+d)
				{
					flag=0;
				}
			}
		}
		if(reach[v]) return;
		reach[v]=1;
		for(auto&& e:g[v])
			dfs(e.first);
	};
	REP(i,n)
		if(root[i])
		{
			pos[i]=0;
			dfs(i);
			reach[i]=1;
		}
	REP(i,n)
		if(!reach[i])
			flag=0;
	if(flag)
	print("Yes");
	else
	print("No");
}


Measured memory_bytes: 11008
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define LOVE ios::sync_with_stdio(0)
#define Foru(i,a,b) for(int i=(a);i<=(b);++i)
#define File ifstream fin("G:\\QtCode\\data\\in.txt")
using namespace std;
//void slove(int question_num)
//{
//    while(question_num--)
//    {
//        int sum[200002]={0};
//        int n;
//        cin>>n;
//        set<int>ans;
//        int num[200002]={0};
//        for(int i=1;i<=n;i++)
//        {
//            cin>>num[i];
//            sum[i]+=sum[i-1]+num[i];
//        }
//        for(int i=2;i<n;i++)
//        {
//            set<int>temp;
//            for(int j=i;j<=n;j++)
//            {
//                temp.insert(sum[j]-sum[j-i]);
//            }
//            if(temp.count((1+i)*i/2))
//                ans.insert(i);
//        }
//        cout<<1;
//        for(int i=2;i<n;i++)
//        {
//            if(ans.count(i))
//                cout<<1;
//            else cout<<0;
//        }
//        cout<<1<<endl;

//    }
//    return;
//}
//void slove(int question_num)
//{
//    while(question_num--)
//    {
//        unsigned int n;cin>>n;
//        map<int,int,greater<int> >temp;
//        for(unsigned int i=1;i<=n;i++)
//        {
//            int kkk;cin>>kkk;
//            temp[kkk]++;
//        }
//        if(temp.size()==1)
//            cout<<0<<' '<<0<<' '<<0<<endl;
//        else
//        {
//            int medalnum=n/2;
//            int tot=0;
//            int ans[5]={0};
//            auto pos=temp.begin();
//            ans[1]=temp.begin()->second;
//            int flage=1;
//            for(;pos!=temp.end();pos++)
//            {
//                tot+=pos->second;
//                if(tot>medalnum)
//                {
//                    tot-=pos->second;
//                    break;
//                }
//            }
//            for(auto it=++temp.begin();it!=pos;it++)
//            {
//                if(ans[2]<=ans[1])
//                    ans[2]+=it->second;
//                else flage=0;
//                if(!flage)
//                {
//                    ans[3]+=it->second;
//                }
//            }
//            if(ans[3]<=ans[1])
//                cout<<0<<' '<<0<<' '<<0<<endl;
//            else
//                cout<<ans[1]<<' '<<ans[2]<<' '<<ans[3]<<endl;
//        }
//    }
//    return;
//}
void slove(int question_num)
{
    while (question_num--) {
        string s;
        cin>>s;
        unsigned long long r=s.size()-1;
        int ans=0;
        unsigned long long l=0;
        while(l<r)
        {
            if(s[r]!=s[l])
                ans++;
            r--;l++;
        }
        cout<<ans<<endl;
    }
}
int main()
{
    LOVE;
    //int n;cin>>n;
    slove(1);
    return 0;
}


Measured memory_bytes: 256