akhauriyash/Code-Regression huggingface dataset:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))

    c = collections.Counter(a).most_common()
    ans = [0] * (n + 1)
    for i, cc in enumerate(c):
        ans[cc[0] - 1] += cc[1]
    for i in range(n):
        print(ans[i])
if __name__=='__main__':
    main()


Measured memory_bytes: 44376
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	// scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	k := scanInt()

	ans := 0
	for i := 1; i <= k; i++ {
		for j := 1; j <= k; j++ {
			for kk := 1; kk <= k; kk++ {
				ans += gcd(gcd(i, j), kk)
			}
		}
	}

	fmt.Println(ans)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {
	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}

func isPrimeNum(n int) bool {

	if n <= 1 {
		return false
	}

	l := int(math.Sqrt(float64(n)) + 1.)
	for i := 2; i < l; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

vector<pii> inputline(){
  int m;
  cin >> m;
  vector<pii> line(m);
  REP(i, m){
    cin >> line[i].first >> line[i].second;
  }
  return line;
}

vector<pii> transform(vector<pii> line, pii src){
  REP(i, line.size()){
    line[i].first -= src.first;
    line[i].second -= src.second;
  }
  return line;
}

vector<pii> rotate(vector<pii> line, int n){
  REP(j, n){
    REP(i, line.size()){
      line[i] = {-line[i].second, line[i].first};
    }
  }
  return line;
}

int main() {
  int n;

  while(cin >> n, n){

    vector<pii> src = inputline();
    vector<pii> rsrc = src;
    reverse(ALL(rsrc));
    vector<vector<pii>> answer;
    answer.push_back(transform(src, src[0]));
    answer.push_back(transform(rsrc, rsrc[0]));
    REP(i, 3){
      answer.push_back(rotate(answer[0], i + 1));
      answer.push_back(rotate(answer[1], i + 1));
    }

    // LOG("anserrrrrrrrr\n");
    // for(vector<pii> line:answer) {
    //   for (pii p : line) {
    //     LOG("%d %d, ", p.first, p.second);
    //   }
    //   LOG("\n");
    // }
    // LOG("anserrrrrrrrr\n");

    REP(i, n){
      vector<pii> line = inputline();
      line = transform(line, line[0]);
      // for (pii p : line) {
      //   LOG("%d %d, ", p.first, p.second);
      // }
      // LOG("\n");
      for(vector<pii> l : answer) {
        if (l == line) {
          cout << i + 1 << endl;
          break;
        }
      }
    }
    cout << "+++++" << endl;
  }
}

Measured memory_bytes: 3012
n = gets.to_i
edges = {}
(1..n).each{|v| edges[v] = []}
(n-1).times{
    a, b, c = gets.split.map(&:to_i)
    edges[a] << [b, c]
    edges[b] << [a, c]
}

costs = []
q, k = gets.split.map(&:to_i)
visited = []
visited[k] = true
costs[k] = 0
queue = [k]
until queue.empty?
    v = queue.shift
    edges[v].reject{|u, c| visited[u]}.each{|u, c|
        visited[u] = true
        costs[u] = costs[v] + c
        queue << u
    }
end
q.times{
    x, y = gets.split.map(&:to_i)
    puts costs[x] + costs[y]
}

Measured memory_bytes: 35136
//３つの整数 a、b、c を読み込み、a から b までの整数の中に、c の約数がいくつあるかを求めるプログラム
#include <stdio.h>

int main(void)
{
    //変数定義
    int iInputA;
    int iInputB;
    int iInputC;
    int iCount;
    int iDivisorCount;

    //変数の初期化
    iInputA = 0;
    iInputB = 0;
    iInputC = 0;
    iDivisorCount = 0;

    scanf("%d %d %d",&iInputA,&iInputB,&iInputC);
    for (iCount = iInputA; iCount <= iInputB; iCount++)
    {
        if (iInputC % iCount == 0)
        {
            iDivisorCount++;
        }
        else
        {
            //何もしない
        }
    }
    printf("%d\n",iDivisorCount);


    return 0;
} 


Measured memory_bytes: 2104
#include "stdio.h"
int main(void){
int H,W;
int i,j;
do{
scanf("%d %d",&H,&W);	
if(H!=0 || W!=0){
for(i=0;i<H;i++){
for(j=0;j<W;j++){
if(((i+j)%2==0)){
printf("#");
}else{
printf(".");
}
}
puts("");
}
puts("");
}
}while(H!=0 || W!=0);
return 0;
}

Measured memory_bytes: 588
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N, H;
	cin >> N >> H;
	int a_max = 0;
	int a[100010], b[100010];
	for (int i = 1; i <= N; i++) {
		cin >> a[i] >> b[i];
		if (a[i] > a_max)a_max = a[i];

	}
	sort(b + 1, b + 1 + N, greater<int>());
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (H > 0 && b[i] > a_max) {
			ans++;
			H -= b[i];
		}
		else break;
	}
	if (H > 0 && H % a_max == 0)ans += H / a_max;
	else if (H > 0)ans += H / a_max + 1;

	cout << ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
