akhauriyash/Code-Regression huggingface dataset:
import * as fs from "fs"
const inp:string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n')
export const res = (inp) =>{
    interface obj {
        AC: number,
        WA: number,
        TLE: number,
        RE: number
    }

    let obj:obj = {
        AC: 0,
        WA: 0,
        TLE: 0,
        RE: 0
    }
    inp.shift()
    for (let element of inp){
        if (element === 'AC'){
            obj.AC += 1
        } else if (element === 'WA'){
            obj.WA += 1
        } else if (element === 'TLE'){
            obj.TLE += 1
        } else if (element === 'RE'){
            obj.RE += 1
        }
    }
    console.log(`AC x ${obj.AC}\nWA x ${obj.WA}\nTLE x ${obj.TLE}\nRE x ${obj.RE}`)
    //return `AC x ${obj.AC}\nWA x ${obj.WA}\nTLE x ${obj.TLE}\nRE x ${obj.RE}`
}
res(inp)


Measured memory_bytes: 40672
#include <bits/stdc++.h>
using namespace std;
#define ll long long
unordered_set<ll>white;
unordered_map<ll,vector<ll>>seen;
bool visited[100001];
ll dp[100001];
void dfs(ll i)
{
    visited[i]=true;
    if(white.find(i)!=white.end())
    {
        dp[i]+=1;
    }
    for(ll j=0;j<seen[i].size();j++)
    {
        if(!visited[seen[i][j]])
        {
            dfs(seen[i][j]);
            dp[i]+=dp[seen[i][j]];
        }
    }
}
int main(){
    // Your code here!
    
    string s,t;
    cin>>s>>t;
    bool np=false;
    for(ll i=0;i<s.length();i++)
    {
        if(s[i]==t[i])
        {
            continue;
        }
        else
        {
            np=true;
            break;
        }
    }
    if(s.length()+1==t.length()&&!np)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,m;
  cin >> n >> m;
  cout << n * (n-1) / 2 + m * (m-1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
using namespace std;
int A[4][4];
int n, m;
bool checkrow(int r){
	for(int i = 0; i < 3; i++) if(A[r][i] != -1) return false;
	return true;
}
bool checkcol(int r){
	for(int i = 0; i < 3; i++) if(A[i][r] != -1) return false;
	return true;
}
int main(){
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)
			scanf("%d", &A[i][j]);

	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		int x;
		scanf("%d", &x);
		for(int j =	0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(A[j][k] == x) A[j][k] = -1;
			}
		}
	}
	bool ans = false;
	for(int i = 0; i < 3 && !ans; i++){
		ans = checkrow(i) || checkcol(i);
	}
	bool d1 = (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1);
	bool d2 = A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1;
	ans = ans || d1 || d2;
	printf("%s\n", ans ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type gcd(Type a, Type b,Type c)
{
	int x = gcd(a, b);
	return gcd(x, c);
}

int main()
{
	int k;
	cin >> k;
	int ans = 0;
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			for (int c = 1; c <= k; c++) {
				ans += gcd(a, b, c);
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<string> s(N);
    int count = 0;
    int a = 0, b = 0, ba = 0;
    for(int i=0; i<N; ++i){
        cin >> s[i];
        int pos = 0;
        while((pos=s[i].find("AB", pos)) != string::npos){
            ++count;
            pos += 2;
        }
        if(s[i][0]=='B'){
            if(s[i][s[i].length()-1]=='A') ++ba;
            else ++b;
        }
        else if(s[i][s[i].length()-1]=='A') ++a;
    }
    int m = min(a, b);
    if(m>0){
        count += m + ba;
    }
    else{
        count += max(a, b)>0? ba : max(0, ba-1);
    }
    cout << count << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	vector<int> v(5);
	int mn = 0;
	int ans = 0;
	cu(i,0,5){
		int x;
		cin >> x;
		if(x % 10 > 0)mn = max(mn, 10 - (x % 10));
		ans += ((x+9)/10) * 10;
	}
	cout << ans - mn << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int mult_2(int n) {
    int myNum = n;

    while(myNum % 2 != 0 || myNum % n != 0) {
        myNum++;
    }

    return myNum;
}


int main() {
    int n;

    scanf("%d", &n);

    printf("%d\n", mult_2(n));

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define IOS ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
	string ch;
	cin>>ch;
	int len = ch.size();
	for(int i =1;i <=len; i++)
	{
		cout<< 'x';
	}
	cout<< endl;
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::VecDeque;

fn main() {
    input!{
        n: usize,
        s: chars,
        q: usize,
        ks: [usize; q],
    }

    for &k in ks.iter() {
        let mut ds = VecDeque::new();
        let mut ms = VecDeque::new();
        let mut ans = 0;
        let mut cur = 0;

        for i in 0..n {
            while ds.len() > 0 && i - ds.front().unwrap() >= k {
                ds.pop_front();
                cur -= ms.len();
            }
            while ms.len() > 0 && i - ms.front().unwrap() >= k {
                ms.pop_front();
            }

            if s[i] == 'D' {
                ds.push_back(i);
            } else if s[i] == 'M' {
                ms.push_back(i);
                cur += ds.len();
            } else if s[i] == 'C' {
                ans += cur;
            }
        }

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


Measured memory_bytes: 20676
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 3e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n,m;
struct uzi{
  int x,y;
  bool operator < (const uzi & t)const{
    return x<t.x;
  }
}p[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>m>>n;
  for(int i=1;i<=m;i++){
    cin>>p[i].x>>p[i].y;
  }
  sort(p+1,p+1+m);
  LL ans=0;
  for(int i=1;i<=m;i++){
    int x=min(n,p[i].y);
    ans+=1ll*x*p[i].x;
    n-=x;
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
ll qpow(ll a, ll n)
{
    ll re = 1;
    while(n)
    {
        if(n&1)
            re=(re*a)%MOD;
        n>>=1;
        a=(a*a)%MOD;
    }
    return re%MOD;
}
/*
ll jiecheng(ll n)
{
	
	ll now;
	if(n<10000000) 
    now=1;
    else now=a[n/10000000-1];
    for(int i=n/10000000*10000000+1;i<=n;i++)
    now=now*i%MOD;
    return now%MOD;
}*/
ll pow(ll a,ll b,ll m)
{
    ll ans=1;
    a%=m;
    while(b)
    {
        if(b&1)ans=(ans%m)*(a%m)%m;
        b/=2;
        a=(a%m)*(a%m)%m;
    }
    ans%=m;
    return ans;
}
ll inv(ll x,ll p)
{
    return pow(x,p-2,p);
}
ll C(ll n,ll m,ll p)
{
    if(m>n)return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<=n;i++) up=up*i%p;
    for(int i=1;i<=m;i++) down=down*i%p;
    return up*inv(down,p)%p;
}
ll Lucas(ll n,ll m,ll p)
{
    if(m==0)return 1;
    return C(n%p,m%p,p)*Lucas(n/p,m/p,p)%p;
}
int main()
{
	ll n,a,b;cin>>n>>a>>b;
	ll sum;
	sum=qpow(2,n);
	sum--;
	/*ll ans=0;
	ans=jiecheng(n-a)*jiecheng(a);
	ans%=MOD;
	sum=sum-(jiecheng(n)/ans)%MOD;
	
	ans=jiecheng(n-b)*jiecheng(b);
	ans%=MOD;
	sum=sum-(jiecheng(n)/ans)%MOD;
	cout<<sum%MOD<<endl;*/
	sum-=Lucas(n,a,MOD);
	sum-=Lucas(n,b,MOD);
	while(sum<0)
	sum+=MOD;
	cout<<sum<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  vector<int> arr(n);
  for(int i=0; i<n; i++) cin>>arr[i];
  
  vector<int> dp(n,INT_MAX);
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  
  for(int i=2; i<n; i++){
  	dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1], abs(arr[i]-arr[i-2])+dp[i-2]);
  }
  cout<<dp[n-1]<<endl;
  
  return 0;
}

Measured memory_bytes: 4048
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.nextLine();
        String T = scanner.nextLine();
        StringBuilder sb = new StringBuilder();
        if (S.length() < T.length()) {
            System.out.println("UNRESTORABLE");
            return;
        }


        for (int i = S.length() - T.length(); i >= 0; i--) {
            if (check(i, S, T)) {
                answers(i, S, T);
                return;
            }
        }

        System.out.println("UNRESTORABLE");

    }

    private static boolean check(int x, String a, String b) {
        for (int i = 0; i < b.length(); i++) {
            if (a.charAt(x) != b.charAt(i) && a.charAt(x) != '?')
                return false;
            x++;
        }
        return true;
    }

    private static void answers(int start, String a, String b) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < a.length(); i++) {
            if (i == start) {
                sb.append(b);
                i += b.length() - 1;
            } else if (a.charAt(i) == '?') {
                sb.append('a');
            } else {
                sb.append(a.charAt(i));
            }
        }
        System.out.println(sb.toString());
    }

}




Measured memory_bytes: 22868
n = int(input())
s = input()

score = []
score.append(s[1:].count("E"))

for i in range(1, n):
    diff = -1 if s[i] == "E" else 0
    diff += 1 if s[i-1] == "W" else 0
    score.append(score[-1]+diff)

print(min(score))

Measured memory_bytes: 15564
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		String t=s.next();
		int a=Integer.parseInt(t.substring(0,2));
		int b=Integer.parseInt(t.substring(2));
		if(0<a&&a<13) {
			if(0<b&&b<13) {
				System.out.println("AMBIGUOUS");
			}else {
				System.out.println("MMYY");
			}
		}else {
			if(0<b&&b<13) {
				System.out.println("YYMM");
			}else {
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 23252
package main

import (
	"fmt"
)

func main() {


	var S string

	fmt.Scan(&S)

	bcnt :=0
	sum :=0

	for i:=0;i<len(S);i++{

		if S[i:i+1] == "B"{

			bcnt++
		
		}else{

			sum += bcnt
		}

	}

	fmt.Println(sum)
}

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

int main()
{
    int t,x,y,px=0,py=0,n;
    cin>>n;
    int i;
    int dist=0;
    int xy=0;
    for(i=1;i<=n;i++)
    {
        cin>>t>>x>>y;
        dist=dist+fabs(x-px)+fabs(y-py);
        xy=t-dist;
         if(xy<0)
         {
             cout<<"No";
             return 0;
         }
         else if(xy%2!=0&&xy>0)
         {
             cout<<"No";
             return 0;
         }
         px=x;
         py=y;

    }
   cout<<"Yes";
    return 0;
}


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

int main(){
    long long a,b;
    cin>>a;
    vector<int>v(a);
    vector<int>v1(a,1e9);
    cin>>b;
    for(int i=0;i<a;i++){
        cin>>v[i];
    }
    v1[0]=0;
    for(int i=0;i<a;i++){
        for(int j=1;j<=b;j++)if(i+j<a){
           v1[i+j]=min(v1[i+j],v1[i]+abs(v[i+j]-v[i]));
        }
    }
    cout<<v1[a-1];

}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
	int n,d,s=0;
	scanf("%d %d",&n,&d);
	while(n--) 
	{
		long long int x,y;
		double dis;
		scanf("%lld %lld",&x,&y);
		x=x*x;
		y=y*y;
		dis=x+y;
		dis=(double) sqrt(dis);
		if(dis<d || dis==d){
			s++;
			
		}
	}
	printf("%d\n",s);
	return 0;
�}

Measured memory_bytes: 2092
n = int(input())
a = list(map(int,input().split()))
b = a.copy()
for i in range(1,n):
    a[i] += a[i-1]
ans = 0
for i in range(n-1):
    ans += b[i] * (a[-1]-a[i])
mod = 10**9 + 7
print(ans % mod)


Measured memory_bytes: 104880
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair
#define F first
#define S second

int main() {
	int c[3] = {};
	string s;
	cin >> s;
	REP(i, s.size()) c[s[i] - 'a']++;
	sort(c, c + 3);
	if(s.size() == 1) cout << "YES" << endl;
	else if (c[2] - c[0] > 1) cout << "NO" << endl;
	else cout << "YES" << endl;
}


Measured memory_bytes: 512
import numpy as np
N,L = map(int,input().split())
s = []
for i in range(N):
    s.append(L+i)
ans_pre = abs(np.array([s]))
if L + N <= 0:
    print(-1*(sum(ans_pre[0])-min(ans_pre[0])))
else:
    print(sum(s)-min(ans_pre[0]))

Measured memory_bytes: 21404
import java.util.*;

public class Main {

    static List<List<Integer>> edges = new ArrayList<>();
    static int[] dp = null;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] ps = new double[N];
        for (int i = 0; i < N ; i++) {
            ps[i] = sc.nextDouble();
        }

        double ans = 0;

        double[][] dp= new double[N+1][N+1];
        dp[0][0] =1;
        for (int i = 1; i <= N ; i++) {
            for (int j = 0; j <= i+1 && j<=N  ; j++) {
                if(j ==0 ){
                    dp[j][i]  =dp[j][i-1]* (1- ps[i-1]);
                }else{
                    dp[j][i]  =dp[j-1][i-1]* ps[i-1]
                                +dp[j][i-1]* (1- ps[i-1]);
                }
            }
        }

        for (int i = (N+1)/2; i <=N ; i++) {
            ans += dp[i][N];
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 122372
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main(){
  int N, K, one;
  cin >> N >> K;

  vt<int> A(N);
  rep(i,N){
    cin >> A[i];
    if(A[i]==1)
      one = i+1;
  }

  int l = one - 1, r = N-one;
  int ans = (l + r)/(K-1);

  if((l + r)%(K-1)!=0)
    ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch MinorChange | diff MinorChange.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address MinorChange.cpp && ./a.out

/*

 6/27/2020

 5:01-

 */

string S,T;

void solve() {
  int res=0;
  REP(i,SZ(S)) res+=S[i]!=T[i];
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>S>>T;
  solve();

  return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,i,j,a[510][510],b[510][510];
char s[510];
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%s",s+1);
		for(j=1;j<=m;j++)if(s[j]=='#')a[i][j]=b[i][j]=1;
	}
	for(i=1;i<=n;i++)a[i][1]=b[i][m]=1;
	for(i=1;i<=n;i++)
	 for(j=2;j<m;j++)if(i&1)a[i][j]=1;
	  else b[i][j]=1;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++)if(a[i][j])printf("#");
		 else printf(".");
		puts("");
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++)if(b[i][j])printf("#");
		 else printf(".");
		puts("");
	}
}
/*
奇数行红，偶数行蓝，第一列红，最后一列蓝。。。
wrnm 
*/

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000000;
int exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1){
        if(exp(x,y-1)==-1)return -1;
        if(x*exp(x,y-1)>big)return -1;
        return (exp(x,y-1)*x);
    }
    ll t=exp(x,y/2);
    if(t==-1||t*t>big)return -1;
    return (t*t);
}

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


