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

int main() {
	int N, M;
	cin >> N >> M;
	if (N % 2 == 1) {
		for (int i = 0; i < M; i++) {
			cout << i + 1 << " " << N - i << endl;
		}
	}
	else {
		for (int i = 0; i < M && i < N / 4; i++) {
			cout << i + 1 << " " << N - i << endl;
		}
		for (int i = N / 4; i < M; i++) {
			cout << i + 1 << " " << N - i - 1 << endl;
		}
	}
}

Measured memory_bytes: 3648
class Combination():
    def __init__(self, n, mod=10**9+7):
        self.mod = mod
        self.fac = [1]*(n+1)
        for i in range(1,n+1):
            self.fac[i] = self.fac[i-1] * i % self.mod
        self.invfac = [1]*(n+1)
        self.invfac[n] = pow(self.fac[n], self.mod - 2, self.mod)
        for i in range(n-1, 0, -1):
            self.invfac[i] = self.invfac[i+1] * (i+1) % self.mod

    def combination(self, n, r):
        return self.fac[n] * self.invfac[r] % self.mod * self.invfac[n-r] % self.mod

    def permutation(self, n, r):
        return self.factorial(n) * self.invfactorial(n-r) % self.mod

    def factorial(self, i):
        return self.fac[i]

    def invfactorial(self, i):
        return self.invfac[i]

def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    x, y= map(int, input().split())
    if 2*x-y < 0 or 2*y-x < 0 or (2*x-y)%3 != 0 or (2*y-x)%3 != 0:
        print(0)
        return
    l = (2*x-y)//3
    k = (2*y-x)//3
    c = Combination(l+k)
    print(c.combination(l+k, l))

    


if __name__ == '__main__':
    main()

Measured memory_bytes: 61600
#include<bits/stdc++.h>
using namespace std;
int main(){
int ans=0;
int a,b,c,k;
cin >> a >> b >> c>> k;
int temp;
temp=min(k,a);
ans+=temp;
k-=temp;
temp=min(k,b);
k-=temp;
if(k>0)ans-=k;
cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    ll cnt=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            if(n-(i*j)>0)
                cnt++;
               if(i*j>=n)
                break;
        }
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 3584
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll h,w;
    ll n;
    ll a,b,c,d;
    cin>>n>>str;
    rep(i,n){
        if(str[i]=='I') sum++;
        else sum--;
                maxi=max(maxi,sum);

    }
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    string s, t;
    cin >> s >> t;
    rep(i, s.size())
    {
        string a, b;
        a = s.substr(i, s.size() - i);
        b = s.substr(0, i);
        string c = a + b;
        if(t==c){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

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

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

	int n;
	cin >> n;
	vector<int> A(n);

	REP(i, n) cin >> A[i];

	int max = *max_element(A.begin(), A.end());
	vector<int> B(max + 1);

	REP(i, n) {
		++B[A[i]];
	}

	REP(i, max + 1)
		REP(j, B[i]) {
			cout << i;
			if(i == max && j == B[i] - 1) cout << endl;
			else cout << ' ';
		}
	return 0;
}

Measured memory_bytes: 9060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll N, K;
    cin >> N >> K;

    vector<ll> p(N);
    rep(i, N) cin >> p[i];

    double ans = 0;
    vector<double> e(N, 0);
    rep(i, N) {
        e[i] = ((double)(1.0 + p[i]) * p[i] / 2.0) * (1.0 / (double)p[i]);
    }

    vector<double> sum(N, 0);
    rep(i, K) { sum[0] += e[i]; }
    reps(i, K, N) { sum[i - K + 1] = sum[i - K] + e[i] - e[i - K]; }

    // rep(i, N) { cout << e[i] << " "; }
    // cout << endl;

    // rep(i, N) { cout << sum[i] << " "; }
    // cout << endl;

    rep(i, N) { chmax(ans, sum[i]); }

    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}

