akhauriyash/Code-Regression huggingface dataset:
// Java program For handling Input/Output 
import java.io.*;
import java.util.*;
import java.math.*;
//import java.awt.*;

public class Main {
    BufferedReader br;
    StringTokenizer st;

    int max = -1;
    final long P = 998244353;
    final long P2 = 1000000007;

    HashSet<String> set = new HashSet<>();
    HashMap<Character, List<Integer>> map = new HashMap<>();

    // actual logic
    void solve() throws IOException {
        // int t = ni();
        // while (--t >= 0) {
        String s = ns();
        String k = ns();
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != k.charAt(i))
                ans++;
        }
        pl(ans);
        // }

    }

    // constructor
    Main() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                System.out.println(e);
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    Main(String s) {
        try {
            br = new BufferedReader(new FileReader(s));
            st = new StringTokenizer(br.readLine());
        } catch (Exception e) {
            System.out.println(e);
        }
    }

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

    // Utility methods

    String ns() {
        if (!st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                System.out.println(e);
            }
        }
        return st.nextToken();

    }

    int ni() {
        return Integer.parseInt(ns());
    }

    long nl() {
        return Long.parseLong(ns());
    }

    double nd() {
        return Double.parseDouble(ns());
    }

    void pl(String s) {
        System.out.println(s);
    }

    void pl(long s) {
        System.out.println(s);
    }

    void pl(double s) {
        System.out.println(s);
    }
}


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

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

    int max_match = 0;
    int diff = S.size() - T.size() + 1;
    for(int i=0;i<diff;i++){
        int match = 0;
        //cout << T.size() << " " << S.size() << " " << i << endl;
        for(int j=0;j<T.size();j++){
            //cout << S.at(i+j);
            if(S.at(i+j) == T.at(j)){
                match++;
                if(match > max_match){
                    max_match = match;
                }
            }
        }
    }
    cout << T.size() - max_match << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=1e9+7;

int main(){
   int n,m;
   cin>>n>>m;
   if(n%2==1){
       rep(i,m){
           cout<<n--<<" "<<i+2<<endl;
       }
       return 0;
   }

   int d=n/2-1;
   int l=1,r=l+d;
   vector<P>p;
   while(r>l){
       p.emplace_back(l,r);
       l++;
       r--;
   }
   l=d+3,r=n;
   while(m>p.size()){
       p.emplace_back(l,r);
       l++;
       r--;
   }
   rep(i,m)cout<<p[i].first<<" "<<p[i].second<<endl;



    return 0;
}

Measured memory_bytes: 4076
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	vint A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	int B[SIZE]={};
	for(int i=0;i<N;i++){
		B[A[i]]=i;
	}
	int maxi=1,temp=1;
	for(int i=1;i<=N;i++){
		if(B[i+1]>B[i])
			temp++;
		else{
			maxi=max(maxi,temp);
			temp=1;
		}
	}
	cout<<N-maxi<<endl;
	return 0;
}

Measured memory_bytes: 1908
import java.util.Scanner;

