akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
  int N; cin >> N;
  string t;
  cin >> t;
  int ans = 0;
  for(int i=0;i<N;++i){
    string test; cin >> test;
    bool flag = false;
    for(int st=0;st<test.size();++st){
      if(test[st] != t[0]) continue;
      for(int dx=1;dx<100;++dx){
	int k = 1;
	for(k=1;k<t.size();++k)
	  if(st+dx*k >= test.size() || t[k] != test[st+dx*k])
	    break;
	if(k == t.size()){
	  flag = true;
	  break;
	}
      }
      if(flag) break;
    }
    if(flag) ++ans;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1208
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: usize = read();
    let y: usize = read();
    let z: usize = read();

    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
def dfs(t, c_max):
    if(len(t)==n):
        print(t)
    else:
        for i in range(c_max+1):
            tmp_t = t
            tmp_t += s[i]
            # print(tmp_t)
            dfs(tmp_t,max(i+1, c_max))

s = "abcdefghijklm"
n = int(input())

dfs('a', 1)

Measured memory_bytes: 4340
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;

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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

class lca {
public:
	const int n = 0;
	const int log2_n = 0;
	vector<vector<int>> parent;
	vector<int> depth;

	lca() {}

	lca(const Graph& g, int root)
		: n(g.size()), log2_n(log2(n) + 1), parent(log2_n, vector<int>(n)), depth(n) {
		dfs(g, root, -1, 0);
		for (int k = 0; k + 1 < log2_n; k++) {
			for (int v = 0; v < (int)g.size(); v++) {
				if (parent[k][v] < 0)
					parent[k + 1][v] = -1;
				else
					parent[k + 1][v] = parent[k][parent[k][v]];
			}
		}
	}

	//深さを求める＋一個上の親を保存
	void dfs(const Graph& g, int v, int p, int d) {
		parent[0][v] = p;
		depth[v] = d;
		for (auto& e : g[v]) {
			if (e.to != p) dfs(g, e.to, v, d + 1);
		}
	}

	//LCA(最小共通祖先)をえる
	int get(int u, int v) {
		//頂点の深さをあわせるために、深さが浅い法を遡らせる
		if (depth[u] > depth[v]) std::swap(u, v);
		for (int k = 0; k < log2_n; k++) {
			if ((depth[v] - depth[u]) >> k & 1) {
				v = parent[k][v];
			}
		}

		//降順で親が一致しない場合は遡る
		if (u == v) return u;
		for (int k = log2_n - 1; k >= 0; k--) {
			if (parent[k][u] != parent[k][v]) {
				u = parent[k][u];
				v = parent[k][v];
			}
		}
		return parent[0][u];
	}

	int d(int u, int v) {
		return depth[u] + depth[v] - 2 * depth[get(u, v)];
	}
};

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

	ll n;
	cin >> n;
	Graph g(n);

	REP(i, n) {
		ll k;
		cin >> k;
		REP(j, k) {
			ll c;
			cin >> c;
			add_edge(g, i, c, 1, false, 0);
		}
	}
	lca lc(g, 0);
	ll q;
	cin >> q;
	while (q--) {
		ll u, v;
		cin >> u >> v;
		cout << lc.get(u, v) << en;
	}

	return 0;
}



Measured memory_bytes: 19152
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
	vector<vector<int>> f(n, vector<int>(10));
	vector<vector<int>> p(n, vector<int>(11));
  
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            cin >> f[i][j];
        }
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 11; j++)
        {
            cin >> p[i][j];
        }
    }
    int ans = -1000000000;
    for(int i = 1; i < (1 << 10); i++)
    {
        int tans = 0;
        for(int j = 0; j < n; j++)
        {
            int count = 0;
            for(int k = 0; k < 10; k++)
            {
                if(i >> k & 1 && f[j][k])
                {
                    count++;
                }
            }
            tans += p[j][count];
        }
        ans = max(ans, tans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }

int main() 
{
    int a[3][3],n,b,x[3][3]={0};
    rep(i,3)rep(j,3)cin>>a[i][j];
    cin>>n;
    rep(i,n){
        cin>>b;
        rep(i,3)rep(j,3)if(a[i][j]==b)x[i][j]=1;
    }
    yn( 
        x[0][0]+x[0][1]+x[0][2]==3 ||
        x[1][0]+x[1][1]+x[1][2]==3 ||
        x[2][0]+x[2][1]+x[2][2]==3 ||
        x[0][0]+x[1][0]+x[2][0]==3 ||
        x[0][1]+x[1][1]+x[2][1]==3 ||
        x[0][2]+x[1][2]+x[2][2]==3 ||
        x[0][0]+x[1][1]+x[2][2]==3 ||
        x[0][2]+x[1][1]+x[2][0]==3
    );
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int a = scan.nextInt();

        if(n%500 <= a) System.out.println("Yes");
        else System.out.println("No");

        scan.close();
    
    }

}