Measured memory_bytes: 7928
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, int>;

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

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int x;
  cin >> x;
  int sum = 0;
  rep2(i, 1, x + 1) {
    sum += i;
    if (sum >= x) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <ctime>
#include <cmath>
#include <cassert>
#include <limits>
#include <functional>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(int)(n);++(i))

typedef struct {
    int id, ac, time;
    vector<int> logTime;
} data;

bool comp(data& a, data& b) {
    if (a.ac != b.ac)
        return a.ac > b.ac;
    if (a.time != b.time)
        return a.time < b.time;
    return a.id > b.id;
}


int main() {
    int M, T, P, R;
    while (true) {
        cin >> M >> T >> P >> R;
        if (!M && !T && !P && !R) break;
        vector<data> team(T);
        rep(i, T) {
            team[i].id = i+1;
            team[i].ac = 0;
            team[i].time = 0;
            rep(j, P) {
                team[i].logTime.push_back(0);
            }
        }
        rep(i, R) {
            int m, t, p, j; cin >> m >> t >> p >> j; t--; p--;
            if (!j) {
                team[t].ac++;
                team[t].time += m + team[t].logTime[p];
            } else {
                team[t].logTime[p] += 20;
            }
        }
        sort(team.begin(), team.end(), comp);
        rep(i, team.size()) {
            if (i) {
                if (team[i-1].ac == team[i].ac && team[i-1].time == team[i].time)
                    cout << "=";
                else
                    cout << ",";
            }
            cout << team[i].id;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int v[n+1];
	for(int i=1;i<=n;++i)
		v[i] = 0;
	for(int i=1,x;i<n;++i)
		cin>>x,v[x]++;
	for(int i=01;i<=n;++i)
		cout<<v[i]<<endl;
	return 0;
}

Measured memory_bytes: 4416
use std::io;

fn main() {
    let mut s = String::new();

    io::stdin()
        .read_line(&mut s)
        .expect("Failed to read line");

    let mut cnt: i32 = 1;

    for i in s.as_str().chars() {
        //奇数文字目
        if cnt % 2 != 0 {
            if i == 'L' {
                println!("No");
                return;
            }
        }else{
            //偶数番目
            if i == 'R' {
                println!("No");
                return;
            }
        }
        cnt += 1;
    }
    println!("Yes");
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define pb push_back
#define eb emplace_back
const  int MAX=1000000;

int main()
{
   ll t;

   t=1;

   while(t--)
   {



   ll a,b;

   cin>>a>>b;


   if(b%2==0)
   {

       ll n=b/4;

       if(b%4!=0)n++;

       if(n<=a && a*2<=b)cout<<"Yes"<<endl;
       else cout<<"No"<<endl;
   } else cout<<"No"<<endl;






   }

    }











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

#define MAX 2
int main(void)
{
	int a,b,c;
	int i;
	int cnt = 0;

	cin >> a;
	cin >> b;
	cin >> c;

	for (i=a; i<=b; i++) {
		if ((c%i) == 0) {
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}



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

int main() {
  bool x;
  cin >> x;
  
  cout << !x << endl;
  
  return 0;
}


Measured memory_bytes: 3628
N, M = map(int, input().split())
NG = []
a = 10**9+7
NG = [True for _ in range(N + 2)]
for i in range(M):
  NG[int(input())] = False
ans = [0 for _ in range(N + 2)]
ans[0] = 1
for i in range(N):
  if NG[i + 1]:
    ans[i + 1] = (ans[i + 1] + ans[i])%a
  if NG[i + 2]:
    ans[i + 2] = (ans[i + 2] + ans[i])%a
print(ans[N])


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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    int a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <bitset>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll f(string s) {
	ll res = 0, t = 1;

	for(int i = s.size()-1; i >= 0; i--) {
		if('0' <= s[i] && s[i] <= '9') {
			res += (s[i] - '0') * t;
		} else {
			res += (10 + (s[i] - 'a')) * t;
		}
		t *= 16;
	}
	return res;
}

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

	rep(q, n) {
		vector<string> v(9);
		vector<ll> t(9);
		rep(i, 9) {
			cin >> v[i];
			t[i] = f(v[i]);
		}

		ll ans = 0;

		vector< vector<int> > bit(9, vector<int>(32));
		rep(i, 9) {
			rep(j, 32) {
				if(t[i] & (1LL << j)) {
					bit[i][j] = 1;
				}
			}
		}

		ans = 0;
		ll sum = 0;
		rep(i, 32) {
			ll d = 0;
			rep(j, 8) {
				d += bit[j][i];
			}
			bitset<32> ss(sum);

			if( ((((sum >> i) & 1) + d) & 1) == bit[8][i]) {
				sum += (d << i);
			} else {
				d = 0;
				rep(j, 8) {
					d += bit[j][i] ^ 1;
				}
				sum += (d << i);
				ans += (1LL << i);
			}
		}

		cout << hex << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
m = 10**9+7
n,a,b = map(int,input().split())
def c(k):
  v = 1
  w = 1
  for i in range(k):
    v = v*(n-i)%m
    w = w*(i+1)%m
  return (v*pow(w,m-2,m)%m)
print((pow(2,n,m)-1-c(a)-c(b))%m)

Measured memory_bytes: 9144
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
using namespace std;

long long v[51];

int check()
{
	for (int i = 1; i <= 50; ++i)
		if (v[i] - 50 >= 0)
			return true;
	return false;
}


int main() {

	long long K ;


	cin >> K;

	if (K <= 1e16)
	{

		if (K == 0)
		{
			cout << "2\n 1 1";
		}
		else
		{
			if (K % 2 == 0)
			{
				cout << "2\n";

				cout << K / 2 + 1 << " " << K / 2;

			}
			else
			{
				cout << "2\n";

				cout << K - K / 2 + 1 << " " << K - K / 2 - 1;

			}
		}
	}
	else
	{

		cout << "50\n";


		if(K%50==0)
			v[1] = K / 50 + 50 - 1;
		else
			v[1]= K / 50 + 50;


		for (int i = 2; i <= 50; ++i)
		{
			v[i] = v[1] - (i - 1);
		}

		long long k = K % 50;

		k = 50 - k;

		if (k != 50)
		{

			for (long long i = 50; i >= 2 && k; --i,--k)
			{
				v[i] -= 1;
			}
		}

		for (int i = 1; i <= 50; ++i)
			cout << v[i] << " ";

	}



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
using namespace std;

int main() {

	int N, res = 0;
	cin >> N;

	int h[1000]; for (int i = 1; i <= N; i++) cin >> h[i];
	h[0] = 0;

	for (int j = 1; j <= N; j++) res += max(h[j] - h[j - 1], 0);

	cout << res << endl;

}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i)
bcs = as.map { |a| [a + 1, a - 1] }.flatten

count = [*as, *bcs].each_with_object(Hash.new(0)) do |n, h|
  h[n] += 1
end

puts count.values.max


Measured memory_bytes: 24708
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define F first
#define S second
#define pb push_back
#define PI 3.14159265
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, ans = 0, sum = 0;
    cin >> n >> m;
    vll a(n);
    map<ll, ll> M;
    fr(i, 0, n)
    {
        cin >> a[i];
    }
    fr(i, 0, n)
    {
        sum = (sum + a[i]) % m;
        if (sum == 0)
        {
            ans++;
        }
        ans += M[sum];
        M[sum]++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
    // cout << fixed << setprecision(5);

    lli n;
    cin>>n;

    deque<lli> a;
    REP(i,0,n){
        lli aa;
        cin>>aa;
        if(i==0)a.push_back(aa);
        else{
            if(a[a.size()-1]==aa)continue;
            a.push_back(aa);
        }
    }

    if(a.size()==1){
        cout<<1000<<endl;
        return 0;
    }

    a.push_front(INF);
    a.push_back(-INF);

    lli now=1000;
    lli nowKabu=0;
    REP(i,1,a.size()-1){
        if(nowKabu==0){
            if(a[i-1]>a[i]&&a[i]<a[i+1]){
                nowKabu = now/a[i];
                now %= a[i];
            }
        }
        else{
            if(a[i-1]<a[i] && a[i] >a[i+1]){
                now += nowKabu*a[i];
                nowKabu=0;
            }
        }
    }
    cout<<now<<endl;

    return 0;
}

Measured memory_bytes: 3616
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        long n = sc.nextLong();
        long v = 0;
        for(long i = 1; i <= n; i++){
            v += i*(n-i+1);
        }
        long e = 0;
        for(long i = 0; i < n-1; i++){
            long l = sc.nextInt();
            long r = sc.nextInt();
            e += Math.min(l,r)*(n-Math.max(l,r)+1);
        }
        pw.println(v-e);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

int main()
{
    int N, M, X, Y;
    std::string result = "No War";
    
    int max_x = -100;
    int min_y = 100;
    cin >> N >> M >> X >> Y;
    int x[N];
    int y[M];
    for (int i = 0; i < N; i++)
    {
        cin >> x[i];
    }
    for (int i = 0; i < N; i++)
    {
        if (max_x < x[i])
        {
            max_x = x[i];
        };
    }
    for (int j = 0; j < M; j++)
    {
        cin >> y[j];
    }
    for (int j = 0; j < M; j++)
    {
        if (min_y > y[j])
        {
            min_y = y[j];
        };
    }

    if (X >= Y)
    {
        result = "War";
    }
    if (max(max_x,X) >= min(min_y,Y))
    {
        result = "War";
    }

    cout << result << endl;
    // ここにプログラムを追記
}


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

int main()
{
    int t=0;
    string s,ss;
    cin>>s>>ss;
    for(int i=0;i<s.size();i++)
        if(s[i]!=ss[i])t++;
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 3912
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
string s;
cin>>s;
int a=0;
for(int i=0;i<s.length()/2;i++)
{
if(s[i]!=s[s.length()-1-i])
{
a++;
}
}
cout<<a<<endl;
}

Measured memory_bytes: 3608
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        v: usize,
        edge: usize,
        src: usize,
        e: [(usize, usize, i32); edge],
    }
    let mut g = vec![vec![]; v];
    for (s, t, d) in e {
        g[s].push((t, d));
    }
    let inf = (v * 10000 + 1) as i32;
    let mut dp = vec![inf; v];
    dp[src] = 0;
    for i in 0..v {
        let mut next = dp.clone();
        let mut update = false;
        for v in 0..v {
            if dp[v] == inf {
                continue;
            }
            for &(u, d) in g[v].iter() {
                if next[u] > dp[v] + d {
                    next[u] = dp[v] + d;
                    update = true;
                }
            }
        }
        dp = next;
        if !update {
            break;
        }
        if update && i == v - 1 {
            writeln!(out, "NEGATIVE CYCLE").unwrap();
            return;
        }
    }
    for d in dp {
        if d == inf {
            writeln!(out, "INF").unwrap();
        } else {
            writeln!(out, "{}", d).unwrap();
        }
    }
}

fn main() {
    run();
}



Measured memory_bytes: 5052
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int n, a;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a);
        if (a % 2 == 0)
        {
            if (!(a % 3 == 0 | a % 5 == 0))
            {
                printf("DENIED");
                return 0;
            }
        }
    }
    printf("APPROVED");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

int N,K;
int h[100010];
int cost[100010];
int main(){
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>h[i];
    }
    cost[0]=0;
    for(int i=1;i<N;i++){
        cost[i]=1001001001;
        for(int j=1;j<=K && 0<=i-j;j++){
            cost[i]=min( cost[i] , cost[i-j]+abs(h[i]-h[i-j]) );
        }
    }
    cout << cost[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
H = list(map(int,input().split()))
tmp = 0
new_tmp = 0
i = N-1
while i >= 1:
    if H[i] <= H[i-1]:
        new_tmp += 1
        i -= 1
        if new_tmp > tmp:
            tmp = new_tmp
    else:
        if new_tmp > tmp:
            tmp = new_tmp
        new_tmp = 0
        i -= 1
print(tmp)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 7;
const int INF = 1 << 29;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  reverse(s.begin(), s.end());
  vector<int> cnt(2019);
  int m = 0;
  int x = 1;
  int ans = 0;
  rep(i, n) {
    cnt[m]++;
    m += ((s[i] - '0') * x);
    m %= 2019;
    x = x * 10 % 2019;
    ans += cnt[m];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3720
def solve():
    n = int(input())
    ws = list(map(int, input().split()))
    min_diff = 1 << 8
    for t in range(1, n):
        small = ws[:t]
        large = ws[t:]
        diff = abs(sum(small) - sum(large))
        if diff < min_diff:
            min_diff = diff
    return min_diff


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


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	int m,d;cin>>m>>d;
	int ans = 0;
	for(int t=1;t<=m;t++){
		for(int i=2;i<=9;i++)
		for(int j=2;j<=9;j++){
			int v = i*10+j;
			if(v<=d&&i*j==t){
				ans++;
//				cout<<"!"<<i<<" "<<j<<" "<<t<<endl;
			}
		}
	} 
	cout << ans << endl;
}


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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) {
	if (b > a) return absdiff(b, a);
	return (a - b);
}
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion



signed main()
{	
	int N;
	cin >> N;

	VI X(N), L(N);
	rep(i, N) {
		cin >> X[i] >> L[i];
	}

	VP arm(N);
	rep(i, N) {
		// pairは辞書順で比較される
		// 終端が小さい順にしたいため、終端をfirstにする
		arm[i].first = X[i] + L[i];  // アームの終端
		arm[i].second = X[i] - L[i]; // アームの始端
	}

	// アームの終端が小さい順に残すロボットを決めることで最大化できる
	sort(All(arm));
	int ans = 0, pre = -INF;
	rbf(a, arm) {
		if (a.second >= pre) {
			ans++;
			pre = a.first;
		}
	}

	COL(ans);
	return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split(' '))
S = input()
T = input()

# 最大公約数
def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

# 最小公倍数
def lcm(a, b):
  return a*b/gcd(a, b)


ans = int(lcm(N, M))

# L / len(x)
L_N = int(ans / N)
# M / len(x)
N_M = int(ans / M)

S_list = []
for i in range(1, ans+1, L_N):
    S_list.append(i)

T_list = []
for i in range(1, ans+1, N_M):
    T_list.append(i)

intersect = set(T_list) & set(S_list)

S_in = [x for x, y in enumerate(S_list) if y in intersect]
T_in = [x for x, y in enumerate(T_list) if y in intersect]

flg = True
for x, y in zip(S_in, T_in):
    if S[x] == T[y]:
        continue
    else:
        flg = False

if flg:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 18540
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    lint n;
    scanf("%lld", &n);
    lint t = 1;
    int ans = 0;
    while(t < n){
        t *= 3;
        ++ans;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 3228
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
typedef long long ll;
#define NIL -INF

typedef struct Node_t {
  ll key;
  Node_t *parent;
  Node_t *left;
  Node_t *right;
} Node;

Node *root = NULL;

void insert(ll key) {
  Node *y = NULL;
  Node *x = root;

  Node *z = (Node*)malloc(sizeof(Node));
  z->key = key;
  z->parent = NULL;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if (y == NULL) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

void inorder(Node *n) {
  if (n == NULL) return;

  inorder(n->left);
  cout << " " << n->key;
  inorder(n->right);
}

void preorder(Node *n) {
  if (n == NULL) return;

  cout << " " << n->key;
  preorder(n->left);
  preorder(n->right);
}

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

  // REP(i, 500500) {
  //   Node n = {NIL, NIL, NIL, NIL};
  //   T[i] = n;
  // }

  REP(i, n) {
    string cmd;
    cin >> cmd;

    if (cmd == "insert") {
      ll key;
      cin >> key;
      insert(key);
    } else {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }

  return 0;
}

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

int N,Q;
string S;
vector<set<int>> abc(26);

void add(int i, char c){//type1
	if(S[i] == c) return;
	abc[S[i]-'a'].erase(i);
	S[i] = c;
	abc[S[i]-'a'].insert(i);
}

void out(int l, int r){//type2
	int ans = 0;
	rep(i,26){
		auto it = abc[i].lower_bound(l);
		if(it == abc[i].end()) continue;
		if(*it <= r) ans++;
	}
	printf("%d\n",ans);
}

int main(){
	cin>>N>>S>>Q;
	rep(i,N) abc[S[i]-'a'].insert(i);
	rep(i,Q){
		int t,a;
		cin>>t;
		if(t-1){//type2
			int b;
			cin>>a>>b;
			out(a-1, b-1);
		}
		else{//type1
			char b;
			cin>>a>>b;
			add(a-1, b);
		}
	}
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){
    ll A;
    cin >> A;
    
    ll ans = A * A;

    cout << ans << endl;
}

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

int main() {
  int N;
  cin>>N;
  int pay=0;
  for(int i=0;i<10;i++){
    pay+=1000;
  
  if(pay>=N){
    cout<<pay-N<<endl;
    break;
  }
  else{
    continue;
  }
 
  }
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<bool> flag(n);
    for(int i=0; i<n; i++) flag[i] = false;
    int d;
    int a;
    for(int i=0; i<k; i++){
        cin >> d;
        for(int j=0; j<d; j++){
            cin >> a;
            flag[a-1] = true;
        }
    }

    int count = 0;
    for(int i=0; i<n; i++){
        if(flag[i] == false) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
int INF = 1e9;
int C[12];
int A[12][12];
int sum[12];
int main() {
  int N, M, X; cin >> N >> M >> X;
  REP(i,N) {
    cin >> C[i];
    REP(j,M) {
      cin >> A[i][j];
    }
  }
  int ans = INF;
  for (int S = 0; S < (1 << N); ++S) {
    REP(j,M) sum[j] = 0;
    int cost = 0;
    REP(i,N) {
      if((S >> i) & 1) {
        cost += C[i];
        REP(j,M) {
          sum[j] += A[i][j];
        }
      }
    }
    bool ok = true;
    REP(j,M) {
      if(sum[j] < X) ok = false;
    }
    if(ok) {
      ans = min(ans, cost);
    }
  }
  if(ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 3196
#!/usr/bin/env python3
import sys
import collections


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    cur = 1
    c = {}
    route = []
    roop = None
    while (True):
        if cur in c:
            roop = cur
            break
        route.append(cur)
        c[cur] = 1
        cur = A[cur - 1]
    idx = route.index(roop)
    if K <= idx:
        print(route[K])
        return
    # route = route[idx:]
    print(route[(K - idx) % (len(route) - idx) + idx])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 37108
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<string>s(n);
  rep(i,0,n)cin>>s[i];
  map<string,ll>mp;
  rep(i,0,n)mp[s[i]]++;
  cout<<"AC x "<<mp["AC"]<<endl;
  cout<<"WA x "<<mp["WA"]<<endl;
  cout<<"TLE x "<<mp["TLE"]<<endl;
  cout<<"RE x "<<mp["RE"]<<endl;
  return 0;
}

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

queue<pair<pair<int,int>, int> > Q; // grid id, dist
int dist[51][51];
char grid[51][51];

int H, W, blackcnt=0, area=0;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};

int main() {
    cin >> H >> W;
    area=H*W;
    for (int i=0; i<H; i++) {
        cin >> grid[i];
    }
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (grid[i][j]=='#') {
                blackcnt++;
            }
        }
    }
    Q.push(make_pair(make_pair(0, 0), 0)); // the source
    memset(dist, -1, sizeof dist);
    while (!Q.empty()) {
        int x = Q.front().first.first, y = Q.front().first.second, d = Q.front().second; 
        Q.pop();
        if (dist[x][y] != -1) continue;
        dist[x][y] = d;
        for (int i=0; i<4; i++) {
            int nx = x + dx[i], ny = y + dy[i], nd = d + 1;
            if (nx >= 0 && nx < H && ny >= 0 && ny < W && grid[nx][ny] != '#') {
                Q.push(make_pair(make_pair(nx, ny), nd));
            }
        }
    }
    if (dist[H-1][W-1] == -1) {
        cout << "-1\n";
        return 0;
    }
    cout << area - blackcnt - dist[H-1][W-1] - 1 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> num(N), denom(N);
  for (int i = 0; i < N; i++){
    int p = 0;
    while (A[i][p] != '.'){
      p++;
      if (p == A[i].size()){
        break;
      }
    }
    if (p == A[i].size()){
      num[i] = stoll(A[i]);
      denom[i] = 1;
    } else {
      denom[i] = 1;
      for (int j = A[i].size() - 1; j > p; j--){
        denom[i] *= 10;
      }
      A[i] = A[i].substr(0, p) + A[i].substr(p + 1);
      num[i] = stoll(A[i]);
      long long tmp = gcd(num[i], denom[i]);
      num[i] /= tmp;
      denom[i] /= tmp;
    }
  }
  /*
  for (int i = 0; i < N; i++){
    cout << num[i] << ' ' << denom[i] << endl;
  }
  */
  vector<long long> num2(N, 1), denom2(N, 1);
  for (int i = 0; i < N; i++){
    while (num[i] % 2 == 0){
      num2[i] *= 2;
      num[i] /= 2;
    }
    while (num[i] % 5 == 0){
      num2[i] *= 5;
      num[i] /= 5;
    }
    denom2[i] = denom[i];
  }
  /*
  for (int i = 0; i < N; i++){
    cout << num2[i] << ' ' << denom2[i] << endl;
  }
  */
  map<pair<long long, int>, int> mp;
  for (int i = 0; i < N; i++){
    mp[make_pair(num2[i], denom2[i])]++;
  }
  long long ans = 0;
  for (auto P : mp){
    for (auto Q : mp){
      long long num3 = P.first.first;
      long long denom3 = P.first.second;
      long long cnt1 = P.second;
      long long num4 = Q.first.first;
      long long denom4 = Q.first.second;
      long long cnt2 = Q.second;
      if (P == Q){
        continue;
      }
      int cnt_two_num = 0;
      while (num3 % 2 == 0){
        num3 /= 2;
        cnt_two_num++;
      }
      while (num4 % 2 == 0){
        num4 /= 2;
        cnt_two_num++;
      }
      int cnt_five_num = 0;
      while (num3 % 5 == 0){
        num3 /= 5;
        cnt_five_num++;
      }
      while (num4 % 5 == 0){
        num4 /= 5;
        cnt_five_num++;
      }
      int cnt_two_denom = 0;
      while (denom3 % 2 == 0){
        denom3 /= 2;
        cnt_two_denom++;
      }
      while (denom4 % 2 == 0){
        denom4 /= 2;
        cnt_two_denom++;
      }
      int cnt_five_denom = 0;
      while (denom3 % 5 == 0){
        denom3 /= 5;
        cnt_five_denom++;
      }
      while (denom4 % 5 == 0){
        denom4 /= 5;
        cnt_five_denom++;
      }
      if (cnt_two_num >= cnt_two_denom && cnt_five_num >= cnt_five_denom){
        ans += cnt1 * cnt2;
      }
    }
  }
  ans /= 2;
  for (auto P : mp){
    long long denom3 = P.first.second;
    if (denom3 == 1){
      long long cnt1 = P.second;
      ans += cnt1 * (cnt1 - 1) / 2;
    }
  }
  cout << ans << endl;
}

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

int main(){
	int n;
	cin>>n;
	int minus=0;
	long long int ans=0;
	int m=1e+9+1;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin>>a[i];
		if (a[i]<0) {
			minus++;
		}
		ans+=abs(a[i]);
		m=min(m,abs(a[i]));
	}
	if (minus%2==0) {
		cout<<ans<<endl;
	}else {
		cout<<ans-2*m<<endl;
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define INF 9999999
#define in(a) cin>>a
#define out(a) cout<<a<<endl
int main()
{
	int x, y;
	vector<int> groups = { 0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
	cin >> x >> y;
	if (groups[x] == groups[y])out("Yes"); else out("No");
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  string s = "APPROVED";
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  for(int i=0;i<N;i++){
    if(vec.at(i) % 2==0 && vec.at(i) % 3!= 0 && vec.at(i) % 5 != 0){
      s = "DENIED";
    }
  }
  cout << s << endl;
}


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

using namespace std;

int main() {
  vector<string> vec(2);
  cin >> vec.at(0) >> vec.at(1);

  auto itr1 = find(vec.begin(), vec.end(), "1");
  if (itr1 == vec.end()) {
    cout << "1" << endl;
    return 0;
  }

  auto itr2 = find(vec.begin(), vec.end(), "2");
  if (itr2 == vec.end()) {
    cout << "2" << endl;
    return 0;
  }

  cout << "3" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  int a[40],ans=1;
  rep(i,33){
    a[i]=i*i;
  }
  cin>>n;
  repi(i,2,33){
    while((a[i]*i) <= n){
      a[i]=a[i]*i;
    }
    if(a[i]<=n) ans=max(ans,a[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 10;

int n;
ll a[maxn], w[maxn], S;
int main() {
//	freopen("data.in","r",stdin);
  scanf("%d%lld", &n, &S);
	for(int i = 1;i <= n;i ++) scanf("%lld%lld", &a[i], &w[i]);
	int head = 1, tail = n;
	ll Ans = 0; int lst = -1;
	for(int i = 1;i <= n;i ++) {
    if(a[tail] < S || (a[head] < S && w[head] < w[tail])) {
			w[tail] += w[head];
			if(lst != -1) Ans += (ll)abs(lst - a[head]);
			lst = a[head]; head ++;
		}
		else {
			w[head] += w[tail];
			if(lst != -1) Ans += (ll)abs(lst - a[tail]);
			lst = a[tail]; tail --;
		}
	}
	Ans += (ll)abs(lst - S);
//	if(S > a[head] && lst != 1) Ans += S - a[head];
//	if(S < a[head] && lst != 0) Ans += a[head] - S;
	printf("%lld\n", Ans);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    float i,r;
    int Acount=0,Bcount=0,Ccount=0,Dcount=0,acount=0,bcount=0,ccount=0,dcount=0;
    while(cin>>i>>r){
        if(i>=1.1)Acount++;
        else if(i>=0.6&&i<1.1)Bcount++;
        else if(i>=0.2&&i<0.6)Ccount++;
        else if(i<0.2)Dcount++;
        if(r>=1.1)acount++;
        else if(r>=0.6&&r<1.1)bcount++;
        else if(r>=0.2&&r<0.6)ccount++;
        else if(r<0.2)dcount++;
    }
    cout<<Acount<<" "<<acount<<endl;
    cout<<Bcount<<" "<<bcount<<endl;
    cout<<Ccount<<" "<<ccount<<endl;
    cout<<Dcount<<" "<<dcount<<endl;
    return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<cstring>
#include<climits>
#include<algorithm>
#include <iomanip> 
#define ll long long int
using namespace std;

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

Measured memory_bytes: 5188
#include<iostream>
#include<cstdio>
#include<fstream>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<cstring>
#define MAX 110000
#define INF 10000000

using namespace std;

map <string, int> dp;
int dir[4] = {1,-1,4,-4};

//BFS 
void Bfs(){
	//队列
	queue <string> que;
	que.push("01234567"); 
	dp["01234567"] = 0;
	while(!que.empty()){
		string now = que.front();
		que.pop();
		//找到0的位置
		int pos = 0;
		for(int i=0; i<8; i++){
			if(now[i] == '0'){
				pos = i;
				break;
			}
		} 
		//在0的位置四向遍历 
		for(int i=0; i<4; i++){
			int n = pos + dir[i];
			string next = now;
			if(n>=0 && n<8&&!(pos==3&&i==0)&&!(pos==4&&i==1)){
				swap(next[pos], next[n]);
				if(dp.find(next) == dp.end()){
					dp[next] = dp[now] + 1;	
					que.push(next);
				}			
			}
		}
	}
}

//测试函数 
int main()
{
    Bfs();
    string s;
    while(getline(cin,s)){
       s.erase(remove(s.begin(),s.end(),' '),s.end());
       cout<<dp[s]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
#define fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll a[N],dp[N];
bool vis[N],vis1[N];
vector<ll>v[N];
pair<ll,ll>p[N],p1[N];
set<int>s;
map<string,ll>mp;

main()
{
    fast_IO
    int n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=1; i<n; i++)
        dp[i]=1e18;

    for(int i=1; i<n; i++)
    {
        for(int j=1; j<=k; j++)
        {
            if(i>=j)
                 dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }
    }
    cout<<dp[n-1];

}










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

int main(){
    int n,a,b,c,d[105];
    cin >> n;
    cin >> a >> b;
    cin >> c;
    for(int i=0; i<n; i++){
       cin >> d[i];
    }
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            if(d[i]<d[j]){
                swap(d[i], d[j]);
            }
        }
    }
    int sum=0;
    int ans=0;
    int w;
    for(int i=0; i<n; i++){
        sum += d[i];
        w = (c+sum)/(b*(i+1)+a);
        if(w >= ans){
            ans = (c+sum)/(b*(i+1)+a);
        }else{
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3072
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
S = [0]*N
for i in range(N):
    S[i] = str(input())

print(len(set(S)))

Measured memory_bytes: 104804