/**
 * https://abc044.contest.atcoder.jp/tasks/abc044_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		sc.close();
		
		int[] count = new int[26];
		for(char c:w.toCharArray()){
			count[c-'a']++;
		}
		
		String ans = "Yes";
		for(int c:count){
			if(c%2==1){
				ans = "No";
				break;
			}
		}
		
		System.out.println(ans);

	}

}


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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	int n, y;
	cin >> n >> y;
	y /= 1000;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n-i; j++) {
			for (int k = 0; k <= n-i-j; k++) {
				if (i+j+k == n && 10*i + 5*j + k == y) {cout << i << " " << j << " " << k; return 0;}
			}
		}
	}
	cout << "-1 -1 -1";
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include <math.h> 

using namespace std;

int main(void)
{
	const int SIZE = 100000;
	int s;
	long long int a[SIZE];
	cin >> s;
	a[0] = s;
	int ans = 0;

	for (int i = 1; i < SIZE; i++)
	{
		if (a[i - 1] % 2 == 0)
		{
			a[i] = a[i - 1] / 2;
		}
		else
		{
			a[i] = (3 * a[i - 1]) + 1;
		}
		//cout << a[i];
		for (int j = 0; j < i; j++)
		{
			if (a[i] == a[j])
			{
				ans = i + 1;
				cout << ans;
				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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

fn main() {
    input! {
        n: usize,
        q: usize,
        s: chars,
        lr: [(usize, usize); q],
    }
    let mut acc_ac = vec![0; n];
    for i in 1..n {
        acc_ac[i] = acc_ac[i - 1];
        if s[i - 1] == 'A' && s[i] == 'C' {
            acc_ac[i] += 1;
        }
    }
    for (li, ri) in lr {
        println!("{}", acc_ac[ri - 1] - acc_ac[li - 1]);
    }
}


Measured memory_bytes: 6908
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
// combination c(max);
// mint c(n, k)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    mint ans = 0;
    combination c(3e6);
    for (int j = c1; j <= c2; ++j) {
        ans += (mint(r2 + 1) * c(j + r2 + 1, r2 + 1) - mint(r1) * c(r1 + j, r1)) / mint(j + 1);
    }
    cout << ans << endl;
}

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

namespace AtCoder.Abc
{
    class A_168_Therefore
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
            {
                Console.WriteLine("hon");
            }
            else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
            {
                Console.WriteLine("pon");
            }
            else if (n % 10 == 3)
            {
                Console.WriteLine("bon");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27380
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int sum(int a)
{
    int i;
    int k=1;
    for(i=1;i<=a;i++)
    k*=i;
    return k;

}
int main()
{
    int k,m=0,n=0,t,i,j,p;
    int a[8],b[8],c[10];
    scanf("%d",&k);

    for(i=0;i<k;i++)
        scanf("%d",&a[i]);

    for(i=0;i<k;i++)
        scanf("%d",&b[i]);

    for(j=0;j<9;j++)
        c[j]=j+1;


    for(i=0;i<k-1;i++)
        {
            p=0;
            t=a[i];
            c[t-1]=0;
            for(j=0;j<t;j++)
                if(c[j]>0)
                    p++;
                m+=p*sum(k-i-1);
        }

    for(i=0;i<9;i++)
        c[i]=i+1;


    for(i=0;i<k-1;i++)
        {
            p=0;
            t=b[i];

            c[t-1]=0;
            for(j=0;j<t;j++)
                if(c[j]>0)
                    p++;

              n+=p*sum(k-i-1);
        }
printf("%d",abs(n-m));
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int n,m;cin>>n;
  Fr(i,n){
    if((i*(i+1))/2>=n){m=i;break;}
  }
  iFr(i,m){
    if(n>=i){
      cout<<i<<endl;
      n-=i;
    }
  }
}

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]
res = [min(a)+min(b)]
for x,y,c in xyc:
    res.append(a[x-1]+b[y-1]-c)
print(min(res))

Measured memory_bytes: 42404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 9223372036854775807;
const int MOD = 1000000007;

int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	int n,m;
	std::cin >> n>>m;
	std::vector<int> a(n);
	priority_queue<int> q;
	
	rep(i,n)std::cin >> a[i];
	rep(i,n)q.push(a[i]);
	rep(i,m){
		int n;
		n=q.top();
		q.pop();
		n/=2;
		q.push(n);
	}
	ll ans=0;
	rep(i,n){
		ans+=q.top();
		q.pop();
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <math.h>

int main(){
  int i,j,k,e,min,x,xmin,jmax,kmax;
  
  while(1){
    scanf("%d",&e);
    if(e == 0) break;
    jmax = pow(e,1.0/2.0);
    kmax = pow(e,1.0/3.0);
    min = 10000000;
    for(j=0;j<=jmax+1;j++){
      for(k=0;k<=kmax+1;k++){
	if(e>=j*j+k*k*k){
	  xmin = e-(j*j+k*k*k);
	  if(j+k+xmin<min ){
	    min=j+k+xmin;
	  }
	}
      }
    } 
    printf("%d\n",min);
  }
  return 0;
}

Measured memory_bytes: 664
#include <stdio.h>



int a[200010];
 int ans[200010];
 int main(){
 int n;
 scanf("%d",&n);
 for(int i=2;i<=n;i++)scanf("%d",&a[i]);
 for(int i=2;i<=n;i++)ans[a[i]]++;
 for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
 }


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define MAX 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mt make_tuple
#define eb emplace_back
#define INF 1e9
#define PI 3.141592653589793238
#define EPS 1e-9
ll modexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b&1) res = (res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
int main()
{

	int a,b,c;
	cin>>a>>b>>c;
	cout<<min({a+b,a+c,b+c})<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>

using namespace std;

constexpr int matchCounts[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

// check b 
bool greaterThan(const string& a, const string& b) {
    if (a.size() != b.size()) return a.size() > b.size();
    for (auto i = 0u; i < a.size(); i++) {
        if (a[i] == b[i]) continue;
        return a[i] > b[i];
    }
    return false;
}

string solveImpl(const set<int>& numbers, const int totalCount) {
    vector<string> dp(totalCount + 1, "");
    dp[0] = "0";
    for (auto valueIter = numbers.rbegin(); valueIter != numbers.rend(); valueIter++) {
        const auto value = *valueIter;
        const char valueChar = '0' + value;
        for (auto i = matchCounts[value]; i < static_cast<int>(dp.size()); i++) {
            auto add = dp[i - matchCounts[value]];
            if (add.empty()) {
                continue;
            } else if (add == "0") {
                add[0] = valueChar;
            } else {
                add += valueChar;
            }
            if (greaterThan(add, dp[i])) dp[i] = add;
        }
    }
    return dp.back();
}

string solve(const set<int>& numbers, int total) {
    return solveImpl(numbers, total);
}

int main()
{
    int N, M;
    cin >> N >> M;
    set<int> numbers;
    for (auto i = 0; i < M; i++) {
        int Ai;
        cin >> Ai;
        numbers.insert(Ai);
    }
    cout << solve(numbers, N) << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N, K; cin >> N >> K;
	set<char> D;
	for(int i = 0; i < K; i++) {
		char d; cin >> d;
		D.insert(d);
	}
	int ans = N;
	while(true) {
		string n = to_string(ans);
		bool flag = true;
		for(int i = 0; i < n.size(); i++) {
			if(D.count(n[i])) {
				flag = false;
				break;
			}
		}
		if(flag) {
			cout << ans << endl;
			return 0;
		}
		ans++;
	}
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n , a , b , l , r , len;
void doit(int a , int b , int len , int l , int r) {
    int L = 0 , R = a / len , ans = -1;
    while(L <= R) {
	int mid = (L + R) >> 1 , res = 0;
	res = (b - mid + 1) / (a - mid * len + 1); if((b - mid + 1) % (a - mid * len + 1) != 0) ++ res;
	if(res > len)  R = mid - 1; else L = mid + 1 , ans = mid;
    }
    for(int i = l;i <= min(r , ans * (len + 1) - 1);++ i) {
	if(i % (len + 1) == 0) putchar('B'); else putchar('A');
    }
    if(r < ans * (len + 1)) return;
    l = max(l , ans * (len + 1));
    int rb = b - (ans - 1) , ra = a - ans * len;
    int end = ans * (len + 1);
    if(l == end) {
	++ l; putchar('B'); if(l > r) return;
    }
    ++ end;-- rb;
    int Ra = rb / len + (rb % len != 0) - 1;
    end = end + ra - Ra;
    for(int i = l;i <= min(r , end - 1);++ i) putchar('A');
    l = max(l , end); ra = Ra; if (l> r) return;
    int rem = len - ((ra + 1) * len - rb);
    for(int i = l;i <= r;++ i) if(i < rem + end) putchar('B');else if(i % (len + 1) == (rem + end) % (len + 1)) putchar('A'); else putchar('B');
}

main(void) {
    for(cin >> n;n--;) {
	cin >> a >> b >> l >> r;
	if(a == b) {
	    for(int i = l;i <= r;++ i) if(i & 1) putchar('A'); else putchar('B'); puts("");
	    continue;
	}
	if(!a || !b) {
	    for(int i = l;i <= r;++ i) if(a) putchar('A'); else putchar('B'); puts(""); continue;
	}
	if(a > b) len = (a / (b + 1)) + (a % (b + 1) != 0);else len = b / (a + 1) + (b % (a + 1) != 0);
	doit(a , b , len , l , r);
	puts("");
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int r,g,b;cin>>r>>g>>b;
    int num=r*100+g*10+b;
    if(num%4==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main(void){
    int N;
    int i,s=0;

    scanf("%d",&N);
    i=N;
    while(i>0){
        s += i%10;
        i /=10;
    }
    if(N % s == 0){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

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

int main(){
  long long n;
  long long cnt=0;
  cin >> n;

  for(int i=1;i<=n;i++){
      if((i%3 != 0) && (i%5 != 0)) cnt += i;
  }
  cout << cnt << endl;
}


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

int main(){
	int N;
	string S;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> S;
		if(S=="Y"){
			cout << "Four" <<endl;
			break;
		}
      	if(i==N-1){
          cout<<"Three"<<endl;
        	break;
        }
    }

}



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

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

Measured memory_bytes: 3916
class UnionFind():
 def __init__(self,n):
   self.n=n
   self.root=[-1]*(n+1)
   self.rank=[0]*(n+1)
 def FindRoot(self,x):
   if self.root[x]<0:
     return x
   else:
     self.root[x]=self.FindRoot(self.root[x])
     return self.root[x]
 def Unite(self,x,y):
   x=self.FindRoot(x)
   y=self.FindRoot(y)
   if x==y:
     return
   else:
     if self.rank[x]>self.rank[y]:
       self.root[x]+=self.root[y]
       self.root[y]=x
     elif self.rank[x]<=self.rank[y]:
       self.root[y]+=self.root[x]
       self.root[x]=y
       if self.rank[x]==self.rank[y]:
         self.rank[y]+=1
 def isSameGroup(self,x,y):
   return self.FindRoot(x)==self.FindRoot(y)
 def Count(self,x):
   return -self.root[self.FindRoot(x)]
 
n,m,k=map(int,input().split())
t=UnionFind(n)
cnt=[0]*(n+1) #各iについて、iと同一の連結成分に属する友達関係の人、ブロック関係の人の数を数える
for _ in range(m):
 a,b=map(int,input().split())
 cnt[a]+=1 #各iについて、iと同一の連結成分に属する友達関係の人の数を数える
 cnt[b]+=1
 t.Unite(a,b)
for _ in range(k):
 a,b=map(int,input().split())
 if t.isSameGroup(a,b)==True:
   cnt[a]+=1 #各iについて、iと同一の連結成分に属するブロック関係の人の数を数える
   cnt[b]+=1
ans=[0]*(n+1)
for i in range(1,n+1):
 ans[i]=(t.Count(i)-1)-cnt[i] #答えは(各iが属する連結成分のサイズ)-1-((iと同一の連結成分に含まれているiと友達関係にある人の数)+(iと同一の連結成分に含まれているiとブロック関係にある人の数)となる
print(*ans[1:])

Measured memory_bytes: 11716
import java.util.Scanner;

public class Main {

    public static int findMaxConsecutiveDays(String weatherString){
        int maxDays =0;

        char[] weatherChar = weatherString.toCharArray();
//        for(char character:weatherChar){
//            System.out.println(character);
//        }

        int temporaryCount = 0;
        for(int i =0 ;i<weatherChar.length;i++){
            if(weatherChar[i] == 'R'){
                temporaryCount++;
            }else{
                if(temporaryCount>maxDays) {
                    maxDays = temporaryCount;
                }
                temporaryCount =0;
            }
        }
        if(temporaryCount>maxDays) {
            maxDays = temporaryCount;
        }
        return maxDays;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        System.out.println(findMaxConsecutiveDays(str));
        scanner.close();
    }
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b)-1; i >= (a); i--)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 200200;

int P[MAX];

int ADD[MAX];
int SUB[MAX];

int A[MAX];
int B[MAX];

bool check(int n)
{
	FOR (i, 0, n)
	{
		if (A[i] < 1 || A[i] > 1000000000) return false;
		if (B[i] < 1 || B[i] > 1000000000) return false;
	}

	FOR (i, 1, n)
	{
		if (A[i] <= A[i-1]) return false;
		if (B[i] >= B[i-1]) return false;
	}

	FOR (i, 1, n)
	{
		if (A[P[i]] + B[P[i]] <= A[P[i-1]] + B[P[i-1]]) return false;
	}
	return true;

}

int main()
{
	//freopen("in.txt", "w", stdout);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	//n = 20000;

	FOR (i, 0, n)
	{
		scanf("%d", &P[i]);
		//P[i] = i + 1;
		P[i]--;
	}
/*
	random_shuffle(P, P + n);
	random_shuffle(P, P + n);
	random_shuffle(P, P + n);
	random_shuffle(P, P + n);
	random_shuffle(P, P + n);
	random_shuffle(P, P + n);
	random_shuffle(P, P + n);
	random_shuffle(P, P + n);*/

	FOR (i, 0, n)
	{
		int x = P[i];
		ADD[x] += i;
		SUB[x+1] += i;
	}
	A[0] = ADD[0];
	B[0] = -SUB[0];

	FOR (i, 1, n)
	{
		A[i] = A[i-1] + ADD[i];

		B[i] = B[i-1] - SUB[i];
	}

	FOR (i, 0, n)
	{
		A[i] += i;
		B[i] += n - i;
	}

	int mn1 = INF, mn2 = INF;

	FOR (i, 0, n)
	{
		mn1 = min(mn1, A[i]);
		mn2 = min(mn2, B[i]);
	}

	FOR (i, 0, n)
	{
		A[i] = A[i] - mn1 + 1;
		B[i] = B[i] - mn2 + 1;
	}

	FOR (i, 0, n)
	{
		printf("%d ", A[i]);
	}
	printf("\n");
	FOR (i, 0, n)
	{
		printf("%d ", B[i]);
	}
	printf("\n");

	//cout<<check(n)<<endl;


}




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

