akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
template <typename T>
T gcd(T m, T n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
         r %= 1000000007;
         rr %= 1000000007;
    }
    r /= rr;
     r %= 1000000007;
    return r;
}
#define rep(a,b,c) for(ll a = b; a < c; ++i)
ll mod = 1000000007;
//---------------------------------------------------------------------------------------------------
ll f[101010];
void init() {
    f[0] = 1;
    rep(i, 1, 101010) f[i] = (f[i - 1] * i) % mod;
}
//---------------------------------------------------------------------------------------------------
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = f[n-k]; // = (n-k)!
    ll c = f[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * inv(bc)) % mod;
}
ll pow2_(ll n){
  
  ll div = 1000000007ll;
  ll ans = 0,k=2;
  {
    bitset<48> b(n);
    FOR(i,32){
      ans+=b[i]*k%div;
      ans%=div;
      k*=k;
      k%=div;
    }
  }
  return ans;
}
int main(){
  ll N,X,Y;
  cin>>N>>X>>Y;
  X--;
  Y--;
  vector<ll> ans(N);
  FOR(i,N){
    ll now=i;
    vector<ll> kyori(N,1e+9);
    vector<pair<ll,ll>> next_;
    next_.push_back({i,0});
    while(next_.size()!=0){
      pair<ll,ll> t = next_.back();
      next_.pop_back();
      if(kyori[t.first]>t.second)kyori[t.first]=t.second;
      else continue;
      if(t.first!=0){
        next_.push_back({t.first-1,t.second+1}); 
      }
      if(t.first!=N-1){
        next_.push_back({t.first+1,t.second+1}); 
      }
      if(t.first==X){
        next_.push_back({Y,t.second+1}); 
      }
      if(t.first==Y){
        next_.push_back({X,t.second+1}); 
      }
    }
    FOR(j,N){
      ans[kyori[j]]++;
    }
  }
  FOR(i,N-1){
    cout<<ans[i+1]/2<<endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;


ll n,m;


int main(){
  cin>>n>>m;
  if(n==1&&m==1)cout<<1<<endl;
  else if(n==1)cout<<(m-2)<<endl;
  else if(m==1)cout<<(n-2)<<endl;
  else cout<<(m-2)*(n-2)<<endl;

  return 0;
}


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

int main() {
  int X, a;
  int sum = 0;
  cin >> X;
  
  for (int i = 0; i<9; i++) {
    a = pow(10,i);
    sum += (X % (a*10)) / a;
  }
  
  
  if (X % sum == 0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
  
}

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

using namespace std;

int main() {
	string S;
	cin >> S;

	if (S == "SUN") {
		cout << 7 << endl;
	} else if (S == "MON") {
		cout << 6 << endl;
	} else if (S == "TUE") {
		cout << 5 << endl;
	} else if (S == "WED") {
		cout << 4 << endl;
	} else if (S == "THU") {
		cout << 3 << endl;
	} else if (S == "FRI") {
		cout << 2 << endl;
	} else {
		cout << 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
ans=0

d=defaultdict(int)
sum_a=0
d[sum_a]+=1
for i in range(n):
    sum_a+=a[i]
    ans+=d[sum_a]
    d[sum_a]+=1
print(ans)

Measured memory_bytes: 39264
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200009
int f[N];

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

       int n;
       cin >> n;
       int i,a[n+1];
       
       for(i=1; i<=n; i++){
           cin >> a[i];
           f[a[i]]++;

       }
       int ans=0;
        for(i=1; i<=2e5; i++){
            if(f[i]>1){
                int x=f[i];
                ans=ans+(x*(x-1))/2;
            }
        }

       for(i=1; i<=n; i++){
           int x=f[a[i]];
           if(x<=1){
               cout << ans << '\n';
           }
           else{
               int y=x;
               y--;
               int r=(y*(y-1))/2;
               int m=(x*(x-1))/2;
               int temp=ans-m+r;
               cout << temp << '\n';
           }
       }
        

}

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

int main() {
    int h, w;
    cin >> h;
    cin >> w;
    vector<string> c(h);
    for (int i = 0; i < h; i++) {
        cin >> c.at(i);
    }
    for (int i = 0; i < h; i++) {
        cout << c.at(i) << endl;
        cout << c.at(i) << endl;
    }
}


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

ans = []
if n%2 == 0:
    p = [[i, n+1-i] for i in range(1, n//2+1)]
    
    for i in range(len(p)):
        for x in p[i]:
            for j in range(i+1,len(p)):
                for y in p[j]:
                    ans.append([x, y])
else:
    p = [[i, n-i] for i in range(1, (n-1)//2+1)]
    p.append([n])
    
    for i in range(len(p)):
        for x in p[i]:
            for j in range(i+1,len(p)):
                for y in p[j]:
                    ans.append([x, y])
                    
print(len(ans))
for edge in ans:
    print(edge[0], edge[1])

Measured memory_bytes: 4128
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf 1000000000000000000

using namespace std;

void run();

signed main(){
    cout<<fixed;
    run();
    return 0;
}

void run(){
    int n,k;
    cin>>n>>k;
    int a=n/k;
    int b=0;
    if(k%2==0){
        REP(i,1,n){
            if(i%k==k/2)b++;
        }
    }
    cout<<a*a*a+b*b*b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void min_self(ll& a, ll b){
  a = min(a,b);
}
int main(){
  ll n,w; cin>>n>>w;
  vector<ll> val(n), weight(n);
  for(int i = 0 ; i < n; i++)
      cin>>weight[i]>>val[i];
    int sumtot = 0;
    for(int i = 0; i < n; i++)
        sumtot += val[i];
    
  vector<ll> dp(sumtot+1,1e18);
    dp[0] = 0;
    for(int i = 0 ; i < n; i++){
      for(int curr_val = sumtot - val[i]; curr_val >=0; curr_val--){
          min_self(dp[curr_val+val[i]], dp[curr_val]+weight[i]);
        }
    }
    int ans = 0;
    for(int i = 0; i < sumtot+1; i++)
      if(dp[i]<=w)
          ans = max(ans, i);
    cout<<ans<<endl;
    return 0;
}
    


Measured memory_bytes: 4020
N, K = map(int, input().split())
p = list(map(int, input().split()))

exp = [(1+p[i])/2 for i in range(N)]
s = sum(exp[:K])
ans = s
for i in range(K, N):
    s -= exp[i-K]
    s += exp[i]
    ans = max(ans, s)
print(ans)

Measured memory_bytes: 24812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string s;
    cin>>s;
    if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main() {
    int A,B;
    cin >> A >> B;
    vector<int> ansA(0),ansB(0);

    rep(i,12500){
        if((int)(i*0.08)==A){
            ansA.push_back(i);
        }
        if((int)(i*0.1)==B){
            ansB.push_back(i);
        }
    }
    rep(i,ansA.size()){
        rep(m,ansB.size()){
            if(ansA[i]==ansB[m]){
                cout << ansA[i] << endl;
                return 0;
            }
        }
    }
    cout << "-1" << endl;

    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
for a in range(0, N + 1):
    for b in range(0, N - a + 1):
        c = N - a - b
        if (10000 * a + 5000 * b + 1000 * c) == Y:
            print(a, b, c)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string S,T;
	int cnt=0;
	cin>>S>>T;
	for(int i=0;i<3;i++){
		if(S[i]==T[i])cnt++;
	}
	printf("%d",cnt);
    return 0;
}


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

int main(){
  vector<string> moji(10);
  moji[1] = ".,!? ";
  moji[2] = "abc";
  moji[3] = "def";
  moji[4] = "ghi";
  moji[5] = "jkl";
  moji[6] = "mno";
  moji[7] = "pqrs";
  moji[8] = "tuv";
  moji[9] = "wxyz";
  int n =0;cin >> n;

  for(int i = 0;i < n;i++){
    string tmp;
    cin >> tmp;
    string mes = "";
    char keep;
    int flag = 0;
    for(int i = 0;i < tmp.size();i++){
      if(tmp[i] != '0'){
	flag++;
	keep = tmp[i]; 
      }else{
	if(flag > 0){
	  mes += moji[keep-'0'][(flag-1)%(moji[keep-'0'].size())];
	}
	flag = 0;
      }
    }
    cout << mes << endl;
    
    
    
  }
  return 0;
}
int string_to_int(string a){
  stringstream ss;
  ss << a;
  int num;
  ss >> num;
  return num;
}

Measured memory_bytes: 1216
solve a b k
    | k == 0 = [a, b]
    | a > 0  = solve (a-c) b (k-c)
    | b > 0  = solve a (b-d) (k-d)
    | otherwise = [a, b]
    where
        c = min a k
        d = min b k

main = do
    [a, b, k] <- map read . words <$> getLine
    putStrLn $ unwords $ map show $ solve a b k

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int n, ans;
  
  cin >> n;
  
  ans = n/2;
  if(n%2 > 0) ans++;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int p[200005];
double sum[200005];
double a(ll x) {
	ll count = 0;
	while (x) {
		count += x;
		x--;
	}
	return count;
}
int main() {
	int n, k;
	cin >> n >> k;
	sum[0] = 0;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	for (int i = 1; i <= n; i++) {
		double kitai = (double)a(p[i - 1]) / p[i - 1];
		sum[i] = sum[i - 1] + kitai;
	}
	double ans = -1e9;
	for (int i = k; i <= n; i++) {
		ans = max(ans, sum[i] - sum[i - k]);
	}
	cout <<fixed<<setprecision(10)<<ans << endl;
	return 0;
}



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

int main(){
    char S[100];
    int i, j;
    long long int K;
    scanf("%s %lld", &S, &K);
    long long int ans = 0;
    int N = strlen(S);

    int f = 0, n = 0, m = 0, F = 0;
    for(i=0; i<N-1; i++){
        if (S[0] != S[i]) F = 1;
        if (S[i] == S[i+1] && f == 0){
            ans++;
            f = 1;
            continue;
        }
        f = 0;
    }

    for(i=0; i<N; i++){
        if (S[i] == S[0]){
            n = i+1;
        }else{
            break;
        }
    }

    for(i=0; i<N; i++){
        if (S[N-1-i] == S[N-1]){
            m = i+1;
        }else{
            break;
        }
    }
    
    f = 0;
    if(n%2 == 1 && m%2 == 1 && S[0] == S[N-1]){
        f = 1;
        ans++;
    }

    if (F == 0){
        printf("%lld\n", K*(long long int)N/(long long int)2);
        return 0;
    }


    printf("%lld\n", ans*(long long int)K - (long long int)f);

    return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	int n;
	cin >> n;
	bool b = false;
	REP(i, n) {
		int a;
		cin >> a;
		if (a % 2)b = true;
	}
	if (b)cout << "first" << endl;
	else cout << "second" << endl;
	return 0;
}

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

int main(){
    int n; cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    rep(i, n) sort(all(s[i]));
    sort(all(s));

    ll res = 0;
    int i = 0;
    while(i < n) {
        ll count = 0;
        while(i<n-1) {
            if(s[i] != s[i+1]) break;
            count++;
            i++;
        }
        res += count * (count + 1) / 2;
        i++;
    }

    cout << res << endl;
}
   

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

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
    else cout << "consonant" << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
ll dp[1000005][2];
int main(){
    string s;cin >> s;
    reverse(s.begin(),s.end());
    s+='0';
    int n=s.size();
    for(int i=0; i<1000005; i++){
        for(int j=0; j<2; j++){
            dp[i][j]=LINF;
        }
    }
    dp[0][0]=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<2; j++){
            int x=s[i]-'0';
            x+=j;
            if(x<10) dp[i+1][0]=min(dp[i+1][0],dp[i][j]+x);
            if(x>0) dp[i+1][1]=min(dp[i+1][1],dp[i][j]+10-x);
        }
    }
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 17028
N, M = gets.split.map(&:to_i)
S = gets.chomp

edges = Array.new(2*N){[]}
M.times do
    a, b = gets.split.map(&:to_i)
    a -= 1
    b -= 1
    if S[a] == S[b]
        edges[a].push(b+N)
        edges[b].push(a+N)
    else
        edges[a+N].push(b)
        edges[b+N].push(a)
    end
end

visited = Array.new(2*N)
N.times do |i|
    next if visited[i]
    stack = [i]
    while stack.length > 0
        v = stack[-1]
        if visited[v] == -1
            visited[v] = 1
            stack.pop
            next
        end

        visited[v] = -1
        edges[v].each do |j|
            if visited[j] == -1
                puts 'Yes'
                exit
            elsif !visited[j]
                stack.push(j)
            end
        end
    end
end

puts 'No'

Measured memory_bytes: 49020
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s,t;
    cin>>s>>t;
    int arr[s.length()+1][t.length()+1];
    for(int i=0;i<=s.length();i++) arr[i][0]=0;
    for(int j=0;j<=t.length();j++) arr[0][j]=0;
    for(int i=1;i<=s.length();i++) {
        for(int j=1;j<=t.length();j++) {
            if(s[i-1]==t[j-1])
                arr[i][j]=arr[i-1][j-1]+1;
            else
                arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
        }
    }
    int i=s.length();
    int j=t.length();
    int index=arr[s.length()][t.length()];
    char lcs[index+1];
    lcs[index--]='\0';
    while(i>0 && j>0) {
        if(s[i-1]==t[j-1]) {
            lcs[index--]=s[i-1];
            i--;
            j--;
        }
        else if(arr[i-1][j]>arr[i][j-1]){
            i--;
        }
        else {
            j--;
        }
    }
        cout<<lcs;
    return 0;
}


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

using namespace std;

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void milktea() {
  string s;
  cin >> s;
  int a, b, c, d;
  a = s[0] - '0';
  b = s[1] - '0';
  c = s[2] - '0';
  d = s[3] - '0';
  int n = 3;
  string op;
  int ans = a + b + c + d;
  for(int bit = 0; bit < (1<<n); ++bit) {
    op = "+++=";
    ans = a + b + c + d;
    for(int i = 0; i < n; ++i) {
      if(bit & (1<<i)) {
        ans -= 2*(s[i+1] - '0');
        op[i] = '-';
      }
    }
    if(ans == 7) break;
  }
  for(int i = 0; i < n+1; ++i) {
    cout << s[i] << op[i];
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt=1;
  //cin >> tt;
  while(tt--) milktea();

  return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;

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

    vector<vector<int>> g(n, vector<int>());
    int a, b;
    REP(i, n - 1) {
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> v;
    function<int(int, int, int)> dfs = [&](int t, int p, int d) {
        for (int c : g[t]) {
            if (c == p) continue;
            if (c == n - 1) {
                v.push_back(c);
                return d;
            }
            int r = dfs(c, t, d + 1);
            if (r > 0) {
                v.push_back(c);
                return r;
            }
        }
        return -1;
    };

    int depth = dfs(0, -1, 0);
    int s = depth > 0 ? v[depth / 2] : n - 1;
    int sp = depth > 0 ? v[depth / 2 + 1] : 0;

    function<int(int, int)> dfs2 = [&](int t, int p) {
        if (g[t].size() == 1) return 1;
        int total = 1;
        for (int c : g[t]) {
            if (c == p) continue;
            total += dfs2(c, t);
        }
        return total;
    };
    int white = dfs2(s, sp);
    if (white >= (n + 1) / 2) {
        cout << "Snuke" << endl;
    } else {
        cout << "Fennec" << endl;
    }
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
  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
}

int32_t main()
{
  //c_p_c();
  int n,p;
  cin >> n;
  p = n;
  int s = 0;
  while(n > 0)
  {
    s+=(n%10);
    n/=10;
  }
  //cout<<n<<" "<<s<<endl;
  if((p%s) == 0)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <assert.h>
#include <iomanip>

#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)

using namespace std;

const double EPS = 0.000000001;
long long a[100];
long long sum[100];
long long c[100][100];

void init() {
  FOR(i, 0, 50) c[i][0] = 1;
  FOR(i, 1, 50) FOR(j, 1, i) c[i][j] = c[i-1][j] + c[i-1][j-1];
}

int main() {
  int n, A, B;
  ios::sync_with_stdio(false);
  init();
  assert(c[5][2] == 10);
  while (cin >> n >> A >> B) {
    FOR(i, 0, n-1) cin >> a[i];
    sort(a, a + n);
    long long res_a = 0;
    long long res_b = 1;
    memset(sum, 0, sizeof(sum));
    FOR(l, A, B) {
      FOR(i, n-l, n-1) sum[l] += a[i];
      if (sum[l] * res_b > res_a * l) {
        res_a = sum[l];
        res_b = l;
      }
    }

    long long nway = 0;
    FOR(l, A, B) {
      if (sum[l] * res_b == res_a * l) {
        int remain = 0;
        int inside = 0;
        FOR(i, 0, n-l-1) if (a[i] == a[n-l]) remain++;
        FOR(i, n-l, n-1) if (a[i] == a[n-l]) inside++; else break;
        nway += c[remain+inside][inside];
      }
    }
    cout << fixed << setprecision(10) << double(res_a) / double(res_b) << endl;
    cout << nway << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define fl(i,x,y) for( int i=x;i<y;i++)
#define w(t) while(t--)
#define vi vector<ll>
#define vvi vector< vi >
#define si set<ll>
#define msi multiset<ll>
#define si_d set<ll, greater<ll> >
#define mii map<ll,ll>
#define pb push_back
#define msi_it  multiset<ll> :: iterator
#define si_it set<ll> :: iterator
#define sort1(v) sort(v.begin(),v.end());
#define F first
#define S second
using namespace std;
#define N 1000000007
#define mod 15000000000031
int main()
{
	string s;cin>>s;
	int a=0,b=0;
	fl(i,0,3)
	{
		if(s[i]=='A') a++;
		else b++;
	}
	if(a==0 || b==0) cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 256
import scala.io.Source

object Main{
  def main(args: Array[String]){
    var list = List[String]()
    for(in <- Source.stdin.getLines.toList){
      list = in :: list
    }

    for(i <- 0 until list.length){
      val arr = list(list.length - i - 1).split(Array(' ')).map(_.toInt)

      if(!(arr(0) == 0 && arr(1) == 0)){
        if(arr(0) > arr(1)){
          println(arr(1) + " " + arr(0))
        }
        else{
          println(arr(0) + " " + arr(1))
        }
      }
    }
  }
}

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

S=[]
bsum=0

for i in range(N):
    a,b = map(int,input().split())
    S.append(a+b)
    bsum+=b

S.sort(reverse=True)

ans=-bsum

for i in range(N):
    if i%2==0:
        ans+=S[i]
print(ans)



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

const int HAMMING_MAX = 1000001;

int main()
{
	bool hamming[ HAMMING_MAX ];
	memset( hamming, 0, sizeof(hamming) );

	for( int x = 1; x < HAMMING_MAX; x *= 2 ){
		for( int y = 1; x * y < HAMMING_MAX; y *= 3 ){
			for( int z = 1; x * y * z < HAMMING_MAX; z *= 5 ){
				int h = x * y * z;
				hamming[ h ] = true;
			}
		}
	}

	int n, m;
	while( cin >> n && n ){
		cin >> m;
		int count = 0;
		for( int i = n; i <= m; ++i ){
			if( hamming[ i ] ){
				++count;
			}
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 2144
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

const long long MOD_CONST = 1000000007;


int main() {

	int n;
	cin >> n;
	vector<int> c(n - 1);
	vector<int> s(n - 1);
	vector<int> f(n - 1);
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	for (int i = 0; i < n - 1; i++) {
		int time = 0;
		for (int j = i; j < n - 1; j++) {
			if (time < s[j]) {
				time = s[j];
			}
			if (time%f[j] != 0) {
				time += (f[j] - time % f[j]);
			}
			time += c[j];
		}

		cout << time << endl;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(c-a-b<0)
	{cout<<"No"<<endl;
	return 0;
	}
	if((c-a-b)*(c-a-b)>4*a*b){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;


int main(void)
{
	int A, B, C, D; cin >> A >> B >> C >> D;
	int start = max(A, C);
	int end = min(B, D);
	int ans = max(end - start, 0);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



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

    for(auto &c : s){
      c -= 'A';
      c += n;
      c %= 26;
      c += 'A';
    }

    cout << s << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);
	freopen("error.txt","w", stderr);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n; string s;
	cin>>n>>s;

	vector<int> r, g;
	unordered_map<int, bool> b;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'R')
			r.push_back(i);
		else if(s[i] == 'G')
			g.push_back(i);
		else 
			b[i] = true;
	}

	ll ans = r.size() * g.size() * b.size();
	for(auto i:r) {
		for(auto j:g) {
			if((i+j)%2 == 0 && b[(i+j)/2])
				ans--;
			if(b[2*j - i])
				ans--;
			if(b[2*i-j])
				ans--;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4176
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>

using namespace std;

#define N 201
#define X 100001
#define mod 1000000007

int s[N];
int dp[2][X];

int add(int x,int y) {
  int ret= x+y;
  if(ret>=mod) {
    ret -= mod;
  }
  return ret;
}
int mul(int x,int y) {
  return (long long)x*y%mod;
}
void solve() {
  int n;
  int myX;
  scanf("%d %d",&n,&myX);
  for(int i=0;i<n;++i) {
    scanf("%d",&s[i]);
  }
  sort(s,s+n);
  int curPos = 0,nextPos=1;
  for(int i=0;i<s[0];++i) {
    dp[curPos][i] = i;
  }
  for(int i=0;i<n;++i,curPos^=1,nextPos^=1) {
    memset(dp[nextPos],0,sizeof(dp[nextPos]));
    for(int t=0;t<=myX;++t) {
      dp[nextPos][t] = add(dp[curPos][t%s[i]] ,mul(i,dp[curPos][t]));
    }
  }
  printf("%d\n",dp[curPos][myX]);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 1024
import math
N=int(input())

def func(A,B):
  if A > B:
    return len(str(A))
  else:
    return len(str(B))


ans=[]
N2=math.floor(math.sqrt(N))
for A in range(1,N2+1):
  if N%A==0:
    B=int(N/A)
    ans.append(func(A,B))

print(min(ans))

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

public class Program
{
    private int N;
    private int[] A;

    public void Solve()
    {
        string yes = "Possible";
        string no = "Impossible";
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();
        var count = new int[100];
        foreach (int i in A)
        {
            count[i]++;
        }

        // 木の直径
        int r = A.Max();

        // 直径だから2つ以上ないといけない
        if (count[r] < 2)
        {
            Console.WriteLine(no);
            return;
        }

        count[r] -= 2;

        // 直径の2nodeの間の構築
        for (int i = 1; i < r; i++)
        {
            int t = Math.Max(i, r - i);

            if (count[t] < 1)
            {
                Console.WriteLine(no);
                return;
            }

            count[t]--;
        }

        for (int i = 0; i < N; i++)
        {
            if (count[i] == 0) continue;
            if ((r + 1) / 2 <= i - 1 && i - 1 <= r - 1) continue;
            Console.WriteLine(no);
            return;
        }
        
        Console.WriteLine(yes);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13268
//#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N,A[200001];
	int lv[200001];
	ll K;
	scan(N>>K);
	fill(lv,lv+N,INF);
	rep(i,N){
		scan(A[i]);
		A[i]--;
	}
	lv[0]=0;
	int now=0;
	ll nokori=K;
	ll newK=K;
	for(ll i=1;i<=K;i++){
		debug(i,now,A[now],nokori);
		now=A[now];
		if(lv[now]!=INF){
			newK=(K-lv[now])%(i-lv[now])+lv[now];
			break;
		}
		lv[now]=i;
	}
	now=0;
	for(ll i=1;i<=newK;i++){
		now=A[now];
	}
	prin(now+1);
	return 0;
}


Measured memory_bytes: 5196
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                while (true) {
                        int N = sc.nextInt();
                        if (N == 0) {
                                break;
                        }
                        String[] S = new String[N];
                        for (int i = 0; i < N; i++) {
                                S[i] = sc.next();
                        }
                        int ans = 0;
                        int dx[] = {0, 1, 1, 1};
                        int dy[] = {1, 1, 0, -1};

                        for (int i = 0; i < N; i++) {
                                for (int j = 0; j < N; j++) {
                                        for (int k = 0; k < 4; k++) {
                                                int count = 0;
                                                while (0 <= i + count * dx[k] && i + count * dx[k] < N && 0 <= j + count * dy[k] && j + count * dy[k] < N && S[i + count * dx[k]].charAt(j + count * dy[k]) == '1') {
                                                        count++;
                                                }
                                                ans = Math.max(ans, count);
                                        }

                                }
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 37876
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-10 22:42:18
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-12 23:50:35
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
int N;
long double L;
const int maxn=5000;
long double T[maxn];

#define pi 3.14159265358979323846
int main()
{
    
    cin>>N>>L;
    for(int i=1;i<=N;i++)
    cin>>T[i];
    long double rx=0.0,ry=0.0;
    for(int i=1;i<=N;i++)
    for(int j=i+1;j<=N;j++)
    {
        rx+=(N-2*j+2*i)*cos((long double)(pi*(T[j]+T[i]))/(long double )(L));
        ry+=(N-2*j+2*i)*sin((long double)(pi*(T[j]+T[i]))/(long double)(L));
    }
    rx /= 1ll*N*(N-1)*(N-2)/6;
	ry /= 1ll*N*(N-1)*(N-2)/6;
    printf("%.12lf %.12lf\n",(double)rx,(double)ry);
    return 0;
}

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

int main() {
  std::string correct = "CODEFESTIVAL2016";
  
  // input
  std::string input;
  std::cin >> input;
  
  // count wrong characters
  int result = 0;
  for (int i = 0; i < correct.length(); ++i) {
    if (correct[i] != input[i]) ++result;
  }
  
  // output
  std::cout << result << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
	if b == 0: return a
	else: return gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

while True:
	try:
		a, b = map(int, input().split())
		print(int(gcd(a, b)), int(lcm(a, b)))
	except EOFError:
		break

Measured memory_bytes: 7612
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

class RangeAddRangeSum {
    public:
        int N;
        vector<int> dat, sum_dat;
        RangeAddRangeSum(int n) {
            N = 1;
            while(N < n) N <<= 1;
            dat.assign(2*N-1, 0);
            sum_dat.assign(2*N-1, 0);
        }

        void add(int a, int b, int x) { add(a,b,x,0,0,N); }
        int add(int a, int b, int x, int k, int l, int r) {
            if(b <= l or r <= a) return dat[k];
            if(a <= l and r <= b) {
                sum_dat[k] += x;
                return dat[k] += x*(r-l);
            }
            const int m = (l+r)/2;
            return dat[k] = add(a,b,x,2*k+1,l,m)+add(a,b,x,2*k+2,m,r)+sum_dat[k]*(min(r,b)-max(l,a));
        }

        int sum(int a, int b) { return sum(a,b,0,0,N); }
        int sum(int a, int b, int k, int l, int r) {
            if(b <= l or r <= a) return 0;
            if(a <= l and r <= b) return dat[k];
            const int m = (l+r)/2;
            return sum(a,b,2*k+1,l,m)+sum(a,b,2*k+2,m,r)+sum_dat[k]*(min(r,b)-max(l,a));
        }
};

string S;
set<int> id[26];
RangeAddRangeSum st(300000+1);

int tr(int i){
    return st.sum(i,i+1);
}

int main(void){
    cin>>S;
    REP(i,SZ(S))
        id[S[i]-'a'].insert(i);
    int nOdd=0;
    REP(i,26)
        nOdd+=SZ(id[i])%2;
    if(1<nOdd){
        cout<<"-1"<<endl;
        return 0;
    }
    REP(i,SZ(S))
        st.add(i,i+1,i);
    LL ans=0;
    REP(i,SZ(S)/2){
        int l=i,r=SZ(S)-i-1;
        int cand=-1;LL cost=IMAX;
        REP(j,26){
            if(1<SZ(id[j])){
                int c=r-tr(*(id[j].rbegin())) + tr(*(id[j].begin()))-l;
                if(c<cost){
                    cand=j;
                    cost=c;
                }
            }
        }
        ans+=cost;
        st.add(*(id[cand].rbegin()),SZ(S),-1);
        st.add(0,*(id[cand].begin())+1,1);
        int s=*id[cand].begin(),e=*id[cand].rbegin();
        id[cand].erase(s);
        id[cand].erase(e);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 18052
import sys

w = sys.stdin.readline().rstrip().lower()
cnt = 0
while True:
	lines = sys.stdin.readline().rstrip()
	if not lines:
		break
	words = lines.split( " " )
	for i in range( len( words ) ):
		if w == words[i].lower():
			cnt = cnt + 1	

print( cnt )

Measured memory_bytes: 6724
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,a,b;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>a>>b;
    if((b-a)&1)cout<<"Borys"<<endl;
    else cout<<"Alice"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll N; cin >> N;
    ll res = 0;
    // for (ll c=1; c<=N-1; ++c){
    //     for (ll a=1; a*a<=c; ++a){
    //         if(c%a==0) {
    //             res++;
    //             if (c/a!=a) res++;
    //         }
    //     }
    // }
    for (int a=1; a*a<=N-1; ++a){
        // cout << a << " ";
        ll s = (N-1)/a - (a);
        // cout << s << " " << endl;
        res += 2*s;
        res ++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
  int i,x,y,count=0;
  while(1)
  {
    scanf("%d %d",&x,&y);
    if(x==0&&y==0)
    break;
    if(x>y)
      printf("%d %d\n",y,x);
    else
      printf("%d %d\n",x,y);
  }
  return 0;
}



Measured memory_bytes: 1928
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MM	100000000
using namespace std;
int wk[501][10001];
int main(void)
{
	int m,n,p[10000],c[500],e[500];
	int i,j,psum[10001],k,jj;
	int mx;
	scanf("%d %d",&m,&n);
	for(i=0;i<m;i++)	{
		scanf("%d",&p[i]);
	}
	sort(p,p+m);
	k=0;
	psum[k]=0;	k++;
	for(i=m-1;i>=0;i--)	{
		psum[k]=psum[k-1]+p[i];
//		printf("psum=%d\n",psum[k]);
		k++;
	}
	for(i=0;i<n;i++)	{
		scanf("%d %d",&c[i],&e[i]);
	}
	for(i=0;i<=n;i++)	{
		for(j=0;j<=m;j++)	{
			wk[i][j]=MM;
		}
	}
	wk[0][0]=0;
	for(i=0;i<n;i++)	{
		for(j=0;j<=m;j++)	{
			if(wk[i][j]!=MM)	{
				if(wk[i+1][j]>wk[i][j])	wk[i+1][j]=wk[i][j];
				if(j+c[i]>m)	jj=m;
				else jj=j+c[i];
				if(wk[i+1][jj]>wk[i][j]+e[i])	{
					wk[i+1][jj]=wk[i][j]+e[i];
				}
			}
		}
	}
//	for(i=0;i<=m;i++)	printf("wk=%d\n",wk[n][i]);
	
	
	
	mx=0;
	for(i=1;i<=m;i++)	{
		mx=max(mx,psum[i]-wk[n][i]);
	}
	printf("%d\n",mx);
	return 0;
}
	


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

using namespace std;

int N, A, B, p[5009];
long long dp[5009][5009];
const long long INF = 1LL << 60;

void u (long long &x, long long y)
{
    if (y < x)
        x = y;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d", &N, &A, &B);
for (int i=1; i<=N; i++)
    scanf ("%d", &p[i]);
for (int i=1; i<=N; i++)
    for (int j=1; j<=N; j++)
        dp[i][j] = INF;
for (int i=N + 1; i>1; i--)
    for (int j=1; j<=N; j++)
    {
        if (p[i - 1] <= j)
            u (dp[i - 1][p[i - 1]], dp[i][j]),
            u (dp[i - 1][j], dp[i][j] + B);
        u (dp[i - 1][min (j, p[i - 1])], dp[i][j] + A);
    }
long long ans = INF;
for (int i=1; i<=N; i++)
    ans = min (ans, dp[1][i]);
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 195968
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define ll long long
int main(){
    ll int n;
    cin>>n;
    vector<ll int> a(n);
    map<ll int,ll int> data;
    rep(i,n){
        cin>>a.at(i);
        data[a.at(i)]++;
    }
    ll int sum=0;
    for(auto p:data){
        sum+=p.second*(p.second-1)/2;
    }
    rep(i,n){
        cout<<sum-data.at(a.at(i))+1<<endl;
    }
    return 0;
}

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

x = []
y = []
z = []
for i in range(n):
  _x, _y, _z = map(int, input().split())
  x.append(_x)
  y.append(_y)
  z.append(_z)

pm = [1, -1]

ans = 0
for i_x in pm:
  for i_y in pm:
    for i_z in pm:
      values = []
      for i in range(n):
        values.append(x[i] * i_x + y[i] * i_y + z[i] * i_z)
      s = 0
      for value in sorted(values, reverse=True)[:m]:
        s += value
      ans = max(ans, s)
      
print(ans)


Measured memory_bytes: 3188
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;

#if defined(_MSC_VER)
#pragma warning(disable: 4996)  // VSでscanfを使う．
#endif

#define int long long

const int INF = 1e28;

signed main() {
  int k, a, b;
  cin >> k >> a >> b;

  int score = b + (b - a) * ((k - (a - 1)) / 2 - 1) + (k - (a - 1)) % 2;

  score = max(score, 1 + k);

  cout << score << endl;

  return 0;
}

Measured memory_bytes: 256