akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n,m,l;
    cin >> n >> m >> l;
    int a[n][m];
    int b[m][l];
    rep(i,n){
        rep(j,m) cin >> a[i][j];
    }
    rep(i,m){
        rep(j,l) cin >> b[i][j];
    }
    vector<vector<ll>> c(n,vector<ll>(l,0));
    rep(i,n){
        rep(j,l){
            rep(k,m) c[i][j] += a[i][k] * b[k][j];
        }
    }
    
    rep(i,n){
        rep(j,l){
             cout << c[i][j];
             if(j != l-1) cout << " ";
        }
        cout << endl;
    }
return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int K = nextInt();
  vector<int> a(N);
  REP(i, N) a[i] = nextInt();
  map<int, int> count;
  for (auto x : a) count[x]++;
  vector<int> cs;
  for (auto it = count.begin(); it != count.end(); ++it) {
    cs.push_back( it -> second );
  }
  sort(ALL(cs));
  reverse(ALL(cs));
  int topK = 0;
  REP(i, min<int>(K, cs.size())) topK += cs[i];
  int ans = N - topK;
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 11516
def encrypt(text,s):
  result = ""
  for i in range(len(text)):
    char = text[i]
    if (char.isupper()):
        result += chr((ord(char) + s-65) % 26 + 65)
  return result
n = int(input())
s = str(input())
print(encrypt(s, n))

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

int main() {
  int a, b, c, x;
  int ret = 0;
  
  cin >> a >> b >> c >> x;
  
  for(int i = 0; i <= a; ++i) {
    for(int j = 0; j <= b; ++j) {
      for(int k = 0; k <= c; ++k) {
        if(500 * i + 100 * j + 50 * k == x) {
          ++ret;
        }
      }
    }
  }
  
  cout << ret;
  
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
 
N, Q = map(int, input().split())
ab=[]
for _ in range(N-1):
    ab.append(tuple(map(int, input().split())))
px=[]
for _ in range(Q):
    px.append(tuple(map(int, input().split())))
 
cnt=[0]*(N+1)
for el in px:
    cnt[el[0]] += el[1]
#print(cnt)
 
 
lst=[[] for _ in range(N+1)]
for el in ab:
    lst[el[0]].append(el[1])
    lst[el[1]].append(el[0])
#print(lst)
 
seen = set()
def dfs(n):
    seen.add(n)
    for child in lst[n]:
        if child not in seen:
            cnt[child]+=cnt[n]
            dfs(child)
 
dfs(1)
#print(cnt)
print(' '.join(list(map(str, cnt[1:]))))

Measured memory_bytes: 276160
//url:https://atcoder.jp/contests/abc054/tasks/abc054_c
//problem name:C - One-stroke Path

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

void print_vec(vector<int> vec) {
    cout << "{";
    for(auto s: vec) cout << s << " ";
    cout << "}" << endl;
}

int main() {
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N,vector<int>());
    vector<int> num(N);

    for(int i = 0; i < N; i++) num.at(i) = i; 

    rep(i,M) {
        int a,b;
        cin >> a >> b;
        G.at(a-1).push_back(b-1);
        G.at(b-1).push_back(a-1);
    }

    int ans = 0;

    do {
        if(num.at(0) != 0) break;
        //print_vec(num);
        bool ok = true;
        for(int i = 0; i < N-1;i++) {
            vector<int> g = G.at(num[i]);
            if(count(g.begin(),g.end(),num[i+1]) == 0) ok = false;
        }
        if(ok) ans++;
    } while(next_permutation(num.begin(),num.end()));

    cout << ans << endl;


}


Measured memory_bytes: 256
import math
K, A, B = map(int, input().split())
ans = 0
if K - A + 1 < 2:
    ans = K + 1
elif (K - A + 1) % 2 == 0:
    if B+(B-A) * (math.floor((K - A + 1) / 2)-1) > K + 1:
        ans = B+(B-A) * (math.floor((K - A + 1) / 2)-1)
    else:
        ans = K + 1
else:
    if B+(B-A) * (math.floor((K - A + 1) / 2)-1) + 1 > K + 1:
        ans = B+(B-A) * (math.floor((K - A + 1) / 2)-1) + 1
    else:
        ans = K+1