struct data{int x,i,o;}s[200010];
int type[100010],A[100010],B[100010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),m=0;
	for(int i=1;i<=n;++i){
		A[i]=gi(),s[++m]={A[i],i,1};
		B[i]=gi(),s[++m]={B[i],i,2};
	}
	std::sort(s+1,s+m+1,[](data a,data b){return a.x<b.x;});
	int c[4]={0};
	ll sum=0;
	for(int i=1;i<=n;++i)type[s[i].i]|=s[i].o,sum+=s[i].x;
	for(int i=1;i<=n;++i)++c[type[i]];
	if(c[0]||!c[1]||!c[2])return printf("%lld\n",sum),0;
	ll mn1=1e18,cmn1=1e18,mn2=1e18,cmn2=1e18;
	for(int i=n+1;i<=m;++i)
		if(type[s[i].i]==1){
			if(s[i].x<mn1)cmn1=mn1,mn1=s[i].x;
			else if(s[i].x<cmn1)cmn1=s[i].x;
		}else{
			if(s[i].x<mn2)cmn2=mn2,mn2=s[i].x;
			else if(s[i].x<cmn2)cmn2=s[i].x;
		}
	ll ans=1e18;
	for(int i=1;i<=n;++i)
		if(type[i]==1)//A[i]<B[i]
			ans=std::min(ans,sum-A[i]+std::min(mn2,c[1]==1?B[i]:(mn1==B[i]?cmn1:mn1)));
		else ans=std::min(ans,sum-B[i]+std::min(mn1,c[2]==1?A[i]:(mn2==A[i]?cmn2:mn2)));
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3712
function main(lines) {
    const input = lines.split(' ').map(Number)
    const a = input[0]
    const b = input[1]
    const radian = input[2]*(Math.PI/180)

    const S = (a*b*(1/2)*Math.sin(radian)).toFixed(4)
    const L = (Math.sqrt(a*a + b*b - 2*a*b*Math.cos(radian)) + a + b).toFixed(4)
    const h = (b*Math.sin(radian)).toFixed(4)

    console.log(S + ' ' + L + ' ' + h)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 15144
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = 0
    right = 0
    s = 0

    for left in range(N):
        while right < N and s & A[right] == 0:
            s += A[right]
            right += 1

        ans += right - left

        if left == right:
            right += 1
        else:
            s -= A[left]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 103320
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jasper van Merle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String str = in.next();
            out.println(str.length() - str.replaceAll("1", "").length());
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return st.nextToken();
        }

    }
}



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

