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

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using usize = std::size_t;
using namespace std;

#define rep(i, max) for(i32 i = 0; i < (i32)max; ++i)
#define loop while(true)
#define allOf(collection) collection.begin(), collection.end()

unique_ptr<string> readLine() { unique_ptr<string> line(new string()); getline(cin, *line); return line; }
template<typename T1, typename T2> pair<T1, T2> readPair() { T1 res1; cin >> res1; T2 res2; cin >> res2; readLine(); return make_pair(res1, res2);}
template<typename T> unique_ptr<vector<T>> readVector(usize num, bool isForIndex = false) { unique_ptr<vector<T>> list(new vector<T>(num)); rep(i, num) { cin >> (*list)[i]; if(isForIndex) --(*list)[i]; } readLine(); return list; }
void readValues() { readLine(); }
template<typename H, typename... T> void readValues(H& head, T&&... tails){ H a; cin >> a; head = a; readValues(forward<T>(tails)...); }
void writeLine() { cout << endl; }
template<typename T> void write(const T& arg) { cout << arg; }
template<typename T> void writeLine(const vector<T>& arg){ if(arg.empty()) { writeLine(); return; } write(arg[0]); for(int i = 1; i < arg.size(); ++i){ write(" "); write(arg[i]); } writeLine(); }
template<typename T> void writeLine(const T& arg) { cout << arg << endl; }
void recursiveCombination(vector<i32>& indexes, i32 s, i32 rest, function<void(vector<i32>&)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursiveCombination(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursiveCombination(indexes, s - 1, rest - 1, f); } }
void foreachWithCombination(i32 n, i32 k, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(k); recursiveCombination(indexes, n - 1, k, f); }
void foreachWithPermutaton(i32 n, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(); indexes.reserve(n); rep(i, (usize)n) indexes.push_back(i); do f(indexes); while (next_permutation(allOf(indexes))); }
void foreachWithPermutaton(i32 n, i32 k, function<void(vector<i32>&)> f){ foreachWithCombination(n, k, [=](vector<i32>& combIndexes){ foreachWithPermutaton(k, [=](vector<i32>& permIndexes){ auto indexes = vector<i32>(); indexes.reserve(k); rep(i, (usize)k){ indexes.push_back(combIndexes[permIndexes[i]]); } f(indexes); }); }); }
void program();
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    program();
    cin.get();
}

void program() {
    i64 a, b, c, d;
    readValues(a, b, c, d);
    i64 res = INT64_MIN;
    res = max(res, a * c);
    res = max(res, a * d);
    res = max(res, b * c);
    res = max(res, b * d);
    writeLine(res);
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;

ll N, M, A[100000 + 100];
ll csum[100000 + 1000];

//f(x) := x以上となる握手を全部やって、(何回の握手, その時の幸せ度)になるか
pair<ll, ll> f(ll x) {
	ll sum = 0;
	ll happiness = 0;
	for (int i = 0; i < N; i++) {
		int pos = (lower_bound(A, A + N, x - A[i] - 1, greater<ll>()) - A);
		sum += (lower_bound(A, A + N, x - A[i] - 1, greater<ll>()) - A);
		happiness += (csum[pos] + A[i] * pos);
	}
	return make_pair(sum, happiness);
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++)cin >> A[i];

	sort(A, A + N, greater<ll>());
	csum[0] = 0;
	for (int i = 0; i < N; i++)csum[i + 1] = csum[i] + A[i];

	ll l = 0, u = 100000000000;
	while (u - l > 1) {
		ll mid = (l + u) / 2;
		if (f(mid).first < M)u = mid;
		else l = mid;
	}
	cout << f(l).second - (f(l).first - M) * l << endl;
	return 0;
}

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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long int lli;

int main()
{
	fio;
	int d,n;
	cin>>d>>n;
	if(n==100) n=101;
	if(d==0) cout<<n<<endl;
	else if(d==1) cout<<to_string(n)+"00"<<endl;
	else if(d==2) cout<<to_string(n)+"0000"<<endl;
	cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 256
/**
 *
 * AtCoder Regular Contest 098 - Problem C: Attention
 *
 * N people stand in a row, facing west or east. If j is the leader, the others must be looking
 * up to the leader. Find the minimum of changes needed.
 *
 * Brute force solution: precompute (prefix sum) the number of people looking to the east or the 
 * west up to k and try all possible leaders. The number of changes for leader k is
 *
 *      changes = looking_west[k - 1] + (looking_east[N] - looking_east[k])
 *
 */
#include <iostream>

using namespace std;

const int MAX { 400010 };

int west[MAX], east[MAX];

int main()
{
    ios::sync_with_stdio(false);

    int N;
    string S;
    cin >> N >> S;

    for (int k = 1; k <= N; ++k)
    {
        west[k] = west[k - 1] + (S[k - 1] == 'W' ? 1 : 0);
        east[k] = east[k - 1] + (S[k - 1] == 'E' ? 1 : 0);
    }

    // Worst case: all but the leader must change
    int min_changes = N - 1;

    // k is the leader
    for (int k = 1; k <= N; ++k)
        min_changes = min(min_changes, west[k - 1] + east[N] - east[k]);

    cout << min_changes << endl;
 
    return 0;
}


Measured memory_bytes: 3092
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using System;

public static class Permi
{
    public static IEnumerable<IEnumerable<T>> Perm<T>(this IEnumerable<T> items, int? k = null)
    {
        if (k == null) k = items.Count();
        if (k == 0) yield return Enumerable.Empty<T>();
        else
        {
            var i = 0;
            foreach (var x in items)
            {
                var xs = items.Where((_, index) => i != index);
                foreach (var c in Perm(xs, k - 1))
                    yield return c.Before(x);
                i++;
            }
        }
    }
    public static IEnumerable<T> Before<T>(this IEnumerable<T> items, T first)
    {
        yield return first;
        foreach (var i in items) yield return i;
    }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var p = Console.ReadLine().Trim().Replace(" ", "");
        var q = Console.ReadLine().Trim().Replace(" ", "");
        getAns(n, p, q);
    }
    static void getAns(int n, string p, string q)
    {
        var alist = new List<string>();
        var a = Enumerable.Range(1, n).Perm();
        foreach (var x in a)
        {
            var t = "";
            foreach (var y in x) t += y.ToString();
            alist.Add(t);
        }
        alist.Sort();
        Console.WriteLine(Abs(alist.FindIndex(x => x == p) - alist.FindIndex(x => x == q)));
    }
}