ll in(ll x){
    return exp(x,big-2);
}

int half(int k,vector<int> &eat,int l,int r,bool aaa){//[l,r)
    if(aaa){
        ll j=1;
        while(j<=r-1){
            if(eat[j]>k)return half(k,eat,j/2-1,j,false);
            j*=1;
        }
        return half(k,eat,j/2-1,r,false);
    }
    if(r-l==1)return r;
    int m=(l+r)/2;
    if(eat[m]>k){
        return half(k,eat,l,m,false);
    }else{
        return half(k,eat,m,r,false);
    }
}

int find(int k,vector<int> &eat,int chi){
    if(eat[chi-1]<k)return -1;
    if(eat[0]>k)return 0;
    int s=half(k,eat,0,chi,true);
    return s;
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    int n;cin >> n;
    vector<int> a(n);
    int all=0;
    rep(i,n){
        cin >> a[i];
        all^=a[i];
    }
    rep(i,n){
        a[i]^=all;
        cout << a[i] << endl;
    }
    
    
}

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


def solve(K: int):
    A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(A[K-1])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
const ll mod=1e9+7;

struct edge{
  ll to,cost;
};

ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true){
      ll n,m;
      cin>>n>>m;
      if(n==0 && m==0) return 0;
      vector<vector<edge> > g(110);
      ll dist[110][3];
      rep(i,110)rep(j,3) dist[i][j]=inf;
      rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        g[a].push_back({b,c});
        g[b].push_back({a,c});
      }
      priority_queue<P1,vector<P1>,greater<P1> > que;
      que.push(P1(0,P(1,0)));
      while(!que.empty()){
        P1 p=que.top();
        que.pop();
        ll now=p.first;
        ll v=p.second.first,cnt=p.second.second;
        if(dist[v][cnt]<now) continue;
        for(auto itr:g[v]){
          if(cnt==0){
            if(dist[itr.to][0]>now+itr.cost){
              dist[itr.to][0]=now+itr.cost;
              que.push(P1(dist[itr.to][0],P(itr.to,0)));
            }
            if(dist[itr.to][1]>now){
              dist[itr.to][1]=now;
              que.push(P1(dist[itr.to][1],P(itr.to,1)));
            }
          }else if(cnt==1){
            if(dist[itr.to][2]>now){
              dist[itr.to][2]=now;
              que.push(P1(dist[itr.to][2],P(itr.to,2)));
            }
          }else{
            if(dist[itr.to][2]>now+itr.cost){
              dist[itr.to][2]=now+itr.cost;
              que.push(P1(dist[itr.to][2],P(itr.to,2)));
            }
          }
        }
      }
      cout<<dist[n][2]<<endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n,a,b;