print("{}".format(ans))


Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstdio>
using namespace std;

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root ,*NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = new Node;
    z ->key = k;
    z ->left = NIL;
    z ->right = NIL;

    while (x != NIL){
        y = x ;
        if (z -> key < x -> key){
            x = x -> left;
        } else{
            x = x -> right;
        }
    }
    z -> parent = y;
    if(y == NIL){
        root = z;
    }else{
        if (z -> key < y -> key){
            y -> left = z;
        }else{
            y -> right = z;
        }
    }
}

void inorder (Node *u){
    if(u == NIL) return;
    inorder(u->left);
    cout << " " << u -> key;
    inorder(u->right);
}

void preorder (Node *u){
    if(u == NIL) return;
    cout << " " <<u->key;
    preorder(u->left);
    preorder(u->right);
}

Node * find(Node *u,int k){
    while (u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}
int main(){
    int n,x;
    string com;
    cin >> n;

    for (int i = 0; i < n ; ++i) {
        cin >> com;
        if(com == "insert"){
            cin >> x;
            insert(x);
        }else if(com == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }else if(com == "find"){
            cin >> x;
            Node *t = find(root,x);
            if (t != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19960
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

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

    string s;
    cin >> s;

    int K;
    cin >> K;

    set<string> v;

    for(int i=0; i < s.size(); i++) {

        string current = "";

        for (int j=1; j <= 10; j++) {

            int pos = (i + j - 1);

            if (pos < s.size()) {
                current += s[pos];
                v.insert(current);
            } else {
                break;
            }

        }
    }

    vector<string> vv(v.begin(), v.end());
    cout << vv[K-1] << endl;
    return 0;
}

Measured memory_bytes: 4480
N=int(input())

A=list(map(int,input().split()))
ans=A[0]

if 0 in A:
    print(0)
    exit()

for cnt in range(N-1):
    ans = ans * A[cnt+1]
    if ans > 1000000000000000000:
        break
    elif ans == 0:
        break
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21500
import java.util.Scanner;

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

		String W = sc.nextLine();
		String T;
		
		String[] strArray;

		int count=0;
		String delete;

		while (sc.hasNextLine()) {
		    T =sc.nextLine().toLowerCase();
		    strArray = T.split(" ");
	 		for(String str : strArray) {
    			if(str.equals(W)) {
    				count++;
    			}
		}
		}

		System.out.println(count);

	}
}


Measured memory_bytes: 26100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,d,x[15][15];
	cin>>n>>d;
	for(int i=0;i<n;i++)for(int j=0;j<d;j++)cin>>x[i][j];
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ll num=0;
			for(int k=0;k<d;k++)num+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			ll p=sqrt(num);
			p*=p;
			if(p==num)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
//
// Created by ryo on 2019/11/23.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    int a,b;
    int ans = 0;
    cin >> a >> b;
    if (a == 1) {
        ans += 300000;
    } else if (a == 2) {
        ans += 200000;
    } else if (a == 3) {
        ans += 100000;
    }

    if (b == 1) {
        ans += 300000;
    } else if (b == 2) {
        ans += 200000;
    } else if (b == 3) {
        ans += 100000;
    }

    if (a == 1 && b == 1) {
        ans += 400000;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)

const int H = 22;
int n, m;

signed main() {
	for (; cin >> n >> m && n;) {
		int ans = 0;
		vector<bitset<501>> b(n);
		vector<int> bb(n);
		rep(i, 0, n) {
			rep(j, 0, m) {
				char c; cin >> c;
				b[i] <<= 1;
				b[i] |= c - '0';
				bb[i] *= 2;
				bb[i] |= c - '0';
			}
		}
		if (n <= H) {
			rep(mask, 0, 1 << n) {
				bitset<501> x = 0;
				int cnt = 0;
				rep(i, 0, n) {
					if (mask >> i & 1) {
						x ^= b[i];
						cnt++;
					}
				}
				if (x == 0) {
					ans = max(ans, cnt);
				}
			}
		}
		else {
			vector<int> dp(1 << m, -1),
				ndp;
			dp[0] = 0;
			rep(i, 0, n) {
				ndp = dp;
				rep(j, 0, 1 << m) {
					if (dp[j] != -1)
						ndp[j ^ bb[i]] = max(ndp[j ^ bb[i]], dp[j] + 1);
				}
				swap(dp, ndp);
			}
			ans = dp[0];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 19320
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 500050
int n,d,q,i,a[N];
long long f[N];
bool b[N];
inline int rd()
{
	char ch=getchar();int ret=0;
	while (ch<'0' || ch>'9') ch=getchar();
	while (ch>='0' && ch<='9') ret=(ret<<3)+(ret<<1)+ch-'0',ch=getchar();
	return ret;
}
int main()
{
	n=rd();d=rd();
	for (i=1;i<=n;i++) a[i]=rd();
	f[n]=1;
	for (i=n-1;i>=1;i--) if (f[i+1]<=(a[i+1]>>1)) f[i]=f[i+1];
	else f[i]=f[i+1]+a[i+1];
	for (i=1;i<=n;i++){
		if (f[i]<=d) b[i]=true;else b[i]=false;int psz=abs(d-a[i]);if (psz<d) d=psz;
	}q=rd();
	while (q--){
		int x=rd();
		if (b[x]) puts("YES");else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int fir,sec;
bool f,s;
int main(){
    scanf("%2d%2d",&fir,&sec);
    if(1<=fir&&fir<=12) f=1;
    if(1<=sec&&sec<=12) s=1;
    if(f&&s) cout<<"AMBIGUOUS"<<endl;
    else if(f) cout<<("MMYY")<<endl;
    else if(s) cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
  return 0;
}

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

int D, n, m;
vector<int> d;
vector<int> e;
int ans;

int main(){
	while(1){
		d = e;
		ans = 0;
		scanf("%d", &D);
		if(D == 0) break;
		scanf("%d %d", &n, &m);
		d.push_back(0);
		d.push_back(-D);
		d.push_back(D);
		for(int i=0; i<n-1; i++){
			int t;
			scanf("%d", &t);
			d.push_back(t);
			d.push_back(t-D);
			d.push_back(t+D);
		}
		sort(d.begin(), d.end());

		for(int i=0; i<m; i++){
			int t;
			scanf("%d", &t);
			int u, l;
			u = *upper_bound(d.begin(), d.end(), t) - t;
			l = t - *(lower_bound(d.begin(), d.end(), t)-1);
			if(*lower_bound(d.begin(), d.end(), t) == t) l = 0;
			ans += min(u, l);
		}

		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4456
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y<=0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
int h[105],g[105];
inline int add(int x,int y){
	return (x+y)%mod;
}
inline int mul(int x,int y){
	return x*y%mod;
}
inline int sub(int x,int y){
	return (x-y+mod)%mod; 
}
pair<int,int>operator*(pair<int,int>a,pair<int,int>b){
	a.first=mul(a.first,add(b.first,b.second));
	a.second=mul(a.second,b.second);
	return a;
}
pair<int,int>solve(int l,int r){
	int low=*min_element(h+l,h+r+1);
	int cnt=0;
	for(int i=l;i<=r;i++)h[i]-=low;
	for(int i=l;i<=r;i++)if(!h[i])cnt++;
	int L=l,R=l;h[r+1]=0;
	pair<int,int>ret(modpow(2,cnt),2);
	for(int i=l;i<=r+1;i++){
		R=i-1;
		if(h[i]==0){
			if(L<=R)ret=ret*solve(L,R);
			L=i+1;
		}
	}
	ret.first=sub(ret.first,ret.second);
	ret.second=mul(ret.second,modpow(2,low-1));
	ret.first=add(ret.first,ret.second);
	return ret;
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	cout<<solve(1,n).first<<endl;
	return 0;
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [a,b] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ a * b


Measured memory_bytes: 3772
#include <stdio.h>

int main()
{
    int n[100], x[100];
    int i, j, k, l;
    int cnt[100];

    for(l = 0; l < 100; l++){
        scanf("%d %d", &n[l], &x[l]);
        if(n[l] == 0 && x[l] == 0){
            break;
        }
    }

    for(l = 0; l < 100; l++){
        cnt[l] = 0;
        if(n[l] == 0 && x[l] == 0){
            break;
        }else if(n[l] >= 3 && n[l] <= 100){
            for(i = 1; i <= n[l] - 2; i++){
                for(j = i + 1; j <= n[l]; j++){
                    for(k = j + 1; k <= n[l]; k++){
                        if(i + j + k == x[l]){
                                cnt[l]++;
                        }
                    }
                }
            }
        }
        printf("%d\n", cnt[l]);
    }

    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	cin >> n;
	vector<pair<LL, LL>> v(n);
	inc(i, n) { cin >> v[i].FI >> v[i].SE; }
	
	inc(i, n) { v[i].FI *= -1; }
	sort(ALL(v));
	inc(i, n) { v[i].FI *= -1; }
	
	vector<pair<LL, LL>> w;
	{
		LL rmi = 2e9;
		inc(i, n) { if(setmin(rmi, v[i].SE)) { w.PB(v[i]); } }
	}
	reverse(ALL(w));
	
	assert(SI(w) > 0);
	
	LL max_len = 0;
	inc(i, n) { setmax(max_len, v[i].SE - v[i].FI + 1); }
	
	LL ans = max_len + max(0LL, w.front().SE - w.back().FI + 1);
	LL R1 = w.front().SE;
	LL L2 = w.back().FI;
	inc(i, SI(w) - 1) {
		LL L1 = w[i    ].FI;
		LL R2 = w[i + 1].SE;
		setmax(ans, (R1 - L1 + 1) + (R2 - L2 + 1));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3956
def main():
    n = int(input())
    for i in range(n):
        Array = list(map(int,input().split()))
        Array.sort()
        if Array[2]**2 == Array[0]**2 + Array[1]**2:
            print("YES")
        else:
            print("NO")

if __name__ == '__main__':
    main()

Measured memory_bytes: 5604
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cout << #x << " = " << x << endl;
 
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
 
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();    
    return 0;
}
 
const int MOD = 998244353, MAXN = 5e5 + 10, INF = 1e18 + 10, BASE = 37; 

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    vec<int> a(n), b(m);
    cin >> a >> b;

    for (int i = 1; i < n; ++i) {
        a[i] = a[i - 1] + a[i];
    }
    for (int i = 1; i < m; ++i) {
        b[i] = b[i - 1] + b[i];
    }

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= k) {
            cnt = i + 1;
        }
    }
    for (int i = 0; i < m; ++i) {
        if (b[i] <= k) {
            cnt = max(cnt, i + 1);
        }
    }

    for (int i = 0; i < n; ++i) {
        int r = k - a[i];
        int id = upper_bound(all(b), r) - b.beg();
        if (id != 0) {
            cnt = max(cnt, i + 1 + id);
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 6316
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int n;
vector<int> v[201];
bool check(int i){

    int col[201];
    rep(j,201)col[j]=-1;
    queue<int> q;
    q.push(i);
    col[i]=0;

    int color = 1;
    while(!q.empty()){
        int sum = q.size();
        rep(j,sum){
            int t = q.front();
            q.pop();
         rep(l,v[t].size()){
             int x = v[t][l];
             if(col[x]==col[t]){
                 return false;
             }else{
                 if(col[x]==-1){
                     q.push(x);
                 }
                 if(col[t]==1){
                     col[x]=0;
                 }else{
                     col[x]=1;
                 }
             }
         }
        }

    }
    return true;




}

int main(){
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        rep(j,s.size()){
            if(s[j]=='1'){
                v[i].push_back(j);
            }
        }
    }
    if(!check(0)){
        cout<<-1<<endl;
        return 0;
    }


    int anss = -1;
    for(int ii=0;ii<n;ii++) {
        vector<bool> al(n,false);
        int ans = 1;
        al[ii] = true;
        set<int> s;
        s.insert(ii);
        queue<int> q;
        q.push(ii);
        set<int> pre;
        pre.insert(ii);

        while (true) {
            set<int> nowp;

            bool f = true;
            int sum = q.size();
            for (int i = 0; i <sum; i++) {
                int now = q.front();
                q.pop();
                rep(j, v[now].size()) {
                    int t = v[now][j];
                    if(pre.find(t)!=pre.end()){
                        ans = -1;
                        f=true;
                        break;
                    }
                    if (!al[t]) {
                        al[t] = true;
                        f = false;
                        q.push(t);
                        nowp.insert(t);
                    }
                }
            }

            if (f) {
                break;
            } else {
                ans++;
                pre=nowp;
            }
        }


        anss=max(anss,ans);
    }
    cout<<anss<<endl;










    
return 0;
}


Measured memory_bytes: 3760
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	string s;
	cin >> n >> s;
	vector<bool> d(2 * n);
	ll left = 0, right = 0;
	for (int i = 0; i < 2 * n; i++) {
		d[i] = s[i] == 'W';
		if (i % 2 == 0) d[i] = !d[i];
		if(d[i]){
			left++;
		}else {
			right++;
		}
	}
	if(left != right){
		dump(0);
		return 0;
	}
	ll ans = 1;
	ll cnt = 0;
	for (int i = 0; i < 2 * n; i++) {
		if (d[i])
			cnt++;
		else {
			ans *= cnt;
			cnt--;
		}
		if(cnt < 0){
			dump(0);
			return 0;
		}
		ans %= MOD;
	}
	for (int i = 1; i <= n; i++) {
		ans *= i;
		ans %= MOD;
	}
	dump(ans);

	return 0;
}

Measured memory_bytes: 720
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int n = sc.nextInt();
		int k = sc.nextInt() - 1;
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < n - k; i++) {
			int d = h[i + k] - h[i];
			if(min > d) min = d;
		}
		System.out.println(min);
	}
	Main(){doIt();}
	public static void main(String[] args) {
		new Main();
	}

}


Measured memory_bytes: 50124
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int s=stdIn.nextInt(),a=0;
		do {
			if(s%10==1) a++;
			s/=10;
		}while(s!=0);
		System.out.print(a);
	}
}

Measured memory_bytes: 22228
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    vector<int> ok(N, 0);
    rep(i, K) {
        cin >> D[i];
        rep(j, D[i]) {
            int a;
            cin >> a;
            a--;
            ok[a] = 1;
        }
    }
    int res = 0;
    rep(i, N) {
        if(ok[i] == 0) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
import sys
from collections import defaultdict
from heapq import *

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    to = defaultdict(list)
    n, m = map(int, input().split())
    for _ in range(m):
        l, r, c = map(int, input().split())
        l, r = l - 1, r - 1
        to[l].append([r, c])
    costs = [-1] * n
    hp = []
    heappush(hp, [0, 0])
    while hp:
        # print(hp)
        c, u = heappop(hp)
        if u == n - 1:
            print(c)
            # print(costs)
            exit()
        if costs[u] != -1: continue
        costs[u] = c
        for v, dc in to[u]:
            if costs[v] != -1: continue
            heappush(hp, [c + dc, v])
        for v in range(u - 1, 0, -1):
            if costs[v] != -1: break
            heappush(hp, [c, v])
    print(-1)

main()


Measured memory_bytes: 52304
#include <cmath>
#include <iostream>

#pragma warning(disable : 4996)

int x, y, q, r1, r2, ok[10][10];

int main()
{
	while (~scanf("%d,%d,%d", &x, &y, &q))
	{
		if (q == 1)
		{
			for (int i = -1; i <= 1; i++)
			{
				for (int j = -1; j <= 1; j++)
				{
					if (abs(i) + abs(j) <= 1)
					{
						if (0 <= x + j && x + j < 10 && 0 <= y + i && y + i < 10)
						{
							ok[y + i][x + j]++;
						}
					}
				}
			}
		}

		if (q == 2)
		{
			for (int i = -1; i <= 1; i++)
			{
				for (int j = -1; j <= 1; j++)
				{
					if (0 <= x + j && x + j < 10 && 0 <= y + i && y + i < 10)
					{
						ok[y + i][x + j]++;
					}
				}
			}
		}

		if (q == 3)
		{
			for (int i = -2; i <= 2; i++)
			{
				for (int j = -2; j <= 2; j++)
				{
					if (abs(i) + abs(j) <= 2)
					{
						if (0 <= x + j && x + j < 10 && 0 <= y + i && y + i < 10)
						{
							ok[y + i][x + j]++;
						}
					}
				}
			}
		}
	}

	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			if (ok[i][j] == 0)
			{
				r1++;
			}

			if (ok[i][j] > r2)
			{
				r2 = ok[i][j];
			}
		}
	}

	printf("%d\n", r1);
	printf("%d\n", r2);

	return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int, int>
#define pll pair<ll , ll>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define N 200005
#define INF 1000000000000000


int main()
{   
    fastio
    int n;
    cin>>n;
    int w;
    cin>>w;
    vector<pll> arr(n);
    ll sum =0;
    for(int i = 0 ; i<n;i++)
    {   
        int a , b;
        cin>>a>>b;
        sum += b;
        arr[i] = mpi(a , b);
    }

    ll dp[n+1][sum+1];

    for(int i = 0 ; i<=n;i++)
        for(int j = 0 ; j<=sum;j++)
            dp[i][j] = 1e14;

    for(int i = 0 ; i<=w;i++)dp[0][0] = 0;
    for(int i = 1 ;i<=n;i++)
    {   
        
        for(int j =0;j<=sum;j++)dp[i][j] = dp[i-1][j]; 

        for(int j = arr[i-1].S ; j<=sum;j++)
        {
            dp[i][j] = min(dp[i-1][j-arr[i-1].S] + arr[i-1].F , dp[i][j]);
        }

        for(int j = sum-1 ; j >=0;j--)
        {
            dp[i][j] = min(dp[i][j] , dp[i][j+1]);
        }
    }

    int ans = 0;
    for(int i = 0 ;i<=sum;i++)
    {
        if(dp[n][i] <= w)ans = max(ans , i);
    }

    // for(int i = 0 ; i<=n;i++)
    // {
    //     for(int j = 0 ;j<=sum;j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }

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

Measured memory_bytes: 79232
#include <iostream>

using namespace std;

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

int gcd3(int a, int b, int c)
{
	return gcd(gcd(a, b), c);
}

int main() {

	int K;
	cin >> K;

	long long sum = 0;

	for (int i = 1; i <= K; ++i)
	{
		for (int j = 1; j <= K; ++j)
		{
			for (int k = 1; k <= K; ++k)
			{
				sum += gcd3(i, j, k);
			}
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
int a,b,c,k,ans;
void dfs(int t){
	if(t>k){
		if(a+b+c>ans)ans=a+b+c;
		return;
	}
	a*=2;
	dfs(t+1);
	a/=2;
	b*=2;
	dfs(t+1);
	b/=2;
	c*=2;
	dfs(t+1);
	c/=2;
}
int main(){
	scanf("%d%d%d",&a,&b,&c);
	scanf("%d",&k);
	dfs(1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

int main() {
    int N;
    std::cin >> N;
    std::string S;
    std::cin >> S;
    
    int ans = 0;
    
    if (N==2) {
        if (S[0]==S[1])
            ans = 1;
        else
            ans = 0;
    }
    
    for (size_t i=1; i<S.size(); ++i) {
        //std::cout << "------------" << std::endl;
        
        std::string left = S.substr(0,i);
        std::string right = S.substr(i);
        
        std::sort(left.begin(), left.end());
        std::sort(right.begin(), right.end());
        
        left.erase(std::unique(left.begin(), left.end()), left.end());
        right.erase(std::unique(right.begin(), right.end()), right.end());
        
        //std::cout << left << " " << right << std::endl;
        
        int cnt = 0;
        for (auto itr=left.begin(); itr!=left.end(); itr++) {
            for (auto itr_r=right.begin(); itr_r!=right.end(); itr_r++) {
                //std::cout << *itr << " " << *itr_r << std::endl;
                if (*itr==*itr_r) {
                    cnt++;
                }
            }
        }
        if (cnt > ans) ans = cnt;
    }
    
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import java.util.*;

class Node{
  private int key;
  private Node p;
  private int k=0;
  private Node l;
  private Node r;
  private static Node root;

  public void pre(){
    System.out.print(" "+key);
    if (l!=null) l.pre();
    if (r!=null) r.pre();
  }

  public void in(){
    if (l!=null) l.in();
    System.out.print(" "+key);
    if (r!=null) r.in();
  }

  public void post(){
    if (l!=null) l.post();
    if (r!=null) r.post();
    System.out.print(" "+key);
  }

  private Node(int key, Node l, Node r){
    this.key = key;
    this.l = l;
    this.r = r;
  }

  public static void insert(int v){
    insert(new Node(v,null,null));
  }

  private static void insert(Node z){
    Node y = null;
    Node x = root;
    while (x != null){
      y = x;
      if (z.key < x.key){
        x = x.l;
      } else {
        x = x.r;
      }
    }
    z.p = y;
    if (y==null){
      root = z;
    } else if (z.key<y.key){
      y.l = z;
    } else {
      y.r = z;
    }
  }

  public static void print(){
    root.in();
    System.out.println();
    root.pre();
    System.out.println();
  }
}

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for (int i=0; i<n; i++){
      switch (sc.next()){
        case "insert":
          Node.insert(sc.nextInt());
          break;
        case "print":
          Node.print();
          break;
      }
    }
  }
}


Measured memory_bytes: 220028
#include <iostream>
using namespace std;
int main(void){
   int w,h,x,y,r;
   cin >> w >> h >> x >> y >> r;
   if(x-r >= 0 && x+r <= w && y-r >= 0 && y+r <= h){
     cout << "Yes";
   }
   else{
       cout << "No";
   }
    cout << endl;
}


Measured memory_bytes: 3108
public class Main {

    static java.util.Scanner scan = new java.util.Scanner(System.in);
    public static void main(String[] args) {
       if(getLine()[0].replaceAll("hi","").length() > 0){
           puts("No");
       }else{
           puts("Yes");
       }
    }


    public static void puts(Object mes){
        System.out.println(mes);
    }

    public static long[] getLineLongs(){
        return java.util.stream.Stream.of(getLine()).mapToLong(Long::parseLong).toArray();
    }

    public static int[] getLineInts(){
        return java.util.stream.Stream.of(getLine()).mapToInt(Integer::parseInt).toArray();
    }

    public static String[] getLine(){
        String line = scan.nextLine();
        String[] sp = line.split(" ");
        if(sp.length == 1){
            //System.out.println(line);
            return new String[]{line};
        }else{
            return sp;
        }
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i += 2) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 512
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;

	long[string] cnt;
	cnt["AC"] = 0;
	cnt["WA"] = 0;
	cnt["TLE"] = 0;
	cnt["RE"] = 0;
	foreach (i; 0..N)
	{
		++cnt[RD!string];
	}

	writeln("AC x ", cnt["AC"]);
	writeln("WA x ", cnt["WA"]);
	writeln("TLE x ", cnt["TLE"]);
	writeln("RE x ", cnt["RE"]);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 3704
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <climits>

#define DEBUG

#ifdef DEBUG

#define printd printf

#else

#define printd(...)

#endif

int main() {
    int n;
    int shapes[100][2];

    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> shapes[i][0] >> shapes[i][1];
    }

    constexpr uint64_t INF = UINT64_MAX;
    uint64_t dp[100][100];
    for (int i = 0; i < 100; i++) {
        dp[i][i] = 0;
    }
    for (int width = 2; width <= n; width++) {
        for (int l = 0; l <= n - width; l++) {
            auto min = INF;
            for (int split = l + 1; split < l + width; split++) {
                auto times = dp[l][split - 1] + dp[split][l + width - 1] + shapes[l][0] * shapes[split][0] * shapes[l + width - 1][1];
                if (times < min) {
                    min = times;
                }
            }
            dp[l][l + width - 1] = min;
        }
    }
    std::cout << dp[0][n - 1] << std::endl;

    return 0;
}



Measured memory_bytes: 3172
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

vector<int> G[100];
bool visit[100];

vector<int> out;

int dfs(int i){
	int res=0;
	for (int v=0;v<G[i].size();v++){
		if (!visit[G[i][v]]){
			visit[G[i][v]]=true;
			res=max(res,dfs(G[i][v]));
			visit[G[i][v]]=false;
		}
	}
	return res+1;
}

int main(){
	int n;
	int a,b;
	do{
		scanf("%d",&n);
		if (n){
			for (int i=0;i<100;i++){
				G[i].clear();
			}
			for (int i=0;i<n;i++){
				scanf("%d %d",&a,&b);
				a--;
				b--;
				G[a].push_back(b);
				G[b].push_back(a);
			}
			int res=0;
			for (int i=0;i<100;i++){
				visit[i]=true;
				res=max(res,dfs(i));
				visit[i]=false;
			}
			out.push_back(res);
		}
	}while (n);
	for (vector<int>::iterator ite=out.begin();ite!=out.end();ite++){
		printf("%d\n",*ite);
	}
	return 0;
}

Measured memory_bytes: 1056
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    string s;
    cin >> s;
    bool playable = true;
    for(int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) {
            if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')
                continue;
        } else {
            if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')
                continue;
        }
        playable = false;
    }
    if (playable)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

int main(){
    ll mod = 1e9+7;
    ll N;
    cin >> N;
    //素数の集合を用意
    vector<ll> prime = Eratosthenes(N);
    //Nまでの数に素数が何回登場するのかを、素数ごとに数える
    ll cnt[N+2];
    llrep(i,N+2){
        cnt[i] = 0;
    }
    llRep(i,N){
        llrep(j,prime.size()){
            if (prime[j] <= i){
                // cout << "aaa" << endl;
                if (i%prime[j]==0){
                    // cout << i << " % " << prime[j] << " = 0" << endl;
                    ll add=0;
                    ll i_ = i;
                    while(i_%prime[j]==0){
                        add++;
                        i_ /= prime[j];
                    }
                    cnt[prime[j]] += add;
                }
            }
        }
    }
    ll ans=1;
    // llRep(i,N){
    //     cout << "cnt[" << i <<"] = " << cnt[i] << endl;
    // }
    llRep(i,N){
        if (cnt[i] >= 1){
            ans *= (cnt[i]+1);
            ans %= mod;
            // cout << "ans = " << ans << endl;
        }
    }
    cout << ans << endl;

    return 0;
}


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

 int main()
 {
 	int a,b,c,d;
 	cin >> a>>b>>c;
 	vector<int> x ={a,b,c};
 	sort(x.begin(), x.end());
 	d=x.at(2)*10+x.at(1)+x.at(0);
 	cout << d << endl;
 }

Measured memory_bytes: 256
n = int(input())
a= []
for i in range(n):
         x,y = input().split()
         y = int(y)
         if x == "S":
                  a.append(y)
         if x == "H":
                  a.append(y + 13)
         if x == "C":
                  a.append(y + 26)
         if x == "D":
                  a.append(y + 39)
for i in range(1, 53):
	if not (i in a):
		if i <= 13:
			print("S {}".format(i - 0))
		elif i <= 26:
			print("H {}".format(i - 13))
		elif i <= 39:
			print("C {}".format(i - 26))
		else:
			print("D {}".format(i - 39))



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[111];
void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	int ans = 0, l = 0, r = 0;
	for(int i = 1; i <= n+1; i++){
		if(a[i] >= a[i-1]){
			r = a[i];
		}
		else{
			ans += r-l;
			l = r = a[i];
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
def gcd(n,m):
    while n:
        m,n = n,m%n
    return m

N = int(input())
A = list(map(int,input().split()))

maxA = max(A)
B = [0]*(maxA+1)
for i in range(2,maxA+1):
    if B[i] == 0:
        B[i] = i
        for j in range(2*i,maxA+1,i):
            B[j] = i

soinsu = set()
a,b = 0,0

def pariwise():
    global N,A,soinsu,a,b
    for i in range(N):
        a = A[i]
        b = set()
        while a != 1:
            b.add(B[a])
            a //= B[a]
        for j in b:
            if j in soinsu:
                return False
            soinsu.add(j)
    return True

def setwise():
    global N,A,soinsu,a,b
    a = A[0]
    for i in range(1,N):
        a = gcd(a,A[i])
    return (a == 1)

if pariwise():
    print('pairwise coprime')
elif setwise():
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 189452
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
         ll n,a;
         map<ll,ll>mp;
         cin>>n;
         while(n--)
         {
             cin>>a;
             if(mp[a]==1)
                mp.erase(a);
             else
                mp[a]++;
         }
         cout<<mp.size()<<endl;

}


Measured memory_bytes: 6528
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin >> n;
	
	ll sum = 0;
	for (ll i = 1; i <= n-1; i ++ )
	{
		sum += i;
	}
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define vector3D(K, N, M, DP) vector<vector<vector<ll>>> DP(K, vector<vector<ll>>(N, vector<ll>(M)));
#define vector4D(K, N, M, O, DP) vector<vector<vector<vector<ll>>>> DP(K, vector<vector<vector<ll>>>(N, vector<vector<ll>>(M, vector<ll>(O))));
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}
/* ここからコード開始 */

int main(){
  kyopro;
  ll N, M;
  cin >> N >> M;
  vector<P> digit;
  vector<ll> num = {2, 5, 5, 4, 5, 6, 3, 7, 6};
  rep(i, 0, M){
    ll tmp;
    cin >> tmp;
    rep(i, 0, 9){
      if(tmp == i+1) digit.push_back(P(i+1, num[i]));
    }
  }
  sort(zenbu(digit));
  vector<string> ans(N+1, "X");
  for(auto&& j : digit){
    if(j.second < N + 1) ans[j.second] = to_string(j.first);
  }
  // test(1);
  // rep(i, 1, N+1){
  //   cout << i << sp << ans[i] << rt;
  // }
  // test(2);
  rep(i, 1, N+1){
    for(auto&& j : digit){
      auto& figure = j.first;
      auto& amount = j.second;
      string append = ans[i] + to_string(figure);
      if(
        i + amount < N + 1 ?
        append.size() > ans[i + amount].size() ||
        (append.size() == ans[i + amount].size() && append >= ans[i + amount]) :
        0
      ){
        if(ans[i] != "X") ans[i + amount] = append;
      }
    }
    // cout << i << ": " << ans[i] << endl;
  }
  // test(3);
  cout << ans[N] << endl;
}

Measured memory_bytes: 33024
import sys
bbn=1000000007
	
#+++++

def is_ok(n,s):
	if n % 2 ==1:
		return False
	for ti,tj in zip(s[:(n//2)],s[(n//2):]):
		#pa((ti,tj))
		if ti != tj:
			return False
	return True
	
def main():
	n = int(input())
	s = input()
	ret = 'Yes' if is_ok(n,s) else 'No'
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064