Measured memory_bytes: 20740
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    a, b, h, m = LI()
    mdeg = 6 * m
    hdeg = 30 * h + (m / 60) * 30
    if hdeg > mdeg:
        diff = hdeg - mdeg
    else:
        diff = mdeg - hdeg
    diff = min(diff, 360 - diff)
    rad = diff * math.pi / 180
    c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(rad))
    print(c)


main()



Measured memory_bytes: 11012
#include<iostream>

using namespace std;

int main(){
  long W,a,b,ans; cin >> W >> a >> b;

    if(a<b)
      ans =  b - (a+W);
    else
      ans =  a - (b+W);

    if(ans < 0)
      cout << 0 << endl;
    else
      cout << ans << endl;
}


Measured memory_bytes: 256
# ABC134b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, d = map(int, input().split())
if(n % (d * 2 + 1) != 0):
    print(n // (d * 2 + 1) + 1)
    exit()
print(n // (d * 2 + 1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int N,P; cin>>N>>P;
    string S; cin>>S;
    int ans = 0;
    if(P==2){
        REP(i,N){
            if((S[i]-'0')%2==0){
                ans += i+1;
            }
        }
    }
    else if(P==5){
        REP(i,N){
            if(S[i]=='5'||S[i]=='0'){
                ans += i+1;
            }
        }
    }
    else{
    vec count(P,0);
    int t = 0; count[t]++;
    int p = 1;
    IREP(i,N){
        t += p*(S[i]-'0');
        t %= P;
        p *= 10;
        p %= P;
        ans += count[t];
        count[t] ++;  
    }  
    }
    Out(ans);
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=105;
ll F[N][5],k;
string str;
vector <ll> B;
ll solve(ll pos,ll num,bool check)
{
    if(pos < 0) return num==k;
    if(check==true && F[pos][num] > -1) return F[pos][num];
    ll dem=0;
    for(int i=0;i<=max(check*9ll,B[pos]);i++)
    {
        if(i==0) dem+=solve(pos-1,num,check || (i < B[pos]));
        else
        {
            if(num==k) break;
            dem+=solve(pos-1,num+1,check || (i < B[pos]));
        }
    }
    if(check) F[pos][num]=dem;
    return dem;
}
ll calc(string str)
{
    while(str.size() > 0)
    {
        B.push_back(str[str.size()-1]-48);
        str.erase(str.size()-1,1);
    }
    return solve(B.size()-1,0,false);
}
int main()
{
    memset(F,-1,sizeof(F));
    cin>>str;
    cin>>k;
    cout<<calc(str);
    return 0;
}


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

using namespace std;

int X[5];

int main() {
	int a[6];
  for(int i = 0; i < 6; i++) scanf("%d", &a[i]), X[a[i]]++;
  for(int i = 1; i <= 4; i++) if(X[i] == 3) return puts("NO"), 0;
  return puts("YES"), 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<string>s(n);
    rep(0,i,n)cin>>s[i];
    sort(s.begin(),s.end());
    string fs="";
    ll ans=0;
    rep(0,i,n){
        if(fs==""){
            fs=s[i];
            ++ans;
        }else{
            if(fs!=s[i]){
                fs=s[i];
                ++ans;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9604
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
a = LI()
ans = float('inf')
sums = [a[0]]
for i in range(1, n):
    sums.append(sums[-1] + a[i])

for i in range(n - 1):
    x = sums[i]
    y = sums[-1] - sums[i]
    # print(f'{x=}, {y=}')
    ans = min(ans, abs(x - y))
print(ans)


Measured memory_bytes: 30724
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
ll h[100005];
int main() {
	int n;
	bool pd=true;
	ll cnt=0;
	cin>>n;
	FOR(i,0,n) cin>>h[i];
	FOR(i,0,n-1) {
		cnt=max(h[i],cnt);
		if(cnt-1>h[i+1]) pd=false;
	}
	if(pd)cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

int main()
{
    map<string, int> dict; 
    

    int n,t; 
    cin >> n; 
    int max=0;
    for (string x; n--; dict[x]++) 
    {   
        cin >> x;
       if(max<dict[x]+1)
       {
         max=dict[x]+1;
       }
      
    }
   auto begin = dict.begin(), end = dict.end();
    for (auto iter = begin; iter != end; iter++) {
       if(iter->second==max)
       {
         cout <<iter->first<<endl;
       }
    }
 
  
}
   
  
  
    


Measured memory_bytes: 25216
def ext_gcd(a, b):
    def _ext_gcd(a, b):
        xs = [1, 0]
        ys = [0, 1]
        sign = 1
        while b != 0:
            q, r = a//b, a%b
            a, b = b, r
            xtmp, ytmp = xs[1], ys[1]
            xs[1], ys[1] = q*xs[1]+xs[0], q*ys[1]+ys[0]
            xs[0], ys[0] = xtmp, ytmp
            sign = -sign
        return (a, (sign*xs[0], -sign*ys[0]))
    if a < b:
        d, (y, x) = _ext_gcd(b, a)
        return (d, (x, y))
    return _ext_gcd(a, b) 

if __name__ == "__main__":
    X, Y = map(int,input().split())
    if (2*Y-X) % 3 != 0 or (2*X-Y) % 3 != 0:
        print(0)
        exit(0)
    a, b = (2*Y-X)//3, (2*X-Y)//3
    if a < 0 or b < 0:
        print(0)
        exit(0)
    n = 1
    k = 1
    l = 1
    mod = 10**9+7
    for i in range(2, a+b+1):
        n = (n*i) % mod
        if i <= a:
            k = (k*i) % mod
        if i <= b:
            l = (l*i) % mod
    _, (k, _) = ext_gcd(k, mod)
    _, (l, _) = ext_gcd(l, mod)
    print(n*k*l % mod)

Measured memory_bytes: 9320
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  VI A(3);
  rep(i,3) cin>>A[i];
  sort(all(A));
  if(A[0]!=A[2]&&(A[0]==A[1]||A[1]==A[2])) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        String[][] table = new String[x + 2][y + 2];
        for (String[] t : table) {
            Arrays.fill(t, "#");
        }
        for (int i = 1; i <= x; i++) {
            String str = sc.next();
            for (int j = 1; j <= y; j++) {
                table[i][j] = String.valueOf(str.charAt(j - 1));
            }
        }
        
        int[][] dp = new int[x + 2][y + 2];
        for (int[] d : dp) {
            Arrays.fill(d, 1);
        }
        for (int i = 1; i <= x; i++) {
            for (int j = 1; j <= y; j++) {
                if (i == 1 && j == 1) continue;
                if (table[i][j].equals("#")) continue;
                
                boolean upToDown = table[i - 1][j].equals(".");
                boolean leftToRight = table[i][j - 1].equals(".");
                
                if (upToDown && leftToRight) {
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
                } else if (upToDown) {
                    dp[i][j] = dp[i - 1][j];
                } else if (leftToRight) {
                    dp[i][j] = dp[i][j - 1];
                } else {
                    table[i][j] = "#";
                }
                
                if (i == x && j == y) {
                    if (!upToDown && !leftToRight) {
                        dp[i][j] = 0;
                    }
                }
            }
        }
        
        System.out.println(dp[x][y]);
    }
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int p[n],sum=0;
    for(int i=0;i<n;i++)
    cin>>p[i];
    sort(p,p+n);
    for(int i=0;i<k;i++)
    sum+=p[i];
    cout<<sum;
}


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

using namespace std;

int main(void){
  vector<long long> v(3);
  int p = 1;
  for(int i = 0; i < 3; i++){
    cin >> v[i];
    p *= v[i];
  }
  if(p % 2 == 0) cout << 0 << endl;
  else{
    sort(v.begin(), v.end());
    cout << v[0] * v[1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int x,y,i,kin;
  scanf("%d%d",&x,&y);
  i = x%y;
  while(i != 0){
    x = y;
    y = i;
    i = x%y;
  }
  printf("%d\n",y);
  return 0;
}


Measured memory_bytes: 2100
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			if (n == 0) break;
			int[] s = new int[n];
			double m = 0;
			double a = 0;
			for (int i = 0; i < n; i++) {
				s[i] = scan.nextInt();
				m += s[i];
			}
			m = m/n;
			for (int i = 0; i < n; i++) {
				a += (s[i] - m) * (s[i] - m);
			}
			System.out.println(Math.sqrt(a/n));
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 31448
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int a=n%10;
  if(a==3)cout << "bon" << endl;
  else if (a==0||a==1||a==6||a==8)cout << "pon" << endl;
  else cout << "hon" << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int a,b,n,m,o;
    scanf("%d %d",&a,&b);
    n=a+b;
    m=a-b;
    o=a*b;
    if(n>=m&&n>=o)
    {
        printf("%d\n",n);
    }
    else if(m>=n&&m>=o)
    {
        printf("%d\n",m);
    }
    else{
        printf("%d\n",o);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=200050;
int n,m;
bool abli[MAXN][2];
int main()
{
    int u,v;
    memset(abli,false,sizeof(abli));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&u,&v);
        if(u==1) abli[v][0]=true;
        if(v==1) abli[u][0]=true;
        if(u==n) abli[v][1]=true;
        if(v==n) abli[u][1]=true;
    }
    bool did=false;
    for(int i=1;i<=n;i++) 
        if(abli[i][0]&&abli[i][1])
        {
            did=true;
            break;
        }
    if(did) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
    return 0;
}

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

int main() {
  int n,ans=1;
  cin>>n;
  vector<int> h(n);
  for(int i=0; i<n; i++) cin>>h[i];
  int lim=h[0];
  for(int i=1; i<n; i++){
    if(lim<=h[i]){
      ans++;
      lim=h[i];
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MOD 1000000007ll
using namespace std;
int n;
struct matrix{
    long long v[55][55];
    matrix operator*(const matrix& rhs) const {
        matrix tmp;
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                tmp.v[i][j]=0;
                for(int k=0; k<n; k++) {
                    tmp.v[i][j]+=v[i][k]*rhs.v[k][j];
                    tmp.v[i][j]%=MOD;
                }
            }
        }
        return tmp;
    }
};
long long k;
matrix orig,kk;
matrix power(long long x) {
    if(x==1) return orig;
    matrix tmp2;
    tmp2=power(x/2);
    if(x%2==0) return tmp2*tmp2;
    else return tmp2*tmp2*orig;
}
int main() {
    scanf("%d%lld",&n,&k);
    for(int i=0; i<n; i++) {
    	for(int j=0; j<n; j++) {
    		scanf("%lld",&orig.v[j][i]);
		}
	}
	kk = power(k);
	long long ans=0;
	for(int i=0; i<n; i++) for(int j=0; j<n; j++) {
		ans+=kk.v[i][j];
		ans%=MOD;
		if(ans<0) ans+=MOD;
	}
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2944
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let X = cin.getIntArray(3);
    const div2 = (a) => Math.floor(a / 2);
    let ans = 0;
    while (!X.every(v=>v==X[2])) {
        X.sort((a, b) => a - b);
        let bc = X[2] - X[1];
        if (bc > 0) {
            X[0] += bc;
            X[1] += bc;
            ans += bc;
        }
        let ac = X[2] - X[0];
        if (ac > 0) {
            let a = Math.ceil(ac / 2);
            X[0] += a * 2;
            ans += a;
        }
    }
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

// boku no template meisou now 

// clang-format off
// #define fs first
// #define sc second
// #define pb emplace_back
// #define mp make_pair
// #define all(v) v.begin(), v.end()
// #define rall(v) v.rbegin(), v.rend()

// #define rep(i, n) for (int i = 0; i < (int)(n); ++(i))
// #define reps(i, n) for (int i = 1; i <= (int)(n); ++(i))
// #define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --(i))
// #define rreps(i, n) for (int i = (int)(n); i > 0; --(i))

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

inline void br(ostream &os = cerr) { os << endl; }

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
  string s = input<string>();

	int ans = 0;
	range(i, 1, s.size()) {
		if (s[i - 1] != s[i]) ans++;
	}

	cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}



Measured memory_bytes: 512
#include <iostream>

using namespace std;
#define NIL -1;

struct Node{int parent, left, right;};
Node T[10000];
int D[10000];
int H[10000];



void setDepth(int u, int d){
    if(u==-1) return;
    D[u]=d;
    setDepth(T[u].right,d+1);
    setDepth(T[u].left,d+1);
}

int setHeight(int u){
    int h1,h2; h1=h2=0;
    if(T[u].right!=-1) h1=setHeight(T[u].right)+1;
    if(T[u].left!=-1) h2=setHeight(T[u].left)+1;

    return H[u] = max(h1,h2);

}

int getSibling(int u){
    if(T[u].parent==-1) return -1;
    if(T[T[u].parent].left!=u and T[T[u].parent].left!=-1) return  T[T[u].parent].left;
    if(T[T[u].parent].right!=u and T[T[u].parent].right!=-1) return  T[T[u].parent].right;
    return -1;

}

void print(int u){
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].parent<<", ";
    cout<<"sibling = "<<getSibling(u)<<", ";
    int deg=0;
    if(T[u].left!=-1) deg++;
    if(T[u].right!=-1) deg++;
    cout<<"degree = "<<deg<<", ";
    cout<<"depth = "<<D[u]<<", ";
    cout<<"height = "<<H[u]<<", ";

    if(T[u].parent==-1)cout<<"root";
    else if(T[u].left==-1 and T[u].right==-1)cout<<"leaf";
    else cout<<"internal node";
    cout<<endl;


}





void print_preorder(int r){
    if(r==-1) return;
    cout<<" "<<r;
    print_preorder(T[r].left);
    print_preorder(T[r].right);
}

void print_inorder(int r){
    if(r==-1) return;
    print_inorder(T[r].left);
    cout<<" "<<r;
    print_inorder(T[r].right);
}

void print_postorder(int r){
    if(r==-1) return;
    print_postorder(T[r].left);
    print_postorder(T[r].right);
    cout<<" "<<r;
}

int main()
{
    int n,i,l,r,v;
    cin>>n;
    for(i=0;i<n;i++)T[i].parent=T[i].left=T[i].right=-1;
    for(i=0;i<n;i++){
        cin>>v;
        cin>>l>>r;
        if (l!=-1){
            T[v].left=l;
            T[l].parent=v;
        }
        if (r!=-1){
            T[v].right=r;
            T[r].parent=v;
        }
    }

    for(i=0;i<n;i++){
        if(T[i].parent==-1) r=i;
    }
    setDepth(r,0);
    setHeight(r);

    cout<<"Preorder"<<endl;
    print_preorder(r); cout<<endl;
    cout<<"Inorder"<<endl;
    print_inorder(r); cout<<endl;
    cout<<"Postorder"<<endl;
    print_postorder(r); cout<<endl;
//    for(i=0;i<n;i++)print(i);

    return 0;
}


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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VC vector<char>
#define FOREACH(x,a) for(auto& (x) : (a) )
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n == 1 || n == 2 || n == 3) {
		cout << 1 << endl;
		return 0;
	}
	VI v;
	for (int i = 40; i >2; i--) {
		for (int j = 2; pow(i, j) <= 1000; j++) {
			if (pow(i,j)<=n) {
				v.push_back(pow(i, j));

			}
		}
	}
	sort(ALL(v));
	reverse(ALL(v));
	cout << v[0] << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main() {
	pair<pair<string, int>, int> p[110];
	int N;
	cin >> N;

	string S;
	int P;
	
	for (int i = 0; i < N; i++)
	{
		cin >> S;
		cin >> P;
		p[i] = make_pair(make_pair(S, -P), i);
	}
	sort(p, p + N);
	for (int i = 0; i < N; i++)
	{
		cout << p[i].second + 1 << endl;
	}
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

int main()
{
	int x, y; cin >> x >> y;
	cout << x * y - x - y + 1 << endl;
}


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

int main()
{ 
    while(true){
    
    string n;
    cin>>n;
    if(n=="-"){break;}
    else{
    int x;
    cin>>x;
    for(int i=0;i<x;i++){
        int s;
        cin>>s;
        s-=1;
        n=n.substr(s+1,n.size()-s)+n.substr(0,s+1);
        
    }
cout<<n<<endl;
}
}
    return 0;
}


Measured memory_bytes: 3176
"""
def g(X, Y):
    s = set()
    for i in range(1,X/2):
        s.add(g(X-2*i,Y+i))
    for i in range(1,Y/2):
        s.add(g(X+i, Y-2*i))
    for i in range(100):
        if i not in s:
            return i

for X in range(16):
    for Y in range(16):
        print g(X,Y),
    print

0 0 0 0 1 1 2 2 3 3 4 4 5 5 6 6
0 0 0 0 1 1 2 2 3 3 4 4 5 5 6 6
0 0 0 0 1 1 2 2 3 3 4 4 5 5 6 6
0 0 0 0 0 1 2 2 3 3 3 4 4 5 5 6
1 1 1 0 0 0 1 1 4 3 5 4 6 4 5 5
1 1 1 1 0 0 0 1 2 2 2 5 6 6 7 5
2 2 2 2 1 0 0 0 1 1 2 4 3 7 6 8
2 2 2 2 1 1 0 0 0 1 2 3 3 3 3 4
3 3 3 3 4 2 1 0 0 0 1 1 2 2 5 4
"""

X,Y = map(int, raw_input().split())
print "Brown" if X<4 and Y<4 or abs(X-Y)<=1 else "Alice"


Measured memory_bytes: 2568
def resolve():
    n,k,q = map(int, input().split())
    a = [int(input()) for i in range(q)]
    point = [0]*n
    for i in range(q):
        point[a[i]-1] += 1
    for j in range(n):
        if k-q+point[j] > 0:
            print("Yes")
        else:
            print("No")
resolve()

Measured memory_bytes: 8704
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 2e5 + 5;
struct DSU{
    int lab[maxn];
    DSU(){
        fill_n(lab,maxn,-1);
    }
    int FindLab(int u){return lab[u] < 0 ? u : lab[u] = FindLab(lab[u]);}
    void Connect(int u , int v){
        u = FindLab(u);v = FindLab(v);
        if(u == v)return;
        if(lab[u] > lab[v])swap(u , v);
        lab[u] += lab[v];
        lab[v] = u;
    }
}g[2];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    int n , k , l;cin >> n >> k >> l;
    map<ii,int> mmap;
    for(int i = 1 ; i <= k ; ++i){
        int u , v;cin >> u >> v;
        g[0].Connect(u , v);
    }
    for(int i = 1 ; i <= l ; ++i){
        int u , v;cin >> u >> v;
        g[1].Connect(u , v);
    }
    for(int i = 1 ; i <= n ; ++i)mmap[mp(g[0].FindLab(i) , g[1].FindLab(i))]++;
    for(int i = 1 ; i <= n ; ++i)cout << mmap[mp(g[0].FindLab(i) , g[1].FindLab(i))] << " ";
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
#define N 4005
#define X 2001
#define M 200000


struct node {
    node *L,*R;
    int l,r, val[2];
};
node nodePool[M];
node *newNode() {
    static int pos = 0;
    nodePool[pos].L = nodePool[pos].R = NULL;
    nodePool[pos].val[0] = nodePool[pos].val[1] = 0;
    return &nodePool[pos++];
}
void init(node *root,int l,int r) {
    root->l = l;
    root->r = r;
    if(l==r) {
        return;
    }
    int mid = (l+r)/2;
    node *ln = newNode();
    init(ln,l,mid);
    node *rn = newNode();
    init(rn,mid+1,r);
    root->L = ln;root->R = rn;
}
void update(node *prev,node *cur,int l,int r,int ind,int bit) {
    cur->l = l;
    cur->r = r;
    if(l==r) {
        cur->val[0] = prev->val[0];
        cur->val[1] = prev->val[1];
        ++cur->val[bit];
        return;
    }
    int mid = (l+r)/2;
    if(ind<=mid) {
        cur->R = prev->R;
        node *ln = newNode();
        update(prev->L,ln,l,mid,ind,bit);
        cur->L = ln;
    } else {
        cur->L = prev->L;
        node *rn = newNode();
        update(prev->R,rn,mid+1,r,ind,bit);
        cur->R = rn;
    }
    cur->val[0] = cur->L->val[0] + cur->R->val[0];
    cur->val[1] = cur->L->val[1] + cur->R->val[1];
}
int query(node *root,int l,int r,int ql,int qr,int bit) {
    if(r<ql || qr<l) {
        return 0;
    }
    if(ql<=l && r<=qr) {
        return root->val[bit];
    }
    int mid = (l+r)/2;
    return query(root->L,l,mid,ql,qr,bit) + query(root->R,mid+1,r,ql,qr,bit);
}

node *seg[N];
int a[N],color[N];
int mindex[2][N],dp[X][X];

int solveDp(int l,int r,int n) {
    if(l==n && r==n) {
        return 0;
    }
    int &ret = dp[l][r];
    if(ret!=-1) {
        return ret;
    }
    ret = 1000000000;
    if(l<n) {
        int curIndex = mindex[0][l];int val = l+1;
        int cost = 0;
        if(val+1<=n) {
            cost += query(seg[curIndex],1,n,val+1,n,0);
        }
        if(r<n) {
            cost += query(seg[curIndex],1,n,r+1,n,1);
        }
        ret = min(ret, cost + solveDp(l+1,r,n));
    }
    if(r<n) {
        int curIndex = mindex[1][r];
        int val = r+1;
        int cost = 0;
        if(val+1<=n) {
            cost += query(seg[curIndex],1,n,val+1,n,1);
        }
        if(l<n ) {
            cost += query(seg[curIndex],1,n, l+1,n,0);
        }
        ret = min(ret, cost + solveDp(l,r+1,n));
    }
    return ret;
}
void solve() {
    int n;
    scanf("%d",&n);
    seg[0] = newNode();
    init(seg[0],1,n);
    int pos[2] = {0,0};
    for(int i=1;i<=n*2;++i) {
        char c;scanf(" %c %d ",&c,&a[i]);
        if(c=='B') {
            color[i] = 0;
        } else {
            color[i] = 1;
        }
        mindex[color[i]][a[i]-1] = i;
        seg[i] = newNode();
        update(seg[i-1],seg[i],1,n,a[i],color[i]);
    }
    memset(dp,-1,sizeof(dp));
    printf("%d\n",solveDp(0,0,n));
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 18944
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static long[] kaijo;
	 static long[] kaiinv;
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       
       Long[][] mi= new Long[N][2];
       long[] a = new long[(int)N];
       for (int i=0 ; i<N; i++) {
           long x = sc.nextLong();
           long y = sc.nextLong();
           mi[i][0]=x-y;
           mi[i][1]=x+y;
       }
//       String S = sc.next();
//       String T = sc.next();
//       char[] s = S.toCharArray();
//       char[] t = T.toCharArray();
       int cnt=0;
       Arrays.sort(mi, (b, c) -> Long.compare(b[0], c[0])); 
       for(int i=0;i<N-1;i++) {
    	   if(mi[i][1]>mi[i+1][0]) {
    		   cnt++;
    		   mi[i+1][1]=Math.min(mi[i][1], mi[i+1][1]);
    	   }
       }
       
       
       System.out.println(N-cnt);
   }


}

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/*************************************************************************************/
void file(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/*************************************************************************************/

const ll maxn=2e5+1,mod=1e9+7;

vector<ll> bit(maxn);
int n,n1;

void upd(int idx,ll val){
	while(idx<=n1){
		bit[idx] = max(bit[idx],val);
		idx+=(idx&-idx);
	}
}

ll q(int idx){
	ll mx = 0;
	while(idx>0){
		mx = max(mx,bit[idx]);
		idx-=(idx&(-idx));
	}
	return mx;
}


int main(){

    sync
  //  file();
    cin>>n;
    n1 = maxn;
    int h[n],b[n];
	forn(i,n) cin>>h[i];
	forn(i,n) cin>>b[i];
	ll ans = 0;
	forn(i,n){
		ll val = q(h[i]);
		ans = max(ans,b[i]+val);
		upd(h[i],b[i]+val);
	}
	cout<<ans;
    
  return 0;
}

Measured memory_bytes: 3328
/*
	0277:Ticket Sales
*/
#include	<iostream>
#include	<cstdio>

using namespace std;

int main(void) {
	const int saleTic[4] = { 6000, 4000, 3000, 2000 };
	
	for(int i = 0; i < 4; i++) {
		int a, b;
		
		cin >> a >> b;
		
		cout << saleTic[a - 1] * b << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    string s;
    cin>>s;
    int count=0,ma=0;
    rep(i,sz(s)){
        if(s.at(i)=='A' || s.at(i)=='T' || s.at(i)=='G' || s.at(i)=='C'){
            count++;
        }
        else{
            chmax(ma,count);
            count=0;
        }
    }
    chmax(ma,count);
    cout<<ma<<endl;;
}

Measured memory_bytes: 3604
import Control.Monad (replicateM)

type Glass = Int
type MaxGlass = Int
type Trays = ([Glass],[Glass],[Glass])
type Goal = Int

main = do
    [maxGlass,limit] <- getLine >>= return . map read . words
    if maxGlass == 0 && limit == 0 then return () else do
        [t1,t2,t3] <- replicateM 3 (getLine >>= return . map read . tail . words)
        print $ solve maxGlass limit (t1,t2,t3)
        main

solve :: MaxGlass -> Int -> Trays -> Int
solve maxGlass limit ts = count `seq` if count <= limit then count else -1
    where
    count = min (stack maxGlass ts 1) (stack maxGlass ts 3)

stack :: MaxGlass -> Trays -> Goal ->  Int
stack maxGlass ts@(t1,t2,t3) goal = stack' goal 1
    where
    stack' goal glass
        | glass > maxGlass = 0
        | goal == 1 && glass `elem` t1 || goal == 3 && glass `elem` t3
            = stack' goal (glass+1)
        | goal == 1 && glass `elem` t2 || goal == 3 && glass `elem` t2
            = 1 + (stack' (otherside goal) (glass+1)) + (move (glass+1))
        | goal == 1 && glass `elem` t3 || goal == 3 && glass `elem` t1
            = 2 + (stack' goal (glass+1)) + 2 * (move (glass+1))

    otherside 1 = 3
    otherside 3 = 1

    move glass
        | maxGlass <  glass = 0
        | otherwise         = 2 + 3 * move (glass+1)

Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  //cout << "aaa" << endl;
  while (true) {
    ll n, k;
    cin >> n >> k;
    if (n == 0 && k == 0) break;
    vector<ll> A(n);
    for (ll i = 0; i < n; i++) {
      cin >> A[i];
    }

    vector<ll> s(n);
    for (ll i = 0; i < n; i++) {
      s[i + 1] = s[i] + A[i];
    }
    ll mx = (1LL << 60) * -1;

    for (ll i = 0; i < n - k; i++) {
      mx = max(mx, s[i + k] - s[i]);
    }
    cout << mx << endl;
  }
}


Measured memory_bytes: 4364
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
tmp = [[0 for i in range(6)] for j in range(n+1)]
absDiff = abs(x[0]-y[0])
tmp[0][3] = tmp[0][0] = absDiff
tmp[0][4] = tmp[0][1] = absDiff ** 2
tmp[0][5] = tmp[0][2] = absDiff ** 3
max = absDiff
for i in range(1, n, 1):
    absDiff = abs(x[i]-y[i])
    tmp[i][0] = absDiff
    tmp[i][1] = absDiff ** 2
    tmp[i][2] = tmp[i][1] * absDiff
    tmp[i][3] = tmp[i-1][3] + tmp[i][0]
    tmp[i][4] = tmp[i-1][4] + tmp[i][1]
    tmp[i][5] = tmp[i-1][5] + tmp[i][2]
    if absDiff > max:
        max = absDiff
print(tmp[n-1][3])
print(tmp[n-1][4] ** (1/2))
print(tmp[n-1][5] ** (1/3))
print(max)

Measured memory_bytes: 7868
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int ans=0;
    char s[10],t[10];
    cin >> s >> t;
    rep(i,3) if(s[i] == t[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
	int n,k;
	cin>>n>>k;
	if(n%2 == 1 && n/2+1 >= k) cout << "YES" << endl;
	else if(n%2 == 0 && n/2 >= k) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

// oxoxo 5なら3個まで n/2+1
// oxoxox 6なら3個まで
// xoxoxo 6なら3個まで…n/2だと思うんだけどなぜ

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define ll               long long
#define pb                push_back
#define mp                make_pair
#define li                list<int>
#define pii               pair<int,int>
#define vit                vector<int>
#define mii               map<int ,int>
#define setbits(x)        __builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ln                cout<<'\n'
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
#define all(x)            (x).begin(), (x).end()
#define PI                3.14159265358979
#define p_sieve           100000
const ll MAX = 1e9 + 7, MAXL = 1LL << 61, dx[8] = { -1, 0, 1, 0, -1, -1, 1, 1}, dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("g.txt", "r", stdin);
	freopen("b.txt", "w", stdout);
#endif
}

ll d[1111111], c[1111111];
void solve()
{
	ll n; cin >> n;
	ll a[n];
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
		d[a[i]]++;
	}
	ll counter = 0;
	for (ll i = 1; i <= 1111111; i++)
	{
		if (d[i])
			for (ll j = i * 2; j <= 1111111; j += i)c[j]++;
	}
	for (ll i = 0; i < n; i++)
	{
		if (d[a[i]] == 1 && !c[a[i]])counter++;
	}
	cout << counter;
}

int32_t main()
{
	c_p_c();
	solve();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}


Measured memory_bytes: 21644
K = int(input())
list_k =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(list_k[K-1])


Measured memory_bytes: 2940
#include<stdio.h>
#include<queue>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int w[1000],sam=0,n,sum=0,in=10000000;
int dd(int x,int y)
{
    if(x>y) return x-y;
    return y-x;
}
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&w[i]);
    }
    for(int i=1; i<=n; i++)
    {
        sam=0,sum=0;
        for(int j=1; j<=n; j++)
        {
            if(j>i)
            {
                sam+=w[j];
            }
            else
            {
                sum+=w[j];
            }
        }
        ///printf("%d %d %d\n",sum,sam,i);
        if(dd(sam,sum)<in)
            in=dd(sam,sum);
    }
    printf("%d\n",in);

    return 0;
}









Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a[3], b[3], i, cnt1=0, cnt2=0, cnt3=0, cnt4=0, ans1=0, ans2=0;

    for(i=0;i<3;i++){
        scanf("%d%d", &a[i], &b[i]);
    }

    for(i=0;i<3;i++){
        if(a[i]==1) cnt1++;
        if(a[i]==2) cnt2++;
        if(a[i]==3) cnt3++;
        if(a[i]==4) cnt4++;
        if(b[i]==1) cnt1++;
        if(b[i]==2) cnt2++;
        if(b[i]==3) cnt3++;
        if(b[i]==4) cnt4++;
    }

    if(cnt1==1) ans1++;
    if(cnt1==2) ans2++;
    if(cnt2==1) ans1++;
    if(cnt2==2) ans2++;
    if(cnt3==1) ans1++;
    if(cnt3==2) ans2++;
    if(cnt4==1) ans1++;
    if(cnt4==2) ans2++;

    if(ans1==2 && ans2==2) printf("YES\n");
    else printf("NO\n");
        
    
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Text;

namespace AtcoderTest.BeginnerContest124
{
    class C
    {
        public static void Main()
        {
            string S = Console.ReadLine();
            int num = 0;
            char p = S[0];
            for(var i = 1; i < S.Length; i++)
            {
                if (p == S[i])
                {
                    num++;
                    if (S[i] == '0')
                    {
                        p = '1';
                    }
                    else
                    {
                        p = '0';
                    }
                }
                else
                {
                    p = S[i];
                }
            }
            Console.WriteLine(num);
        }
    }
}


Measured memory_bytes: 13140
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			int[][] map = new int[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					map[i][j] = scanner.nextInt();
				}
			}
			int[][][] p = new int[4][m][m];
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < m; j++) {
					p[0][i][j] = scanner.nextInt();
				}
			}
			for (int k = 1; k < 4; k++) {
				for (int i = 0; i < m; i++) {
					for (int j = 0; j < m; j++) {
						p[k][i][j] = p[k - 1][j][m - i - 1];
					}
				}
			}
			int ay = -1;
			int ax = -1;
			boolean flag = false;
			loop: for (int i = 0; i <= n - m; i++) {
				for (int j = 0; j <= n - m; j++) {
					a: for (int k = 0; k < 4; k++) {
						boolean f = false;
						for (int y = 0; y < m; y++) {
							for (int x = 0; x < m; x++) {
								if (p[k][y][x] == -1)
									continue;
								else if (!f) {
									f = true;
									ay = i + y + 1;
									ax = j + x + 1;
								}
								if (p[k][y][x] != map[i + y][j + x]) {
									continue a;
								}
							}
						}
						flag = true;
						break loop;
					}

				}
			}
			System.out.println(flag ? ax + " " + ay : "NA");

		}
	}
}

Measured memory_bytes: 66380
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

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

    cout <<( (b * 10 + c) % 4 == 0 ? "YES" : "NO")<<endl;

    return 0;
}

Measured memory_bytes: 256
S = list(input())
ans = []
N = len(S) + 1

lr = [[] for _ in range(N)]

# 左から見る
temp = 0
for i in range(N):
    if i == 0:
        lr[i].append(0)
    else:
        if S[i-1] == "<":
            temp += 1
            lr[i].append(temp)
        else:
            temp = 0
            lr[i].append(temp)

# 右から見る
temp = 0
for i in reversed(range(N)):
    if i == N - 1:
        lr[i].append(0)
    else:
        if S[i] == ">":
            temp += 1
            lr[i].append(temp)
        else:
            temp = 0
            lr[i].append(temp)

ans = []
for i in range(N):
    ans.append(max(lr[i]))
print(sum(ans))

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

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

	if ((a + b) % 2 == 0) x = (a + b) / 2;
	else x = (a + b) / 2 + 1;

	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256