Measured memory_bytes: 21716
import java.io.*;
 
class Main {
    public static void main( String[] args ) throws IOException
    {
        int width;
        int height;
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        String line = br.readLine();
        String[] splitStr = line.split( " ", 0 );
        width = Integer.parseInt( splitStr[ 0 ] );
        height = Integer.parseInt( splitStr[ 1 ] );
        System.out.println( width* height + " " + 2 * ( width + height ) );
    }
}

Measured memory_bytes: 24308
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
    
    int n;
    scanf("%d", &n);
    int p[n];
    for (int i=0; i < n; i++)
        scanf("%d", &p[i]);
    
    int cnt = 0;
    for (int i= 0; i < n; i++){
        if (p[i] != i+1)
            cnt++;
    }

    if (2 < cnt)
        printf("NO\n");
    else
        printf("YES\n");






    return 0;
} 



Measured memory_bytes: 128
from heapq import heappush, heappop, heapify

def resolve():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))

    heap = []

    for i in a:
        heappush(heap, -i)

    for i in range(m):
        max_price = heappop(heap) * -1
        discount_price = max_price // 2
        heappush(heap, -discount_price)

    print(sum(heap) * -1)





resolve()

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

using namespace std;

bool isprime(long long int P)
{
    if(P<=1)
    {
        return false;
    }
    for(long long int i=2;i<=sqrt(P);i++)
    {
        if(P%i==0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    vector<long long int>v;
    long long int n,m;
    cin>>n>>m;
    long long int d=2;
    long long int broj=m;
    int kolku=0;
    long long int nzd=1;
    if(n==1)
    {
        cout<<m<<endl;
        return 0;
    }
    if(m==1)
    {
        cout<<1<<endl;
        return 0;
    }
    while(broj>1)
    {
        //cout<<broj<<endl;
        if(broj%d==0 && isprime(d)==true)
        {
                broj=broj/d;
                v.push_back(d);
                kolku++;
                //cout<<d<<" "<<kolku<<endl;
                if(broj==1)
                {
                    if(kolku>=n)
                    {
                        for(int i=0;i<kolku/n;i++)
                        {
                            nzd=nzd*d;
                        }
                    }
                }
        }else
        {
                if(kolku>=n)
                {
                    for(int i=0;i<kolku/n;i++)
                        {
                            nzd=nzd*d;
                        }
                }
                d++;
                kolku=0;
        }
        if(d>sqrt(m))
        {
            break;
        }
    }
    cout<<nzd<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int sevencnt = 0, fivecnt = 0;
	int num[3];
		for (int i = 0; i < 3; i++)
		{
			cin >> num[i];
		}

	for (int i = 0; i < 3; i++)
	{
		if (num[i] == 7)
		{
			sevencnt++;
		}
		else if (num [i] == 5)
		{
			fivecnt++;
		}
	}

	if (fivecnt == 2 && sevencnt == 1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    ll p[A], q[B], r[C];
    REP(i, A) cin >> p[i];
    REP(i, B) cin >> q[i];
    REP(i, C) cin >> r[i];

    sort(p, p + A);
    sort(q, q + B);
    sort(r, r + C);

    ll d = 0;
    for (int i = A - 1; i >= A - X; --i) d += p[i];
    for (int i = B - 1; i >= B - Y; --i) d += q[i];

    int itA, itB, itC;
    itA = A - X;
    itB = B - Y;
    itC = C - 1;

    for (int itC = C - 1; itC >= 0; --itC) {
        bool fa = false, fb = false;
        ll ta = 1e+10, tb = 1e+10;
        if (itA < A) {
            if (p[itA] < r[itC]) {
                fa = true;
                ta = p[itA];
            }
        }
        if (itB < B) {
            if (q[itB] < r[itC]) {
                fb = true;
                tb = q[itB];
            }
        }
        if (fa || fb) {
            if (ta < tb) {
                d = d - ta + r[itC];
                itA++;
            }
            else {
                d = d - tb + r[itC];
                itB++;
            }
        }
    }
    cout << d << endl;


    return 0;
}


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

int main()
{
	auto start = steady_clock::now();

	int D;
	vector<int> cs(26);
	cin >> D;
	for (auto &&c : cs)
	{
		cin >> c;
	}
	vector<vector<int>> sss(D, vector<int>(26));
	for (auto &&ss : sss)
	{
		for (auto &&s : ss)
		{
			cin >> s;
		}
	}

	vector<int> ts(D, 0);

	auto calc_score = [&] {
		vector<int> last(26, -1);

		int s = 0;

		for (int d = 0; d < D; d++)
		{
			s += sss[d][ts[d]];

			last[ts[d]] = d;

			for (int i = 0; i < 26; i++)
			{
				s -= cs[i] * (d - last[i]);
			}
		}

		// return max(0, 1000000 + s);
		return s;
	};

	auto calc_diff = [&](int d, int q) {
		int p = ts[d];

		ts[d] = q;

		int ret = calc_score();

		ts[d] = p;

		return ret;
	};

	int score = calc_score();

	while (duration_cast<milliseconds>(steady_clock::now() - start).count() < 1950)
	{
		for (int d = 0; d < D; d++)
		{
			for (int q = 0; q < 26; q++)
			{
				if (ts[d] == q)
				{
					continue;
				}

				int next_score = calc_diff(d, q);

				if (score < next_score)
				{
					ts[d] = q;
					score = next_score;
				}
			}
		}
	}

	for (auto &&t : ts)
	{
		cout << t + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3668
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <cstdio>
//#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include <string>//"reverse(s's it,s's it)"
//#include <functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include <cmath>//"abs" "sqrt"
//#include <numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include <algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size()-8;++i) cout<<s[i];
	cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

void solve() {
    int n, m;
    std::string s;
    std::cin >> n >> m >> s;

    std::vector<int> ans;
    while (n > 0) {
        int i;
        for (i = m; i >= 1; --i) {
            if (n - i >= 0 && s[n - i] == '0') {
                break;
            }
        }
        if (i == 0) {
            ans.clear();
            break;
        } else {
            ans.push_back(i);
            n -= i;
        }
    }

    if (ans.empty()) {
        std::cout << -1 << std::endl;
    } else {
        std::reverse(ans.begin(), ans.end());
        for (auto x : ans) std::cout << x << " ";
        std::cout << std::endl;
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1096
use std::io;


fn main() {
    let n = read_one::<usize>();
    let an = read::<isize>();
    let min = an.iter().min().unwrap();
    let max = an.iter().max().unwrap();
    let sum = an.iter().sum::<isize>();
    println!("{} {} {}", min, max, sum);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 5040
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000;
const char END = '\n';

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

	ll Ans = 0;
	string S, T;
	cin >> S >> T;
	rep(i, S.size()) {
		if (S[i] == T[i])
			Ans++;
	}
	cout << Ans;
	cout << END;
	return 0;
}


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

int main(){
    int n ;
    cin >> n ;
    vector<double> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    int ave = round(accumulate(a.begin(),a.end(),0.0) /n) ;

    //cout << ave << endl;

    int ans = 0 ;

    for (size_t i = 0; i < n; i++)
    {
        ans += pow(a.at(i) - ave , 2) ;
    }
    
    cout << ans << endl ;
}    

Measured memory_bytes: 256
def main():
    from bisect import bisect_left
    import sys
    input = sys.stdin.buffer.readline
    def dist(x, s, t):
        if s < x and t < x:
            return x - min(s, t)
        elif s > x and t > x:
            return max(s, t) - x
        else:
            if (ds := abs(x - s)) <= (dt := abs(x - t)):
                return 2 * ds + dt
            else:
                return ds + 2 * dt
    def near(A, x):
        if (i := bisect_left(A, x)) == 0:
            return [A[0], ]
        elif 0 < i < len(A):
            return [A[i - 1], A[i]]
        else:
            return [A[-1], ]
    a, b, q = map(int, input().split())
    S = [int(input()) for _ in range(a)]
    T = [int(input()) for _ in range(b)]
    for _ in range(q):
        x = int(input())
        ans = 100000000000
        for s in near(S, x):
            for t in near(T, x):
                ans = min(ans, dist(x, s, t))
        print(ans)

if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin>>N;
  int ans=0;
  std::vector<int> v(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
    for(int j=0;;j++){
      if(v[i]%2==0){v[i]/=2;ans++;}
      else break;
    }
  }
  cout<<ans<<endl;
}


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

#define ll long long
#define pb push_back
#define vb vector<bool>
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll, ll>
#define MOD 1000000007
#define MAX_TIME 1e9
#define nl "\n"
#define sp " "
#define gcd __gcd
#define pf printf
#define sf scanf
#define se(a) a.begin(),a.end()
#define fill(a,n) for(int i = 0; i < n; i++)cin>>a[i]


int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n/x)*t + (n%x != 0)*t)<<nl;
}

Measured memory_bytes: 3620
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
vector<int>G[100006];
int color[100006];

int par[100006], siz[100006];
void init(int n) {
	rep(i, n) {
		par[i] = i; siz[i] = 1;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x), y = find(y);
	if (x == y)return;
	if (siz[x] < siz[y])swap(x, y);
	par[y] = x;
	siz[x] += siz[y];
}

bool dfs(int now, int c) {
	color[now] = c;
	for(int e:G[now]){
		if (color[e] == c) {
			return false;
		}
		if (color[e] == 0 && !dfs(e, -c))return false;
	}
	return true;
}

signed main() {
	int n, m; cin >> n >> m;
	set<int>S,S1;
	init(n);
	rep(i, m) {
		int u, v; cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
		S.insert(u); S.insert(v);
		unite(u, v);
	}
	rep(i, n)S1.insert(find(i));
	int t1 = 0, t2 = 0, t3 = n-S.size();
	for (auto itr = S1.begin(); itr != S1.end(); itr++) {
		int e = *itr;
		if (G[e].size()) {
			if (dfs(e, 1))t1++; else t2++;
		}
	}

	int ans = 2 * n*t3 - t3*t3;
	ans += t1*t1 * 2;
	ans += (2 * t1*t2 + t2*t2);
	cout << ans << endl;
}

Measured memory_bytes: 16000
#include<iostream>
using namespace std;
int main(){
	int a[6],b;
	char m;
	for(int i=0;i<6;i++){
		cin>>a[i];
	}
	while(cin>>m){
		if(m=='N'){
			b=a[0];
			a[0]=a[1];
			a[1]=a[5];
			a[5]=a[4];
			a[4]=b;
		}else if(m=='E'){
			b=a[0];
			a[0]=a[3];
			a[3]=a[5];
			a[5]=a[2];
			a[2]=b;
		}else if(m=='W'){
			b=a[0];
			a[0]=a[2];
			a[2]=a[5];
			a[5]=a[3];
			a[3]=b;
		}else{
			b=a[0];
			a[0]=a[4];
			a[4]=a[5];
			a[5]=a[1];
			a[1]=b;
		}
	}
	cout<<a[0]<<endl;
	return 0;
}


Measured memory_bytes: 3108
S=gets.chomp.chars.map(&:to_i)
K=gets.to_i

one_count=0
other_num=1

S.each_index {|a|
    if S[a]==1
        one_count+=1
    else
        other_num=S[a]
        break
    end
}

if K<=one_count
    puts 1
else
    p other_num
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(a,b,c) for(int a=b; a<(int)c; a++)
#define REPE(a,b,c) for(int a=b; a<=(int)c; a++)
#define REPD(a,b,c) for(int a=b; a>=(int)c; a--)
#define rep(a,b) REP(a,0,b)
#define repd(a,b) REPD(a,b,0)
typedef long long int ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  rep(i,N){
    int y, m, d;
    cin >> y >> m >> d;
    int ans = 0;
    if((y%3) == 0 || (m&1) == 1){
      //d 20
      ans = 20 -d + 1;
    }else{
      //s 19
      ans = 19 -d + 1;
    }
    if((y%3) == 0){
      ans += (10-m)*20;
    }else{
      ans += (10-m)*20;
      ans -= (10-m+1)/2;
    }
    ans += (999-y)*(20*5+19*5);
    ans += (999-y+2)/3*5;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

#https://atcoder.jp/contests/abc126/tasks/abc126_b

def is_mm(s):
	return int(s) >= 1 and int(s) <= 12

def is_yy(s):
	return True

def main():
	#a = int(input())
	#b , c = IN()
	s = input()
	is_mmxx=is_mm(s[:2])
	is_yyxx=is_yy(s[:2])
	is_xxmm=is_mm(s[2:])
	is_xxyy=is_yy(s[2:])
	ra = 'AMBIGUOUS'
	rb = 'NA'
	rc = 'YYMM'
	rd = 'MMYY'
	
	if is_mmxx and is_xxyy and is_xxmm and is_yyxx:
		return ra
	elif is_mmxx and is_xxyy:
		return rd
	elif is_yyxx and is_xxmm:
		return rc
	else:
		return rb
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62124
/*input
5
11 1 2 4 8
11 1 2 2 8
32 10 8 5 4
29384293847243 454353412 332423423 934923490 1
900000000000000000 332423423 454353412 934923490 987654321
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

ll a,b,c,d;

map<ll,ll> mp;

ll func(ll n){
	if(!n)return 0;
	if(n==1)return d;
	if(mp[n])return mp[n];
	ll ans=LLONG_MAX;
	if(n<(7*1e18)/d)ans=min(ans,n*d);
	if(n%2==0)ans=min(ans,a+func(n/2));
	else{
		ll k=n/2;
		k*=2;
		ans=min(ans,abs(n-k)*d+a+func(k/2));
		k+=2;
		ans=min(ans,abs(n-k)*d+a+func(k/2));
	}
	if(n%3==0)ans=min(ans,b+func(n/3));
	else{
		ll k=n/3;
		k*=3;
		ans=min(ans,abs(n-k)*d+b+func(k/3));
		k+=3;
		ans=min(ans,abs(n-k)*d+b+func(k/3));
	}
	if(n%5==0)ans=min(ans,c+func(n/5));
	else{
		ll k=n/5;
		k*=5;
		ans=min(ans,abs(n-k)*d+c+func(k/5));
		k+=5;
		ans=min(ans,abs(n-k)*d+c+func(k/5));
	}
	return mp[n]=ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	cin>>t;
	while(t--){
		ll n;
		cin>>n>>a>>b>>c>>d;
		mp.clear();
		cout<<func(n)<<endl;
	}
	return 0;
}




Measured memory_bytes: 4452
import itertools

def checker(l):
    a, b, c = l
    if abs(a - b) < c and c < a + b and len(set(l)) == 3:
        return True
    else:
        return False

n = input()
l = [int(i) for i in input().split()]
c = 0
for v in itertools.combinations(l, 3):
    if checker(v) is True:        
        c += 1
print(c)

Measured memory_bytes: 68592
#include <stdio.h>
int main(){

  char b[25],a[500];
  int n,miss,i,j,k,l,blank,result=0;

  scanf("%d",&n);

  scanf("%s",b);

  for(i = 0; i < n; i++){

    for(j = 0; j < 500; j++) a[j]='\0';
    scanf("%s",a);
    blank=0;
    
    for(j = 0; a[j] != '\0'; j++){

      if(blank == 1) break;

      if(a[j] == b[0]){

        for(k = j+1; a[k] != '\0'; k++){

          if(blank == 1) break;          

          if(a[k] == b[1]){

            miss=0;
            for(l = 0; b[l+2] != '\0'; l++){

              if(a[k+k-j+l*(k-j)] != b[l+2] || a[k+k-j+l*(k-j)] == '\0'){

                miss++;
                break;

              }
              
            }

            if(miss == 0){

              result++;
              blank=1;

            }
            
          }

        }

      }

    }

  }

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

  return 0;

}

Measured memory_bytes: 2716
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6;
#define ll long long
int pri[maxn];int vis[maxn];int rec[maxn];int op=0;int t;
void advan(){
     vis[1]=1;
     for(ll i=1;i<=1e6;i++){
        rec[i]=op;if(vis[i])continue;
        vis[op++]=1;rec[i]=op;
        for(ll j=i*i;j<1e6;j=j+i){
            vis[j]=1;
}}}
int main(){
    advan();int n;
    while(scanf("%d",&n)!=EOF){
        printf("%d\n",rec[n]);
    }
}

Measured memory_bytes: 10904
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("avx,avx2,fma,sse,sse2")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

#define N 200007

typedef tree<int, null_type, less<int>,rb_tree_tag,
tree_order_statistics_node_update> new_data;
int main()
{
    ll x,y,m;
    cin>>x>>y>>m;
    map<ll,ll>mp,mp1;
    map<pair<ll,ll>,bool>chk;
    vector<pair<ll,ll>>pai;
    for(ll i=0;i<m;i++)
    {
        ll u,v;
        cin>>u>>v;
        chk[{u,v}]=true;
        mp[u]++;mp1[v]++;
        pai.push_back({u,v});
    }
    ll a=0,b=0,x1,y1;
    for(auto i:pai)
    {
    if(mp[i.first]>a)a=mp[i.first],x1=i.first;
    if(mp1[i.second]>b)b=mp1[i.second],y1=i.second;
    }
    if(chk[{x1,y1}])
        {
            for(auto i:pai)
            {
                if(mp[i.first]==a&&chk[{i.first,y1}]==false){cout<<(a+b)<<endl;return 0;}
                if(mp1[i.second]==b&&chk[{x1,i.second}]==false){cout<<(a+b)<<endl;return 0;}
            }
            cout<<(a+b)-1<<endl;
        }
    else cout<<a+b<<endl;
}
//33 44
//2 2
//2 3
//2 5
//2 4
//3 3
//5 3
//7 3


Measured memory_bytes: 64312
#include <iostream>
#include <vector>
#include <complex>
#include <utility>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
using namespace std;
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;i++)
typedef complex<double> C;

struct L :public vector<C>
{
    L(){}
    L(const C a, const C b){
        push_back(a);push_back(b);
    }
};
double cross(const C a,const C b){
    return imag(conj(a)*b);
}
double dot(const C a,const C b){
    return real(conj(a)*b);
}
int ccw (C a, C b, C c){
    b -=a; c -=a;
    if(cross(b,c)>0 )return +1;
    if(cross(b,c)<0) return -1;
    if(dot(b,c) < 0) return 2;
    if(norm(b)<norm(c)) return -2;
    return 0;
}

bool intersectSS(const L& s,const L &t){
    return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0;
}

template<typename T> class Dijkstra{
    public:
    struct edge{
        int to; T cost;
    };
    int V;
    vector<vector<edge> > G;
    vector<T> d;
    using pti = pair<T,int>;
    Dijkstra(int node_size) : V(node_size),G(V),d(V,numeric_limits<T>::max()){}
    void add_edge(int u,int v,T cost){
        G[u].push_back((edge){v,cost}),G[v].push_back((edge){u,cost});
    }
    void solve(int s){
        priority_queue<pti,vector<pti>,greater<pti> > que;
        d[s] = 0;
        que.push(pti(0,s));
        while(!que.empty()){
            pti p = que.top();
            que.pop();
            int v = p.second;
            if(d[v] < p.first) continue;
            for(auto& w : G[v]){
                if(d[w.to] > d[v]+w.cost){
                    d[w.to] = d[v] + w.cost;
                    que.push(pti(d[w.to],w.to));
                }
            }
        }
    }
};


int main(){
    int a,b;
    cin >> a >> b;
    vector<complex<double> >x(a),y(b);
    for(int i=0;i<a;i++){
        double p,q;
        cin >> p >> q;
        x[i] = C(p,q);
    }
    for(int i=0;i<b;i++){
        double p,q;
        cin >> p >> q;
        y[i] = C(p,q);
    }
    Dijkstra<double> gx(a),gy(b);
    for(int i=0;i<a;i++){
        for(int j=i+1;j<a;j++){
            if(!intersectSS(L(y[0],y[1]),L(x[i],x[j]))){
                gx.add_edge(i,j,sqrt(dot(x[i]-x[j],x[i]-x[j])));
            }
        }
    }
    for(int i=0;i<b;i++){
        for(int j=i+1;j<b;j++){
            if(!intersectSS(L(x[0],x[1]),L(y[i],y[j]))){
                gy.add_edge(i,j,sqrt(dot(y[i]-y[j],y[i]-y[j])));
           }
        }
    }
    double ans = 0.0;
    gx.solve(0);
    gy.solve(0);
    ans = sqrt(dot(x[0]-x[1],x[0]-x[1])) + gy.d[1];
    ans = min(ans,sqrt(dot(y[0]-y[1],y[0]-y[1])) + gx.d[1]);
    if(ans<1000000000.00)cout <<fixed << setprecision(15) << ans << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 37056
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//long long A,B;
bool ok(long long key,long long index,vector<long long> &retu){
    if(retu.at(index) > key) return true;
    else if(retu.at(index) <= key) return false;
}
long long binary_search(long long key,long long size,vector<long long> &retu){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        bool hantei = ok(key,mid,retu);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

//leftは条件を満たさない最大の値、rightは条件を満たす最小の値になっている

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    long long ans = 0;
    for(long long i = 1;i<=N;i++){
        long long times = N/i;
        ans += i*(times*(times+1))/2;
    }
    cout << ans << endl;
}


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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
	ll n, m;
	cin >> n >> m;
	int ans = 0;
	for(int i = 1; i * i <= m;  i++)
	{
		if(m % i != 0)
			continue;
		int j = m / i;
		if(i >= n)
			umax(ans, j);
		if(j >= n)
			umax(ans, i);
	}
	cout << ans;




	





	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
s = ns()

now = s[1:].count("E")
ans = now
for spre, si in zip(s[:-1], s[1:]):
    if spre == "W":
        now += 1
    if si == "E":
        now -= 1
    ans = min(ans, now)

print(ans) 



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

int main(){
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0; i < s.size(); i+=2){
        if(s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D'){
            count++;
        }
    }
    for(int i = 1; i < s.size(); i+=2){
        if(s.at(i) == 'L' || s.at(i) == 'U' || s.at(i) == 'D'){
            count++;
        }
    }
    if(count == s.size()){
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define size 12

char input[16][16];
int table[16][16];

void init(void) {
	memset(table, 0, sizeof(table));
	memset(input, 0, sizeof(input));
}

void check(int i, int j) {
	if(table[i][j])
		return;

	if(input[i][j] == '1')
		table[i][j] = 1;
	else
		return;

	if(i != 0)
		check(i - 1, j);
	if(i != size - 1)
		check(i + 1, j);
	if(j != 0)
		check(i, j - 1);
	if(j != size - 1)
		check(i, j + 1);

	return;
}

int main(void) {
	int i, j;
	int ans;

	do {
		init();
		for(i = 0; i < size; i++)
			fgets(input[i], 16, stdin);
		ans = 0;

		for(i = 0; i < size; i++) {
			for(j = 0; j < size; j++) {
				if(input[i][j] == '1' && !table[i][j]) {
					check(i, j);
					ans++;
				}
			}
		}

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

	} while(getchar() != EOF);

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i = x;i < y;i++)
using namespace std;
int main(){
  string O,E;
  cin >> O >> E;
  FOR(i,0,E.size()){
    cout << O[i];
    cout << E[i];
  }
  if(O.size() - E.size())cout << O[O.size()-1];
  cout << endl;
}


Measured memory_bytes: 256
//参考１：char＜＝＞string  https://qiita.com/shusakuorz/items/d24bd33ff7ea0c2b0024
//参考２：.Replaceメソッド　https://www.sejuku.net/blog/47953
using System;

public class ABC76C{
  public static int index_key;
  
  public static bool isMatch(string ss, string tt){
    int i, j;
    index_key = -1;
    
    for(i = 0 ; i < (ss.Length - tt.Length + 1) ; i++){//~~~~~~
      for(j = 0 ; j < tt.Length ; j++){
        if( ss[i+j] != tt[j] && ss[i+j] != '?'){
          break;
        }
      }
      if( j == tt.Length ){
        index_key = i;
      }
    }//~~~~~~
    
    if(index_key != -1){
      return true;
    }
    
    return false;
  }
  
  public static string restoration(string ss, string tt){
    
    String ss_a = ss.Replace("?", "a");//?をaに置き換える
    //for(int i = 0; i < ss.Length ; i++){
    //  if(ss[i] == '?'){
        //ss[i] = 'a'; //これはエラー        
    //  }
    //}
    
    char[] cs = ss_a.ToCharArray();
    char[] ct = tt.ToCharArray();
    
    for(int i = 0 ; i < tt.Length ; i++){
      cs[i + index_key] = ct[i];
    }
    string cnt = new String(cs);
    
    return cnt;
  }
  
  public static void Main(){
    string s = Console.ReadLine();
    string t = Console.ReadLine();
    
    if(!isMatch(s, t)){
      Console.WriteLine("UNRESTORABLE");
    }
    else{
      Console.WriteLine(restoration(s, t));
    }
    
    
  }
}

Measured memory_bytes: 13140
N=int(input())
name=[input()[0] for _ in range(N)]
m=name.count("M")
a=name.count("A")
r=name.count("R")
c=name.count("C")
h=name.count("H")
print(m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h)

Measured memory_bytes: 3864
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }







void solve() {
    ll n;
    ll a[100010];
    cin>>n;
    rep(i,n) cin>>a[i];
    ll ans=0;
    rep(i,n){
        rep2(j,i+1,n){
            rep2(k,j+1,n){
                ll sum=a[i]+a[j]+a[k];
                if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]){
                    ll s=max(a[i],max(a[j],a[k]));
                    if(sum-s > s) ans++;
                }
            }
        }
    }
    cout<<ans<<endl;

}






signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    rep(i,t){
        solve(); 
    }


    return 0;
}

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


int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
	int n,m;
	cin>>n>>m;
	vector<int> hills(n+1);
	vector<bool> good(n+1, true);
	good[0] = false;
	hills[0] = -1;
	for(int i = 1; i <= n; i++) {
		cin>>hills[i];
	}

	for(int i = 0 ; i < m; i++) {
		int a,b;
		cin>>a>>b;
		if(hills[a] < hills[b])
			good[a] = false;
		else if(hills[a] > hills[b])
			good[b] = false; 
		else {
			good[a] = false;
			good[b] = false;
		}
	}

	int count = 0;
	for(int i = 1; i <= n; i++) {
		if(good[i]) {
			// cout<<i<<" ";
			count++;
		}
	}

	cout<<count;


	return 0;		
}


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

int F(ll a, ll b){
    int digit = 0;
    while(a != 0 || b != 0){
        a /= 10;
        b /= 10;
        digit++;
    }
    return digit;
}

int main() {

    ll n;
    cin >> n;

    int ans = INT_MAX;
    for(ll i=1; i*i<=n; i++){
        if(n % i == 0){
            int tmp = F(i, n/i);
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  
  cin >> a >> b;
  
  int c = a * b % 2;
  
  if (c == 0){
      cout << "Even";
  }
  else{
      cout << "Odd"; 
  }
}

Measured memory_bytes: 256
n=int(input())
s=input()
ans=0
tmp=0
for i in range(n-1):
  for j in range(i+2,n+1):
    if j-i>ans:
      if s[i:j] in s[j:]:
        tmp=j-i
      else:
        ans=max(tmp,ans)
        break
ans=max(tmp,ans)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

//AtCoder Beginner Contest 124
//C	Coloring Colorfully
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();

		sc.close();

		int ans0 = 0;

		if (S.length() > 1) {
			char pre = '0';
			for (int i = 0; i < S.length(); i++) {
				char c = S.charAt(i);
				if (pre == c) {
					ans0++;
					if (c == '0') {
						pre = '1';
					} else {
						pre = '0';
					}
				} else {
					pre = c;
				}
			}
		}

		int ans1 = 0;

		if (S.length() > 1) {
			char pre = '1';
			for (int i = 0; i < S.length(); i++) {
				char c = S.charAt(i);
				if (pre == c) {
					ans1++;
					if (c == '0') {
						pre = '1';
					} else {
						pre = '0';
					}
				} else {
					pre = c;
				}
			}
		}

		int ans = Math.min(ans0, ans1);

		System.out.print(ans);
	}
}


Measured memory_bytes: 28092
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


a, b = [int(_) for _ in input().split()]
a_l = list(set(prime_factorize(a)))
b_l = list(set(prime_factorize(b)))
ans_l = []
for n in a_l:
    if n in b_l:
        ans_l.append(n)

print(len(ans_l) + 1)


Measured memory_bytes: 38512
package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	input := bufio.NewReader(os.Stdin)
	var N int
	fmt.Fscanf(input, "%d\n", &N)
	A := make([]int, N+1)
	for i := 0; i < N+1; i++ {
		fmt.Fscanf(input, "%d", &A[i])
	}
	fmt.Fscanf(input, "\n")
	B := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Fscanf(input, "%d", &B[i])
	}
	fmt.Fscanf(input, "\n")

	var ans int
	for i := 0; i < N; i++ {
		if A[i] > B[i] {
			ans += B[i]
			A[i] -= B[i]
		} else {
			ans += A[i]
			B[i] -= A[i]
			A[i] = 0

			if A[i+1] > B[i] {
				ans += B[i]
				A[i+1] -= B[i]
			} else {
				ans += A[i+1]
				B[i] -= A[i+1]
				A[i+1] = 0
			}
		}
	}
	fmt.Println(ans)
}


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

//---------------------------------------------------------------------------------------------------------
#define error( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) {
    vector<string> v;
    stringstream ss( s);
    string x;
    while ( getline( ss, x, c))
        v.emplace_back( x);
    return move( v);
}
void err( vector<string>::iterator it) { }
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t';
    err( ++it, args...);
}
//----------------------------------------------------------------------------------------------------------

#define pb push_back
#define pfr push_front
#define eb emplace_back
#define ef emplace_front
#define fi first
#define se second
#define mp make_pair
#define fr(i,j,k) for(i = j; i < (k); i++)
#define bck(i,j,k) for(i = j; i > (k); i--)
#define all(x) x.begin(), x.end()
#define el '\n'

typedef long long int ll;
typedef long double DO;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
//---------------------------  TEMPLATE ENDS, MAKE CHANGES FROM HERE ----------------------------------------

const int mod = 1e9+7;
const ll inf = 2e18;
const DO eps = 1e-9;
const int NN = 1e5 + 2;

int to[200], inv[200];

void solve(){
    int i = 0, j = 0, k = 0, n = 0, m = 0;
    string s, t;
    cin >> s >> t;
    n = s.size();
    for(i = 0; i < n; i++){
        if( to[s[i]] ) {
            if(to[s[i]] != t[i])  {
                cout  << "No";
                return;
            }
        }
        to[s[i]] = t[i];
        if(inv[t[i]]) {
            if(inv[t[i]] != s[i])
                 {
                     cout << "No";
                     return;
                 }
        }
        inv[t[i]] = s[i];
    }
    cout << "Yes";
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T = 1, tc;
    fr(tc, 1, T+1){
        solve();
    }
    return 0;
}
/* The judge is never wrong! Your code is buggy 😈
   Look for:
 * * an easier and alternate approach
 * * if concept is corret and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
 */



Measured memory_bytes: 916
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

char s[55][55];
int memo[55][55];
int pre[10000];
int board[55][55];
vector<int> path;

int main() {

	int H,W;

	scanf("%d %d",&H,&W);

	int i,j;

	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			scanf(" %c",&s[i][j]);
		}
	}

	queue<pair<int,int> >q;
	q.push(make_pair(0,0));

	int flag=0;

	while (!q.empty()) {
		pair<int,int> now = q.front();
		q.pop();

		if(now.first==H-1&&now.second==W-1){
		flag=1;
		break;
		}

		int dx[4]={-1,0,0,1};
		int dy[4]={0,-1,1,0};
		for(i=0;i<4;i++){
			int next_y=now.first+dy[i];
			int next_x=now.second+dx[i];
			if(0<=next_y&&next_y<H&&0<=next_x&&next_x<W && s[next_y][next_x]=='.' &&memo[next_y][next_x]==0){
				q.push(make_pair(next_y,next_x));
				memo[next_y][next_x]=1;
				pre[(next_y*W)+next_x]=(now.first*W)+now.second;
			}
		}
	}

	if(flag==0){
	printf("-1\n");
	}
	else{
		int t=(H*W)-1;
		int start=0;
		for (; t != start; t = pre[t]) {path.push_back(t);}
		path.push_back(start);
		reverse(path.begin(),path.end());
		for(i=0;i<path.size();i++){
			board[path[i]/W][path[i]%W]=1;
		}
		int ans=0;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(board[i][j]==0&&s[i][j]=='.'){
				ans++;
				}
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

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...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll l, r;
    cin >> l >> r;
    int MAX = 1 << 16;
    vector<bool> isPrime(MAX, true);
    isPrime[0] = isPrime[1] = false;
    vector<vector<int>> cands(r - l + 1);
    REP(i, 2, MAX) {
        if (isPrime[i]) {
            for (int j = 2 * i; j < MAX; j += i) {
                isPrime[j] = false;
            }
            for (ll j = ((l + i - 1) / i) * i; j <= r; j += i) {
                cands[j - l].push_back(i);
            }
        }
    }
    ll ans = 0;
    REP (i, 0, cands.size()) {
        if (cands[i].size() == 0) continue;
        ll n = i + l;
        int cnt = 0;
        for(int &e: cands[i]) {
            while (n % e == 0) {
                n /= e;
                cnt++;
            }
        }
        if (n != 1) {
            cnt++;
        }
        ans += isPrime[cnt];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 59472