int main()
{
    int k;
    cin >> k;
    vector<long long int> v;
    for (int i = 1; i < 10; i++)
    {
        v.push_back(i);
    }

    while (1)
    {
        if (k <= v.size())
        {
            cout << v[k - 1] << endl;
            return 0;
        }
        k -= v.size();
        vector<long long int> old;
        swap(old, v);
        for (long long int x : old)
        {
            for (int i = -1; i <= 1; ++i)
            {
                int d = x % 10 + i;
                if (d < 0 || d > 9) continue;
                long long int nx = x * 10 + d;
                v.push_back(nx);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1712
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    int n, K;
    cin >> n >> K;

    vector<pair<int,int>> P;
    vector<int> X;
    vector<int> Y;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        P.emplace_back(x, y);
        X.emplace_back(x);
        Y.emplace_back(y);
    }

    sort(X.begin(), X.end());
    X.resize(unique(X.begin(), X.end()) - X.begin());
    sort(Y.begin(), Y.end());
    Y.resize(unique(Y.begin(), Y.end()) - Y.begin());

    int h = X.size();
    int w = Y.size();


    auto count = [&](int l, int r, int t, int b) {
        int res = 0;
        for (auto& p : P) {
            int x = p.first, y = p.second;
            if (l <= x && x <= r && t <= y && y <= b) {
                ++res;
            }
        }
        return res;
    };

    auto area = [&](long long l, long long r, long long t, long long b) {
        return (r - l) * (b - t);
    };

    long long res = 1LL << 62;
    for (int l = 0; l < h; ++l) {
        for (int r = l; r < h; ++r) {
            for (int t = 0; t < w; ++t) {
                for (int b = t; b < w; ++b) {
                    int L = X[l], R = X[r], T = Y[t], B = Y[b];
                    if (count(L, R, T, B) >= K) {
                        res = min(res, area(L, R, T, B));
                    }
                }
            }
        }
    }


    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
using namespace std;
int main() {
    string str;
    cin >> str;
    int count = 700;
    if (str[0] == 'o'){
      	count += 100;
    }
    if (str[1] == 'o'){
    	count += 100;
    }
    if (str[2] == 'o'){
    	count += 100;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int a, b; cin >> a >> b;
    print(a * b);

    return 0;
}

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

typedef long long LL;

LL n;

int main(){
//	for(int i=1;i<=20;i++){
//		printf("%d:",i);
//		for(int j=1;j<=i;j++){
//			if(i/j == i%j){
//				printf(" %d",j);
//			}
//		}
//		printf("\n");
//	}
	scanf("%lld",&n);
//	for(n=1;n<=10000;n++){
	LL ans = 0LL;
	for(LL i = 1;i*i<n;i++){
		if(n%i == 0 && (n%(n/i -1) != 0)){
			ans+= n/i-1;
		}
	}
//	LL ans2 = 0LL;
//	for(int i=1;i<=n;i++){
//		if(n/i == n%i){
//			ans2+=i;
//		}
//	}
	printf("%lld\n",ans);
//	if(ans != ans2) system("PAUSE");
//	}
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
ll int N;
double dp[305][305][305];
double fun(ll int a,ll int b,ll int c)
{
    double x,y,z;
    x=0;
    y=0;
    z=0;
    if(a==0&&b==0&&c==0)
    {
        dp[a][b][c]=0;
        return 0;
    }
    if(c>0)
    {
        if(dp[a][b+1][c-1]==-1)
        dp[a][b+1][c-1]=fun(a,b+1,c-1);
        z=dp[a][b+1][c-1];
    }
    if(b>0)
    {
        if(dp[a+1][b-1][c]==-1)
        dp[a+1][b-1][c]=fun(a+1,b-1,c);
        y=dp[a+1][b-1][c];
    }
    if(a>0)
    {
        if(dp[a-1][b][c]==-1)
        dp[a-1][b][c]=fun(a-1,b,c);
        x=dp[a-1][b][c];
    }
    dp[a][b][c]=(((double)N)+(a*x+b*y+c*z))/(c+b+a);
    return dp[a][b][c];
}
int main()
{
    ll int a,b,c,i,j,k,v;
    a=0;
    b=0;
    c=0;
    cin>>N;
    for(i=0;i<N;i++)
    {
        cin>>v;
        if(v==1)
        a+=1;
        if(v==2)
        b+=1;
        if(v==3)
        c+=1;
    }
    for(i=0;i<305;i++)
    {
        for(j=0;j<305;j++)
        {
            for(k=0;k<305;k++)
                dp[i][j][k]=-1;
        }
    }
    double x,y,z;
    if(c>0)
    {
        if(dp[a][b+1][c-1]==-1)
        dp[a][b+1][c-1]=fun(a,b+1,c-1);
        z=dp[a][b+1][c-1];
    }
    if(b>0)
    {
        if(dp[a+1][b-1][c]==-1)
        dp[a+1][b-1][c]=fun(a+1,b-1,c);
        y=dp[a+1][b-1][c];
    }
    if(a>0)
    {
        if(dp[a-1][b][c]==-1)
        dp[a-1][b][c]=fun(a-1,b,c);
        x=dp[a-1][b][c];
    }
    double ans;
    ans=(((double)N)+(a*x+b*y+c*z))/(c+b+a);
    printf("%0.12lf\n",ans);
    return 0;
}


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


def solve(a: int, b: int):
    print(min(str(a) * b, str(b) * a))


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


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long  int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

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

	cin >> N;
	long double ans = 0;
	for (int i = 0; i < N; i++) {
		string s;
		long double a;
		cin >> a >> s;
		if (s[0] == 'J')ans += a;
		else ans += a * 380000;
	}
	cout << setprecision(20) << ans << endl;
	return 0;
}

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

int main(void) {
	int A[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	int N;
	int b[10];
	int appear[3][3];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &b[i]);
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			appear[i][j] = false;
			for (int k = 0; k < N; k++) {
				if (b[k] == A[i][j]) appear[i][j] = true;
			}
		}
	}
	string ans = "No";
	for (int i = 0; i < 3; i++) {
		if (appear[i][0] && appear[i][1] && appear[i][2]) ans = "Yes";
	}
	for (int i = 0; i < 3; i++) {
		if (appear[0][i] && appear[1][i] && appear[2][i]) ans = "Yes";
	}
	if (appear[0][0] && appear[1][1] && appear[2][2]) ans = "Yes";
	if (appear[0][2] && appear[1][1] && appear[2][0]) ans = "Yes";
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3656
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_a



Ms = Array.new(2)
Ds = Array.new(2)
2.times do |i|
  Ms[i], Ds[i] = gets.split.map(&:to_i)
end
if Ms[1]==Ms[0]
  puts 0
else 
  puts 1
end


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[5];

ll dfs(vector<int> v)
{
    if (v.size() == 5)
    {
        ll t = 0;
        REP(i, 4)
        {
            t += A[v[i]];
            t += (10 - t % 10) % 10;
        }
        t += A[v[4]];
        return t;
    }

    ll min = INF;
    REP(i, 5)
    {
        bool e = false;
        REP(j, v.size())
        {
            if (i == v[j])
                e = true;
        }
        if (e)
            continue;
        v.push_back(i);
        min = std::min(min, dfs(v));
        v.pop_back();
    }
    return min;
}

int main()
{
    ll t = 0;
    REP(i, 5)
    {
        cin >> A[i];
    }

    vector<int> v;
    cout << dfs(v) << endl;
    return 0;
}

Measured memory_bytes: 384
import sys, math, re
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, X, M = mi()
    r = [-1]*M

    now = X
    cnt = 0
    while True:
        if r[now] != -1:
            break
            
        r[now] = cnt

        now = (now*now)%M
        cnt += 1
    
    d = [(r[i], i) for i in range(M) if r[i] != -1]
    d.sort()

    s = [v for k, v in d[:r[now]]]
    t = [v for k, v in d[r[now]:]]

    ns = len(s)
    nt = len(t)

    if N < ns:
        print(sum(s[:N]))
        return
    
    print(sum(s) + sum(t) * ((N-ns)//nt) + sum(t[:(N-ns)%nt]))



if __name__ == "__main__":
    main()

Measured memory_bytes: 18124
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

unordered_map<ll, bool> M;
bool l[5][5];
ll s[10];
int h, w, n;

inline bool getv(ll x, ll y)
{
    ll v = (x << 32) | y;
    return M.find(v) != M.end();
}

inline void setv(ll x, ll y)
{
    ll v = (x << 32) | y;
    M[v] = true;
}

inline bool good(int x, int y)
{
    return x >= 0 && y >= 0 && x < h && y < w;
}

int main()
{
    cin >> h >> w >> n;
    s[0] = (ll) (h - 2) * (w - 2);
    for (int k = 0; k < n; ++k)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        setv(a, b);
        memset(l, 0, sizeof l);
        for (int i = a - 2; i <= a + 2; ++i)
            for (int j = b - 2; j <= b + 2; ++j)
                if (good(i, j))
                    l[i - (a - 2)][j - (b - 2)] = getv(i, j);

        for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 3; ++j)
            {
                if (!good(a - 2 + i, b - 2 + j) ||
                    !good(a + i, b + j))
                    continue;

                int cnt = 0;
                for (int p = i; p < i + 3; ++p)
                    for (int q = j; q < j + 3; ++q)
                        cnt += l[p][q];

                s[cnt - 1]--;
                s[cnt]++;
            }
        }
    }
    for (int k = 0; k < 10; ++k)
        cout << s[k] << '\n';
}


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

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rf(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define rb(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int N = 4e3 + 1;
const int INF = 2e9;

int cnt[N][4];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin >> n;
    cin >> s;
    s = '*' + s;
    ll ans = 0;

    rf(i, 1, n) {
        rf(j, 1, 3) cnt[i][j] = cnt[i - 1][j];
        if (s[i] == 'R')
            cnt[i][1]++;
        if (s[i] == 'G')
            cnt[i][2]++;
        if (s[i] == 'B')
            cnt[i][3]++;
    }

    rf(i, 1, n) {
        rf(j, i + 1, n) if (s[i] != s[j]) {

            if (s[i] != 'R' && s[j] != 'R') {

                ans += cnt[n][1] - cnt[j][1];
                if (j + j - i  <= n && s[j + j - i ] == 'R')
                    ans--;
            }

            if (s[i] != 'G' && s[j] != 'G') {
                ans += cnt[n][2] - cnt[j][2];
                if (j + j - i  <= n && s[j + j - i ] == 'G')
                    ans--;
            }
            if (s[i] != 'B' && s[j] != 'B') {
                ans += cnt[n][3] - cnt[j][3];
                if (j + j - i  <= n && s[j + j - i ] == 'B')
                    ans--;
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3692
n, k = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("")
case s[k-1]
when "A"
    s[k-1] = "a"
when "B"
    s[k-1] = "b"
else
    s[k-1] = "c"
end

puts s.join("")

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<int, lli> il;

int main() {
    int N, M;
    cin >> N >> M;

    int sM = sqrt(M);
    vector<int> list;
    for (int i = 1; i <= sM; i++) {
        if (M % i == 0) {
            list.push_back(i);
            if (M/i != i) {
                list.push_back(M/i);
            }
        }
    }
    sort(list.begin(), list.end(),
        [](const int &a, const int &b) {
            return a > b;
        });
    
    for (vector<int>::iterator it = list.begin(); it != list.end(); ++it) {
        int m = *it;
        if (M / m >= N) {
            cout << m << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
n, *L = map(int, open(0).read().split())
P = [complex(x, y) for x, y in zip(*[iter(L)] * 2)]

def CH(P: list):
	def cross(z1,z2):
		return z1.real*z2.imag-z1.imag*z2.real
	P.sort(key=lambda z:(z.imag,z.real))
	hull=[]
	cur,pre=0,1
	for Q in (P,P[len(P)-2::-1]):
		for z in Q:
			while cur>pre and cross(hull[-2]-hull[-1],z-hull[-1])>0:
				hull.pop()
				cur-=1
			hull.append(z)
			cur+=1
		pre=len(hull)
	return hull[:-1]

ret=CH(P)
print(len(ret))
for z in ret:
	print(int(z.real),int(z.imag))


Measured memory_bytes: 30036
A= int(input())
B= int(input())
C= int(input())
D= int(input())
E= int(input())

l = [A,B,C,D,E]

r = list(map(lambda x:x % 10,l))
r = [x if x != 0 else 10 for x in r]

index = r.index(min(r))


ans = 0

for i in range(5):
	if i == index:
		ans += l[i]
	else:
		if l[i] % 10 == 0:
			ans += l[i]
		else:
			ans += (l[i]//10 + 1) * 10

print(ans)


Measured memory_bytes: 3064
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
count = 0
for i in range(n):
    a=list(map(int,input().split()))
    dot = 0
    for al,bl in zip(a,b):
        dot += al*bl
    count += (dot+c)>0
print(count)
        

Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        // educational dp 2

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] list = new int[n];
        for (int i = 0; i < n; i++) {
            list[i] = sc.nextInt();
        }
        long[] dp = new long[n];
        Arrays.fill(dp, -1);
        dp[0] = 0;

        for (int i = 0; i < n - 1; i++) {
            int limit = Math.min(i + k + 1, n);
            for (int j = i + 1; j < limit; j++) {
                long cost = Math.abs(list[i] - list[j]) + dp[i];
                if (dp[j] == -1) {
                    dp[j] = cost;
                } else {
                    dp[j] = Math.min(dp[j], cost);
                }
            }
        }
        System.out.println(dp[n - 1]);
    }
}

Measured memory_bytes: 52748
import sys
input = sys.stdin.readline

def main():

    N, M = map(int, input().split())
    Set = [list(map(int,input().split())) for i in range(M)]

    for i in range(10**N):
        num = str(i)
        if len(num) == N and all(num[s-1]==str(c) for s,c in Set):
            print(i)
            break
    else:
        print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
List = []
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))

L = [x % 10 if x % 10 != 0 else 10 for x in List]
last_item = L.index(min(L))

# Find the next multiple of 10 for each value, except the last item
for i in range(len(List)):
    if (List[i] % 10) and i != last_item:
        List[i] = List[i] + (10 - List[i] % 10)

print(sum(List))

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

using namespace std;
typedef long long ll;
const int N = 2000;
int _w;

int n, a[N], sum;
bitset<4000001> s;

int main() {
	cin >> n;
	for( int i = 0; i < n; ++i ) {
		cin >> a[i];
		sum += a[i];
	}
	sum = (sum + 1)/2;
	s[0] = 1;
	for( int i = 0; i < n; ++i )
		s |= s << a[i];
	for( int i = sum; ; ++i )
		if( s[i] ) {
			cout << i << endl;
			break;
		}
	return 0;
}


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

using namespace std;

int main(){

	int x, y, ans=0;

	cin>> x >> y;

	if (x == 3) ans += 100000;
	if (y == 3) ans += 100000;
	if (x == 2) ans += 200000;
	if (y == 2) ans += 200000;
	if (x == 1) ans += 300000;
	if (y == 1) ans += 300000;
	if (x == 1 && y == 1) ans += 400000;

	cout<< ans << endl;

}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int n, s[100][100];
  while(scanf("%d", &n) && n){
    rep(i, n) rep(j, n) scanf("%d", &s[i][j]);
    int smax[100];
    memset(smax, 1, sizeof(smax));

    rep(i, n){
      int tmax = 0;
      rep(j, n) tmax = max(tmax, s[j][i]);
      smax[i] = tmax;
    }

    int i, j, k;
    for(i = 0; i < n; i++){
      int tmin = INF;
      for(j = 0; j < n; j++) tmin = min(tmin, s[i][j]);
      for(j = 0; j < n; j++) if(tmin == smax[j]){ printf("%d\n", smax[j]); i = INF; break;}
    }
    if(i == n) puts("0");
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
// #define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define PRIME           1000000007
#define MAX         50000
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define pi          3.14159265358979323
int i,j,k;
int power(int x,int y){
    if(y==0)return 1;
    if(y==1)return x;
    if(y&1)return (((power(x,y/2)*power(x,y/2))%PRIME)*x)%PRIME;
    else return (power(x,y/2)*power(x,y/2))%PRIME;
}
const bool cmp(pair<int,char> &a,pair<int,char> &b){
    return a.F>b.F;
}
 
void Anon_mouS(){
    int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;
}
 
int32_t main(){
    fastio;
    int q=1;
    // cin>>q;
    // SieveOfEratosthenes();
    while(q--){
        Anon_mouS();
    }
    return 0;   
}

Measured memory_bytes: 3656