int main(){
  cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
Q = int(input())
for i in range(Q) :
    c, a, n = map(int, input().split())
    teams = 0
    
    mini = min(c, a, n)
    teams += mini
    c -= mini
    a -= mini
    n -= mini
    
    mini = min(int(c/2), a)
    teams += mini
    c -= mini * 2
    a -= mini
    
    mini = int(c/3)
    teams += mini
    
    print(teams)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y; cin>>x>>y;
    for(int i=0; i<=x;i++){
        if(2*i + 4*(x-i) == y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
int K;
int mi[101010];
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K;
	FOR(i,K) mi[i]=1<<30;
	priority_queue<pair<int,int>> P;
	for(i=1;i<=9;i++) {
		mi[i%K]=min(mi[i%K],i);
		P.push({-mi[i%K],i%K});
	}
	
	while(P.size()) {
		int cur=P.top().second;
		int cost=-P.top().first;
		P.pop();
		if(cost!=mi[cur]) continue;
		FOR(i,10) {
			int nc=cost+i;
			int nex=(cur*10+i)%K;
			if(mi[nex]>nc) {
				mi[nex]=nc;
				P.push({-mi[nex],nex});
			}
		}
	}
	
	cout<<mi[0]<<endl;
	
	
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

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

using namespace std;

long long a[105];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    if (n == 1) {
        cout << a[0] << endl;
        return 0;
    }
    long long m = a[0] / __gcd(a[0], a[1]) * a[1];
    for (int i = 2; i < n; ++i)
        m = m / __gcd(m, a[i]) * a[i];
    cout << m << endl;
    return 0;
}


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

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long a = (x / 11) * 2;
        long b = x % 11;
        if (b != 0) {
            if (b <= 6) {
                a++;
            } else {
                a += 2;
            }
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 21716
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;

int a[100005];
int main()
{

    int n,L,R;
    while(scanf("%d",&n)==1)
    {
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        int sum=0,ans=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==a[i+1])
                ans++;
            else
            {
                if((ans+1)%2==1)
                    sum++;
                ans=0;
            }
        }
        printf("%d\n",sum);

    }



    return 0;
}


Measured memory_bytes: 640
#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(){
	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> q(n);
	rep(i, n) cin >> p.at(i);
	rep(i, n) cin >> q.at(i);

	vector<int> a(n);
	rep(i, n) a.at(i) = i+1;

	map<vector<int>, int> mp;
	do{
		mp[a] = mp.size();
	}while(next_permutation(a.begin(), a.end()));

	int ans = abs(mp[p] - mp[q]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,m;
    cin >> n >> m;
    ll time=1900*m+100*(n-m);
    rp(i,m) time*=2;
    print(time);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

const int MAX_N = 100;
const long long INF = 10000000000000;

long long DP[MAX_N][MAX_N];
pair<int,int> P[MAX_N];

int main()
{
	int n;
	long long q;
	cin >> n;
	for(int i=0;i<n;i++){
		scanf("%d",&P[i].first);
		scanf("%d",&P[i].second);
	}
	fill(DP[0],DP[n],INF);
	for(int i=0;i<n;i++){
		DP[i][i] = 0;
	}
	for(int l=1;l<n;l++){
		for(int i=0;i<n-l;i++){
			for(int k=i;k<i+l;k++){
				q = DP[i][k] + DP[k+1][i+l] + P[k].second * P[i].first * P[i+l].second;
				if(q < DP[i][i+l]){
					DP[i][i+l] = q;
				}
			}
		}
	}
	cout << DP[0][n-1] << "\n";
}

Measured memory_bytes: 3220
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
template<typename T>T lcm(T a, T b){
  T g = gcd(a,b);
  return a/g*b; 
}
template<typename T>T power(T a,T b){
  T tmp = 1;
  rep(i,b){
    tmp *= a;
  }
  return tmp;
}
int main(){
  ll a;cin>>a;
  print(a * a * 3)
  
  
  
  return 0;
}


Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())
water=[]
for i in range(1+30//a):
  for j in range(1+30//b):
    hoge=a*i*100+b*j*100
    if(hoge<=f):
      water.append(hoge)
water=list(set(water))
      
sugar=[]
for i in range(1+3000//c):
  for j in range(1+3000//d):
    hoge=c*i+d*j
    if(hoge<=f):
      sugar.append(hoge)
sugar=list(set(sugar))

node_max=0
water_max=0
sugar_max=0
for i in range(len(water)):
  for j in range(len(sugar)):
    if(water[i]+sugar[j]<=f):
      if(sugar[j]==0):
        node=0
      else:
        node=sugar[j]/(water[i]+sugar[j])
      if(node_max<=node and e*water[i]//100>=sugar[j]):
        water_max=water[i]
        sugar_max=sugar[j]
        node_max=node

print(water_max+sugar_max,sugar_max)

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


int main(){
  int n, k;
  string str;
  cin >> n >> k;
  cin >> str;

  transform(str.begin() + k -1, str.begin() + k, str.begin() + k -1, ::tolower);
  cout << str << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    ll MAX = max(n, m);
    ll memo[MAX];
    memo[1] = 1;
    rep(i, 2, MAX+1) memo[i] = (memo[i-1] * i) % MOD;

    if (abs(n-m) > 1) cout << 0 << endl;
    else if (abs(n-m) == 1) cout << memo[n] * memo[m] % MOD << endl;
    else cout << 2 * memo[n] * memo[m] % MOD << endl;
}

Measured memory_bytes: 1024
import functools

A = int(input())
B = int(input())
C = int(input())
X = int(input())

if min(A, B, C, X) == X:
	print(0)

@functools.lru_cache(1000)
def num_patterns(A, B, C, X):
    if X == 0:
      	return 1

    if min(A, B, C, X) == X:
        return 0

    if A > 0:
        return sum(
            num_patterns(0, B, C, X - 500 * nA) if X >= 500 * nA else 0
            for nA in range(0, A + 1)
        )
    if B > 0:
        return sum(
            num_patterns(0, 0, C, X - 100 * nB) if X >= 100 * nB else 0
            for nB in range(0, B + 1)
        )
    if C > 0 and X % 50 == 0 and X / 50 <= C:
        return 1
    else:
        return 0

print(num_patterns(A, B, C, X))

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int mx = max({a,b,c});
    int mn = min({a,b,c});
    int md = a + b + c - mx - mn;
    if(a %2 == b %2 && b %2 == c%2) {
        cout << (mx - md) / 2 + (mx - mn) / 2 << endl;
    }
    else {
        if(mn %2 == md %2) { 
            cout << (2 * mx - md - mn -2) /2 + 1 << endl;
        } else 
        cout << (mx + 1 - md  + mx + 1 - mn - 1) / 2  + 1<< endl;

    }

    return 0;
}


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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    if(a==5||a==7&&b==5||b==7&&c==5||c==7)
        if(a+b+c==17)
            cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f(int n){
	int sum = 0;
	while(n>0){
		sum += n%10;
		n /= 10;
	}
	return sum;
}

int main() {
  int n;
  cin >> n;
  int x = f(n);
  if(n%x == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        Node W[] = new Node[n];
        int s = Integer.MAX_VALUE, cost = 0;
        for (int i = 0; i < n; i++) {
            W[i] = new Node();
            W[i].value = scan.nextInt();
            W[i].place = -1;
            if (s > W[i].value)
                s = W[i].value;
        }
        for (int j = 0; j < n; j++) {
            int min = Integer.MAX_VALUE, place = -1;
            for (int i = 0; i < n; i++) {
                if (W[i].place != -1)
                    continue;
                if (min > W[i].value) {
                    min = W[i].value;
                    place = i;
                }
            }
            W[place].place = j;
        }
        for (int i = 0; i < n; i++) {
            int j = W[i].place;
            if (j != -1 && j != i) {
                int cnt = 1, min, sum;
                min = sum = W[i].value;
                while (j != i) {
                    int next = W[j].place;
                    if (min > W[j].value)
                        min = W[j].value;
                    sum += W[j].value;
                    cnt++;
                    W[j].place = -1;
                    j = next;
                }
                if(sum + (cnt - 2) * min < sum + min + (cnt + 1) * s){
                    cost += sum + (cnt - 2) * min;
                }
                else{
                    cost += sum + min + (cnt + 1) * s;
                }
            }
        }
        System.out.println(cost);
    }
}
class Node {
    int value;
    int place;
}


Measured memory_bytes: 31720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,a;
    int i,j,k,s;
    while(~scanf("%lld",&n))
    {
        a = n;
        s = 0;
        while(a!=0)
        {
            s += a%10;
            a/= 10;
        }
        if(n%s==0) cout<<"Yes"<<endl;
        else cout <<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3572
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
b = [[] for _ in range(n+1)]
for i in range(m):
    b[a[i][0]].append((a[i][1],i+1))
#print(b)
for i in range(1,n+1):
    b[i].sort()
ans = ["."]*m
for i in range(1,n+1):
    for j in range(len(b[i])):
        ans[b[i][j][1]-1] = "0"*(6-len(str(i))) + str(i) + "0"*(6-len(str(j+1))) + str(j+1)
print(*ans, sep="\n")

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



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    string s;
    cin>>s;
    int n=s.size();
    ll ans=n*(n-1)/2;
    map<char,int> mp;
    rep(i,n){
        mp[s[i]]++;
    }
    for(auto x:mp){
        ans-=x.sc*(x.sc-1)/2;
    }
    cout<<ans+1<<endl;
    
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 5*1e5;

int n;
vvint bit(26,vint(MAX+1));

int sum(int i, int id) {
    int s = 0;
    while (i > 0) {
        s += bit[id][i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x, int id) {
    while (i <= n) {
        bit[id][i] += x;
        i += i & -i;
    }
}

int main() {
    cin >> n;
    string s; cin >> s;
    for (int i = 0; i < n; i++) {
        add(i+1,1,s[i]-'a');
    }
    int q; cin >> q;
    rep(i,q) {
        int type; cin >> type;
        if (type == 1) {
            int x; cin >> x;
            char c; cin >> c;
            add(x,1,c-'a');
            add(x,-1,s[x-1]-'a');
            s[x-1] = c;
        }
        if (type == 2) {
            int l, r; cin >> l >> r;
            int ct = 0;
            rep(j,26) {
                if (sum(r,j)-sum(l-1,j) > 0) ct++;
            }
            cout << ct << endl;
        }
    }
}

Measured memory_bytes: 52992
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;

signed main(){
	int a,b;
	cin>>a>>b>>n;
	int x=min(b-1,n);
	cout<<a*x/b-a*(x/b)<<endl;
}


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

using namespace std;

#define M 110

int main(){
  int n;
  while(cin>>n,n){
    int b[M][M]={{0}};
    int w,h,s,t;
    vector<pair<int,int> > v(n);
    cin >> w >> h;
    for(int i=0;i<n;i++)
      cin >> v[i].first >> v[i].second;
    cin >> s >> t;
    for(int i=0;i<n;i++){
      int x=v[i].first,y=v[i].second;
      for(int xx=0;xx<s && x-xx>=1;xx++){
	for(int yy=0;yy<t && y-yy>=1;yy++){
	  b[y-yy][x-xx]++;
	}
      }
    }
    int ans=0;
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	ans=max(ans,b[i][j]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
SS ss;
#define debug ss
#endif

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define repc(i,n) for(int i=0;i<=(n);++i)
#define repcn(i,m,n) for(int i=(m);i<=(n);++i)
#define repcd(i,n) for(int i=(n);i>=0;--i)
#define repcnd(i,m,n) for(int i=(n);i>=(m);--i)
#define repc0(i,n) for(i=0;i<=(n);++i)
#define repcn0(i,m,n) for(i=(m);i<=(n);++i)
#define repcd0(i,n) for(i=(n);i>=0;--i)
#define repcnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const double INF = 1e+10;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int n,m,p,a,b,t[10];
vpint road[40];
double mem[40][300];

int main() {
	IL{
		cin>>n>>m>>p>>a>>b;
		if(n==0&&m==0&&p==0&&a==0&&b==0)break;
		--a,--b;
		rep(i,40)rep(j,300)mem[i][j]=INF;
		rep(i,n)cin>>t[i];
		rep(i,m)road[i].clear();
		rep(i,p){
			int x,y,z;
			cin>>x>>y>>z;
			--x,--y;
			road[x].PB(MP(y,z));
			road[y].PB(MP(x,z));
		}
		priority_queue<pair<double,pint>,vector<pair<double,pint> >,greater<pair<double,pint> > > que;
		que.push(MP(0,MP((1<<n)-1,a)));
		while(!que.empty()){
			pair<double,pint> now=que.top();
			que.pop();
			double cost=now.first;
			int bit=now.second.first,pos=now.second.second;
			if(mem[pos][bit]<=cost)continue;
			mem[pos][bit]=cost;
			rep(i,sz(road[pos])){
				rep(j,n){
					if((bit&1<<j)==0)continue;
					que.push(MP(cost+(double)road[pos][i].second/t[j],MP(bit^1<<j,road[pos][i].first)));
				}
			}
		}
//rep(i,m)rep(j,1<<n)cout<<i<<" "<<j<<" "<<mem[i][j]<<endl;
		double res=INF;
		rep(i,1<<n){
			chmin(res,mem[b][i]);
		}
		if(res==INF)cout<<"Impossible"<<endl;
		else printf("%.12lf\n",res);
	}
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<bool> v(a.back() + 1, true);
    for (int e : a) {
        for (size_t i = 2; e * i < v.size(); ++i) {
            v[e * i] = false;
        }
    }
    int answer = 0;
    for (size_t i = 0; i < a.size(); ++i) {
        if (i + 1 < a.size() && a[i + 1] == a[i]) {
            int m = a[i];
            while (i < a.size() && a[i + 1] == m) ++i;
            continue;
        }
        if (v[a[i]]) ++answer;
    }
    cout << answer << endl;
}


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

#define MAX_N (100000)

int main(int argc, char *argv[]) {
  // read inputs
  char S[MAX_N + 1];
  scanf("%s", S);
  const int N = strlen(S);

  // solve
  if (N % 2 == 1) {
    // if second can make ab(ab)*a then second wins
    // otherwise first wins
    if (S[0] != S[N - 1]) {
      printf("First\n");
    } else {
      printf("Second\n");
    }
  } else {
    // if first can make ab(ab)*a then first wins
    // otherwise second wins
    if (S[0] != S[N - 1]) {
      printf("Second\n");
    } else {
      printf("First\n");
    }
  }

  return 0;
}


Measured memory_bytes: 256