int main() {
  int n,S;
  while(cin >> n >> S && (n||S)) {
    int a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    int cnt=0;
    for(int i=0; i<n-1; i++) {
      for(int j=i+1; j<n; j++) {
	if(a[i]+a[j]>S) cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
char n[10010];
bool c,f;
int main() 
{
    cin>>n;
    for(int i=0; i<strlen(n); i++) 
    {
        if(n[i]=='C') 
            c=true;
        if(n[i]=='F'&&c==true) 
            f=true; 
    }
    if(f==true) 
        cout<<"Yes\n";
    else 
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O3")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

lli tmod(lli x,lli m){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;  
    }
    if(res<0)
       res+=mod; 
    return res; 
}
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
int n;
set <string> ans;
bool check(string &temp){
    string temp2=temp;
    int mark[10];memset(mark,0,sizeof mark);
    int pos=0;
    f(i,0,temp.size()){
        if(!mark[temp[i]-'a']){
            if(temp[i]-'a'!=pos)return 0;
            mark[temp[i]-'a']=1;
            pos++;
        }
    }
    return 1;
}
void solve(string temp){
    if(temp.size()==n){
        ans.insert(temp);
        return;
    }
    f(i,0,10){
        string temp2=temp;
        temp2.pb('a'+i);
        if(check(temp2))solve(temp2);
    }
}
int main() 
{ 
    fastio;
    // fact[0]=1;
    // f(i,1,2000009)fact[i]=(fact[i-1]*i)%mod;
    int t;
    // cin>>t;
    t=1;
    while(t--){
            cin>>n;
            string temp="";
            solve(temp);
            for(auto x:ans)cout<<x<<"\n";
        }
    return 0; 	
}



Measured memory_bytes: 12416
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>

using namespace std;

int main() {

	int M,D;
	cin >> M >> D;

	int result = 0;

	for (int i = 0; i <= D; i++)
	{
		int d1 = i % 10;
		int d2 = i / 10;
		if (d1 >= 2 && d2 >= 2 && (d1*d2) <= M)
		{
			++result;
		}
	}

	cout << result << endl;
	
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	cout << A[N - 1] - A[0] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
  
using namespace std;
 
int main()
{
    int x, y;
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        int t[100], h[100];
        int t_sum = 0, h_sum = 0;
       
      
	 for(int i = 0; i < x; i++){
            cin >> t[i];
            t_sum += t[i];
        }
         for(int i = 0; i < y; i++){
            cin >> h[i];
            h_sum += h[i];
        }
        if((t_sum + h_sum) % 2 == 1) cout << -1 << endl;
        else{
            int t_sum_new, h_sum_new;
            for(int i = 0; i < x; i++){
                for(int j = 0; j < y; j++){
                    t_sum_new = t_sum + h[j] - t[i];
                    h_sum_new = h_sum + t[i] - h[j];
                    if(t_sum_new == h_sum_new){
                        cout << t[i] << ' ' << h[j] << endl;
                        i = 101;
                        break;
                    }
                }
                if(i == x - 1) cout << -1 << endl;
            }
        }
    }
   return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stack>
#include <cstring>

using namespace std;

char s[100];

int main(){
	stack<int> st;
	while(~scanf("%s", s)){
		if(s[0]=='+'){
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			st.push(a+b);
		}
		else if(s[0]=='-'){
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			st.push(b-a);	
		}
		else if(s[0]=='*'){
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			st.push(a*b);	
		}
		else{
			int tmp = 0;
			for(int i=0; i<strlen(s); i++){
				tmp *= 10;
				tmp += s[i]-'0';
			}
			st.push(tmp);
		}
	}
	cout<<st.top()<<endl;
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	int n = 0;
	cin >> n;

	vector<int> vec(n);
	map<int, int> mp;

	for (int i = 0; i < n; i++) {
		cin >> vec[i];
		mp[vec[i]]++;
	}

	vector<pii> res(ALL(mp));

	for (int i = 0; i < n; i++) {
		if (mp.rbegin()->second > 1)
			cout << res.back().first << '\n';
		else {
			if (vec[i] == res.back().first)
				cout << res[res.size() - 2].first << '\n';
			else
				cout << res.back().first << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define long long ll
#define MAXN 300

int a[MAXN + 1][MAXN + 1];

using namespace std;

int n, m;

int fr[MAXN + 1];
int ind[MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, j;
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for(i = 1; i <= n; i++)
        for(j = 1; j <= m; j++)
            cin >> a[i][j];
    int cnt = 0;
    for(i = 1; i <= n; i++)
        ind[i] = 1;
    int ans = n * m;
    while(cnt < m) {
        for(i = 1; i <= m; i++)
            if(fr[i] > -1)
               fr[i] = 0;
        for(i = 1; i <= n; i++) {
               while(ind[i] <= m && fr[a[i][ind[i]]] == -1)
                  ind[i]++;
               if(ind[i] == m + 1)
                  cnt = m + 1;
               else
                  fr[a[i][ind[i]]]++;
        }
        if(cnt < m) {
            int mx = 0;
            int val;
            for(i = 1; i <= m; i++)
                if(mx < fr[i]) {
                    mx = fr[i];
                    val = i;
                }
            ans = min(ans, fr[val]);
            fr[val] = -1;
            for(i = 1; i <= n; i++)
               if(a[i][ind[i]] == val)
                   ind[i]++;
            cnt++;
        }
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	while(1){
		ll e; cin >> e;
		if(!e) break;
		ll ans = inf;
		rep(i,101){
			ll tmp = e - i*i*i;
			if(tmp < 0) break;
			ll sq = (ll)sqrt(tmp);
			chmin(ans,i+sq+tmp-sq*sq);
		}
		cout << ans << endl;
	}
}


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

int main(){
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    ll x = (n + a - 1) / a * b;
    ll y = (n + c - 1) / c * d;
    cout << min(x, y) << endl;
    return 0;
}



Measured memory_bytes: 3124
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;
    t.pop_back();
    if (s == t) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<fstream>
using namespace std;
int n,m;
int sum;
int main()
{
	int a,b,c;
	cin>>a>>b;
	c=a*b;
	if(c%2==0)
	cout<<"Even"<<endl;
	else
	cout<<"Odd"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int x = int.Parse(input[0]);
            int a = int.Parse(input[1]);
            int b = int.Parse(input[2]);
            int A = Math.Abs(x - a);
            int B = Math.Abs(x - b);
            Console.WriteLine(A <= B ? "A" : "B");
        }
    }
}

Measured memory_bytes: 13268
lis = input().split(' ')
N= int(lis[0])
L = int(lis[1])

l = input().split(' ')
for i in range(N):
    l[i] = int(l[i])
l.sort()

#print(l)
ans = 0
n = N - 1
for i in range(L):
#    print(l[n])
    ans += l[n]
    n -= 1

print(ans)


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

int main() {

	int N;
	cin >> N;
	int W[110];
	int sum_all = 0;

	for (int i = 0; i < N; ++i) {
		cin >> W[i];
		sum_all += W[i];
	}

	int sum12;
	int abs_min=0;
	bool first_flg = true;

	for (int i = 0; i < N; ++i) {
		int sum1 = 0;

		for (int j= 0; j< i+1; ++j) { //
			sum1 += W[j];
		}
		
		sum12 = abs(sum1 - (sum_all - sum1));

		if (first_flg == false) {
			if (sum12 < abs_min) {
				abs_min = sum12;
			}
		}

		else if (first_flg == true) {
			first_flg = false;
			abs_min = sum12;

		}

	}
	cout << abs_min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    int A[210];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int count = 0;
    while (true)
    {
        bool exist_odd = false;
        for (int i = 0; i < N; i++)
        {
            if(A[i] % 2 != 0){
                exist_odd = true;
                break;
            }
        }
        if(exist_odd) break;

        for (int i = 0; i < N; i++)
        {
            A[i] /= 2;
        }
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,c;
  cin>>a>>b>>c;
  map<int,int>m1;
  m1[a]++;
  m1[b]++;
  m1[c]++;
  if(m1.size()==2)
    cout<<"Yes";
  else cout<<"No";
return 0;
}

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

typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef pair<ll,ld> pd;
typedef pair<ld,ll> pdi;

typedef vector <pd> vpi;
typedef pair<pi,ll> pii;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001

string S,T;
int q;

int SsumsA[maxn],SsumsB[maxn],TsumsA[maxn],TsumsB[maxn];

int main(){
	fast;
	
	cin>>S>>T>>q;
	
	FOR(i,1,S.size()){
		if (S[i-1] == 'A'){
			SsumsA[i] = SsumsA[i-1] + 1;
			SsumsB[i] = SsumsB[i-1];
		}else{
			SsumsA[i] = SsumsA[i-1] ;
			SsumsB[i] = SsumsB[i-1] + 1;
		}
	}
	
	FOR(i,1,T.size()){
		if (T[i-1] == 'A'){
			TsumsA[i] = TsumsA[i-1] + 1;
			TsumsB[i] = TsumsB[i-1];
		}else{
			TsumsA[i] = TsumsA[i-1] ;
			TsumsB[i] = TsumsB[i-1] + 1;
		}
	}
	
	FOR(i,0,q-1){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		
		int AsumsS = SsumsA[b] - SsumsA[a-1], BsumsS = SsumsB[b] - SsumsB[a-1];
		int AsumsT = TsumsA[d] - TsumsA[c-1], BsumsT = TsumsB[d] - TsumsB[c-1];
		
		int Ssum = AsumsS + 2 * BsumsS;
		int Tsum = AsumsT + 2 * BsumsT;
		
		if (Ssum % 3 == Tsum % 3) cout<<"YES\n";
		else cout<<"NO\n";
	}
}


Measured memory_bytes: 2512
S = input()
q = int(input())

ans = S
for _ in range(q):
    A = input().split()
    if A[0]=='print':
        a,b = map(int, A[1:])
        print(ans[a:b+1])
    elif A[0]=='reverse':
        a,b = map(int, A[1:])
        ans = ans[:a] + ans[a:b+1][::-1] + ans[b+1:]
    elif A[0]=='replace':
        a,b = map(int, A[1:3])
        p = A[3]
        ans = ans[:a] + p + ans[b+1:]


Measured memory_bytes: 5608
#include<stdio.h>

long long int abs(long long int);

int main(){
    long long int a[100002], N, i;
    unsigned long long int max;
    scanf("%llu", &N);
    for(i=0;i<N;i++)scanf("%llu", &(a[i+1]));
    a[0] = a[100001] = 0;
    max = 0;
    for(i=0;i<=N+1;i++)max += abs(a[i+1]-a[i]);
    for(i=1;i<=N;i++){
        printf("%llu\n", max+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1])));
    }
    return 0;
}

long long int abs(long long int a){
    if(a>0)return a;
    return -a;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;

int INF = 1LL << 30;
int MOD = 1e9 + 7;

int main(void) {
    int N;
    cin >> N;
    vector<int> L(N + 2), R(N + 2), V(N + 2);
    int T = 0;
    //l(s) - r(s)
    for (int i = 1; i <= N; i++) {
        int t;
        cin >> t;
        t *= 2;//
        L[i] = R[i - 1];
        R[i] = L[i] + t;
        T += t;
    }
    for (int i = 1; i <= N; i++)cin >> V[i], V[i] *= 2;
    L[N + 1] = R[N + 1] = T;
    vector<double> vel;
    for (int i = 0; i <= T; i++) {
        double v = INF;
        int t = i;
        for (int j = 0; j < N + 2; j++) {
            if (t <= L[j]) v = min(v, 1. * V[j] + L[j] - t);
            else if (t >= R[j]) v = min(v, 1. * V[j] + t - R[j]);
            else v = min(v, 1. * V[j]);
        }
        vel.push_back(v);
    }
    double sum = 0;
    for (int i = 0; i < T; i++) {
        sum += 0.25 * (vel[i] + vel[i + 1]);
    }
    printf("%.9lf\n", sum / 2);

    return 0;
}

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

int main(){
  int N;cin>>N;
  int t=1;
  for(int i=0;i<=N;i+=4){
    for(int j=0;j<=N;j+=7){
      if(i+j==N){
        t=0;break;
      }
    }
  }
  if(t==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    public class Program
    {
        public static void Main()
        {
            string line = System.Console.ReadLine();
            string []input = line.Split(' ');
            string str_in = input[0];
            line = System.Console.ReadLine();
            input = line.Split(' ');
            string str_out = input[0];

            if(str_out.Substring(0,str_out.Length-1) == str_in)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 25888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
const int maxn = 2e5+10;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
int d[4][2]={1,0,0,1,-1,0,0,-1};
ll a[maxn];
int main() {
    ios::sync_with_stdio(0);
    #ifdef Uncle_drew
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #else
    #endif
    int n;
    cin>>n;
    map<ll,ll> ma;
    ll ans=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        ma[i-a[i]]++;
    }
    for(int i=1;i<=n;i++){
        ans+=ma[i+a[i]];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 27880
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
	int N, M;
	cin >> N >> M;

	int cnt[N];
	for(int i=0;i<N;i++) cnt[i] = 0;

	for(int i=0;i<M;i++){
		int a, b;
		cin >> a >> b;
		cnt[a-1]++;
		cnt[b-1]++;
	}

	for(int i=0;i<N;i++){
		cout << cnt[i] <<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

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

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL vmax(vi v, LL n) {
	int MAX = 0;
	f(i, 0, n) {
		MAX = max(MAX, v[i]);
	}
	return MAX;
}

LL vmin(vi v, LL n) {
	int MIN = LL_INF;
	f(i, 0, n) {
		MIN = min(MIN, v[i]);
	}
	return MIN;
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//エラトステネスの篩
void sieve(LL n) {
	vb s(n + 1, true);
	f(i, 2, n + 1) {
		for (int j = 2; i*j <= n; j++) {
			s[i*j] = false;
		}
	}
	cout << "2から" << n << "までの素数" << endl;
	f(i, 2, n + 1) {
		if (s[i]) {
			cout << i << " ";
		}
	}
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	int n, y, m, d, sum;
	cin >> n;
	f(i, 0, n) {
		cin >> y >> m >> d;
		sum = 0;
		if (y % 3 == 0 || m % 2 == 1) {
			sum += 20 - d;
		}
		else {
			sum += 19 - d;
		}
		f(j, m + 1, 11) {
			if (y % 3 == 0 || j % 2 == 1) {
				sum += 20;
			}
			else {
				sum += 19;
			}
		}
		f(j, y + 1, 1000) {
			if (j % 3 == 0) {
				sum += 200;
			}
			else {
				sum += 195;
			}
		}
		cout << sum + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define rep(i,s,t) for (auto i=s; i<=t; i++)
#define per(i,s,t) for (auto i=s; i>=t; i--)
using namespace std;
const int maxn=3e5+10;
int n,k,a[maxn];

int main(){
    scanf("%d%d",&n,&k);
    if(!(n&1)){
        printf("%d ",n/2);
        rep(i,2,k)
            printf("%d ",n);
        return 0;
    }
    rep(i,1,k)
        a[i]=(n+1)/2;
	int top=k;
	rep (i,1,k/2)
		if (a[top]==1) top--;
		else {
			a[top]--;
			while(top<k) a[++top] = n;
		}
	rep (i,1,top) printf("%d ",a[i]);
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, 0, n){
        cin >> a[i] >> b[i];
    }
    int ans = 0, now = 0;
    repb(i, n - 1, 0){
        a[i] += now;
        int tmp = (b[i] - a[i] % b[i]) % b[i];
        now += tmp;
        ans += tmp;
    }
    cout << ans << endl;
}

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

#define ll long long
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll> &b)
{
  return a.first<b.first;
}

int main()
{
  ll a,b;
  cin>>a>>b;
  vector<pair<ll,ll>> v;
  while(a--)
  {
    ll c,d;
    cin>>c>>d;
    v.pb(mk(c,d));
  }
  sort(v.begin(),v.end(),sortbysec);
  ll sum=b,ans;
  for(ll i=0;i<v.size();i++)
  {
    sum-=v[i].second;
    if(sum<=0)
    {
      ans=v[i].first;
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2420
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<string>
#include<iomanip>

int main() {
	double r;
	cin >> r;
	double m = 3.141593;
	double ans = 2 * r * m;
	cout << fixed << setprecision(8) << ans;

	return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;
const double PI = acos(-1);

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
  vector<int> p;
  vector<int> s;
  void init(int n) {
    p.resize(n, -1);
    s.resize(n, 1);
  }
  int find(int n) {
    if(p[n] == -1) return n;
    else return find(p[n]);
  }
  int size(int n) {
    return s[find(n)];
  }
  void unite(int n, int m) {
    int pn = find(n);
    int pm = find(m);
    if(pn == pm) return;
    if(s[pn] > s[pm]) {
      s[pn] = s[pn] + s[pm];
      p[pm]= pn;
    } else {
      s[pm] = s[pm] + s[pn];
      p[pn] = pm;
    }
  }
};

long long gcd(long long a, long long b) {
  if(a % b == 0) return b;
  else return gcd(b, a % b);
}
int main() {
  int h, w;
  cin >> h >> w;
  vector<int> al(26);
  rep(i, h * w) {
    char c;
    cin >> c;
    al[c-'a']++;
  }
  int odd = 0;
  int even = 0;
  int four = 0;
  bool yes = true;
  if(h % 2 == 0 && w % 2 == 0) {
    rep(i, al.size()) {
      if(al[i] % 4 != 0) yes = false;
    }
  }
  else if(h % 2 == 1 && w % 2 == 1) {
    rep(i, al.size()) {
      if(al[i] % 2 == 1) {
        odd++;
        al[i] -= 1;
      }
      if(al[i] % 4 == 2) four += 2;
    }
    if(odd != 1) yes = false;
    if(four > h + w - 2) yes = false;
  }
  else {
    rep(i, al.size()) {
      if(al[i] % 2 == 1) odd++;
      else if(al[i] % 4 != 0) four+=2;
    }
    if(odd != 0) yes = false;
    if(h % 2 == 0) {
      if(four > h) yes = false;
    }
    else if(four > w) yes = false;
  }
  if(yes) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
import math

n,d = [int(i) for i in input().split()]
main = []
for i in range(n):
  array = [int(i) for i in input().split()]
  main.append(array)
  
cnt = 0

for i in range(n):
  for j in range(i+1,n):
    kyori2 = 0
    for k in range(d):
      kyori2 += (main[i][k]-main[j][k])*(main[i][k]-main[j][k])
      
    kyori = math.sqrt(kyori2)
    if int(kyori)+0.000001 > kyori:
      cnt += 1
      
print(cnt)

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

int main( void ) {
    
    long long i, o, t, j, l, s, z, ans;
    cin >> i >> o >> t >> j >> l >> s >> z;
    
    ans = o + (i / 2) * 2 + (j / 2) * 2 + (l / 2) * 2;
    
    if( i >= 1 && j >= 1 && l >= 1 ) {
        i --; j --; l --;
        ans = max( ans, 3 + o + (i / 2) * 2 + (j / 2) * 2 + (l / 2) * 2 );
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
    int min,max;
    int a,b,c,d,e;
    cin >> min >> max;
    int count = 0;
    for(int i=min; i<=max; i++){
        a = i / 10000;
        b = i / 1000 - 10 * a;
        c = i / 100 - 100 * a - 10 * b;
        d = i / 10 - 1000 * a - 100 * b - 10 * c;
        e = i - 10000 * a - 1000 * b - 100 * c - 10 * d;
        if(a == e && b == d){
            count += 1;
        }
    }
    cout << count << '\n';
}

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
#define N 10000000
ll num[10000009];
ll di[10000009];
vector<ll> prime;
void seive()
{
    ll i,j;
    num[1] = true;
    for(i=1;i<=N;i++)
        num[i]  = i;
    for(i=4; i<=N; i+=2)
    {
        num[i] = 2;
    }
    for(i=3; i<=sqrt(N); i+=2)
    {
        if(num[i]==i)
        {
            for(j=2*i; j<=N; j+=i)
            {
                if(num[j]==j)
                    num[j] = i;
            }
        }
    }
}

ll fact(ll n)
{
    ll x,cnt=0,ans = 1;
    while(n>1)
    {
        x = num[n];
        cnt = 0;
        while(n%x==0)
        {
            n = n/x;
            cnt++;
        }
        ans = ans*(cnt+1);

    }
    return ans;
}
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    FAST
    seive();
    di[1]  =1;
    for(i=2;i<=10000000;i++)
    {
        di[i]  =fact(i);
    }
    cin>>n;
    ll ans = 0;
    for(i=1;i<=n;i++)
        ans+= i*di[i];
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 159892
"use strict";
const NUM = 3;
const MAX_N = 100;

function check(ty, xy, n) {
    let flg = false;
    ty[xy[n]]++;
    if (ty[xy[n]] == NUM) flg = true;
    return flg;
}

function check_naname(nnm, y, x, n) {
    let flg = false;
    if (y[n] == x[n]) {
        nnm[0]++;
        if (nnm[0] == NUM) flg = true;
    }
    if (y[n] == NUM - x[n] - 1) {
        nnm[1]++;
        if (nnm[1] == NUM) flg = true;
    }
    return flg;
}

function main(input) {
    let idx = 0;
    let line = input.split(/\r?\n/g);
    let y = new Array(MAX_N).fill(-1);
    let x = new Array(MAX_N).fill(-1);
    for (let i = 0; i < NUM; i++) {
        let arr = line[idx].split(" ").map(Number);
        idx++;
        for (let j = 0; j < NUM; j++) {
            arr[j]--;
            y[arr[j]] = i;
            x[arr[j]] = j;
        }
    }
    let N = parseInt(line[idx]);
    idx++;
    let b = line.slice(idx, idx + N).map(Number);
    let tate = new Array(NUM).fill(0);
    let yoko = new Array(NUM).fill(0);
    let naname = new Array(2).fill(0);
    let flg = false;
    for (let i = 0; i < b.length; i++) {
        b[i]--;
        if (y[b[i]] == -1) continue;
        flg = check(tate, y, b[i]);
        if (flg) break;
        flg = check(yoko, x, b[i]);
        if (flg) break;
        flg = check_naname(naname, y, x, b[i]);
        if (flg) break;
    }
    console.log(flg ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

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

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

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

fn main() {
  input! {
    _n: usize,
    a: usize1,
    b: usize1,
    c: usize1,
    d: usize1,
    s: chars
  }
  for i in a .. cmp::max(c, d) {
    if s[i] == '#' && s[i+1] == '#' {
      println!("No");
      return;
    }
  }
  if c < d {
    println!("Yes");
    return;
  }
  for i in b .. d + 1 {
    if s[i-1] == '.' && s[i] == '.' && s[i+1] == '.' {
      println!("Yes");
      return;
    }
  }

  println!("No");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int count2(int n){
	int res = 0;
	while(n > 0){
		res += (int)(n % 10 == 2);
		n /= 10;
	} // end while
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	int res = count2(N);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256