akhauriyash/Code-Regression huggingface dataset:
class Node():
    def __init__(self, key, p, l, r):
        self.key, self.p, self.l, self.r = key, p, l, r


class BinarySearchTree():
    def __init__(self):
        self.tree = []
        self.root = -1

    def insert(self, key):
        y = -1  # parent of x
        x = self.root
        while x != -1:
            y = x
            if key < self.tree[x].key:
                x = self.tree[x].l
            else:
                x = self.tree[x].r
        self.tree.append(Node(key, y, -1, -1))
        z = len(self.tree) - 1
        if y == -1:
            self.root = z
        elif key < self.tree[y].key:
            self.tree[y].l = z
        else:
            self.tree[y].r = z

    def find(self, key, x=0):
        while x != -1 and key != self.tree[x].key:
            if key < self.tree[x].key:
                x = self.tree[x].l
            else:
                x = self.tree[x].r
        return x

    def delete(self, key):
        node = self.find(key)
        self.delete_node(node)

    def delete_node(self, z):
        if self.tree[z].l == -1 or self.tree[z].r == -1:
            y = z
        else:
            y = self.get_successor(z)
        if self.tree[y].l != -1:
            x = self.tree[y].l
        else:
            x = self.tree[y].r
        if x != -1:
            self.tree[x].p = self.tree[y].p
        if self.tree[y].p == -1:
            self.root = x
        elif y == self.tree[self.tree[y].p].l:
            self.tree[self.tree[y].p].l = x
        else:
            self.tree[self.tree[y].p].r = x
        if y != z:
            self.tree[z].key = self.tree[y].key

    def get_successor(self, x):
        if self.tree[x].r != -1:
            return self.get_minimum(self.tree[x].r)
        y = self.tree[x].p
        while y != -1 and x == self.tree[y].r:
            x = y
            y = self.tree[y].p
        return y

    def get_minimum(self, x):
        while self.tree[x].l != -1:
            x = self.tree[x].l
        return x

    def preorder_traversal(self, u=0):
        if u == -1:
            return
        print(' ' + str(self.tree[u].key), end='')
        self.preorder_traversal(self.tree[u].l)
        self.preorder_traversal(self.tree[u].r)

    def inorder_traversal(self, u):
        if u == -1:
            return
        self.inorder_traversal(self.tree[u].l)
        print(' ' + str(self.tree[u].key), end='')
        self.inorder_traversal(self.tree[u].r)


def main():
    n = int(input())
    bst = BinarySearchTree()
    for _ in range(n):
        order = input().split()
        if order[0] == 'insert':
            key = int(order[1])
            bst.insert(key)
        elif order[0] == 'print':
            bst.inorder_traversal(0)
            print('')
            bst.preorder_traversal(0)
            print('')
        elif order[0] == 'find':
            key = int(order[1])
            print('yes' if bst.find(key) != -1 else 'no')
        elif order[0] == 'delete':
            key = int(order[1])
            bst.delete(key)


if __name__ == '__main__':
    main()



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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    int sum = 0;
    rep(i, n)
    {
        if (v[i] < k - v[i])
        {
            sum += v[i] * 2;
        }
        else
        {
            sum += (k - v[i]) * 2;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a>> b >> c;
    int ab,bc,ac;
    ab = a+ b;
    bc = b+c;
    ac = a+c;
    cout << min(min(ab,bc),ac) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) < abs(x - b)) cout << 'A' << endl;
    else cout << 'B' << endl;
}

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

int N, m;
scanf("%d", &N);
char a[N];
m = 1;
scanf("%s", a);


char pre = a[0];
for(int i = 0;i<N;i++){
    if(pre != a[i])m++;
    pre = a[i];
}

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

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define INF 1000000007LL
int t[101];
int pri[26];
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[y] = px;
	}
	else {
		pr[x] = py;
	}
	return true;
}
struct edge {
	int to;
	bool use = false;
	edge(int _to) : to(_to) {}
};
ll calc(ll v) {
	if (v == 0) return 0;
	ll sa = 1;
	int to = 10;
	for (ll j = 0; j < to; j++)
	{
		sa *= v;
		sa %= INF;
	}

	return sa;
}
pair<ll, ll> calc(ll a, ll b, ll c,ll d) {

	ll gc = gcd(b, d);
	ll m = (b * d) / gc;
	ll ac = a * (m / b);
	ll cc = c * (m / d);
	return pair<ll, ll>(ac - cc, m);
}

void solv() {

	double n;
	cin >> n;
	for (ll i = 3500; i >= 1; i--)
	{
		pair<ll, ll> p = calc(4, n, 1, i);
		for (ll j = 3500; j >= 1;j--)
		{
			pair<ll, ll> q = calc(p.first, p.second, 1, j);
			if (q.first == 1) {
				cout << i << " " << j << " " << q.second;
				return;
			}
		}
	}


}


int main() {
	solv();

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    long long int suml,sumr=0,min,x;
    int N,i,p=1;
    scanf("%d",&N);
    long long int a[N];
    for(i=0;i<N;i++)
    {
        scanf("%lld",&a[i]);
    }
    suml=a[0];
    for(i=1;i<N;i++)
    {
        sumr=sumr+a[i];
    }
    min=llabs(sumr-suml);
    for(p=1;p<N-1;p++){
    suml=suml+a[p];
    sumr=sumr-a[p];
    x=llabs(sumr-suml);
    if(x<min)
        min=x;
    }
    printf("%lld",min);
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
 int N;
 cin >> N;
 int res = N%10;
 if(res == 3) {
   cout << "bon" << endl;
 }else if(res == 0||res == 1||res == 6||res == 8){
   cout << "pon" << endl;
 }else{
   cout << "hon" << endl;
 }
}

Measured memory_bytes: 3636
N = int(input())
for n in range(1, 3500):
  for w in range(1, 3500):
    if 4 * n * w - N * n - N * w == 0: continue
    if N * n * w % (4 * n * w - N * n - N * w) == 0:
      h = N * n * w // (4 * n * w - N * n - N * w)
      if h > 0:
        print(h, n, w)
        #print(1 / h + 1 / n + 1 / w, 4 / N)
        exit(0)

Measured memory_bytes: 41836
#include<iostream>
#include<map>
#include<vector>
using namespace std;
#define df 0
int root(int v,vector<int>& r);
void merge(int u,int v,vector<int>& r);

int main(){
  if(df) printf("*debug mode*\n");
  int n,k,l; cin >> n >> k >> l;
  vector<int> ar(n,-1);
  for(int i=0;i<k;i++){
    int a,b; cin >> a >> b; a--;b--;
    merge(a,b,ar);
  }
  if(df){
    printf("ar:[ ");
    for(int const& k: ar){
      printf("%d ",k);
    }
    printf("]\n");
  }
  vector<int> br(n,-1);
  for(int i=0;i<l;i++){
    int a,b; cin >> a >> b; a--;b--;
    merge(a,b,br);
  }
  if(df){
    printf("br:[ ");
    for(int const& k: br){
      printf("%d ",k);
    }
    printf("]\n");
  }
  map<pair<int,int>,int> mp;
  for(int i=0;i<n;i++){
    if(df)printf("add (%d %d)\n",root(i,ar),root(i,br));
    mp[make_pair(root(i,ar),root(i,br))]++;
  }
  for(int i=0;i<n;i++){
    printf("%d ",mp[make_pair(root(i,ar),root(i,br))]);
  }
}

int root(int v,vector<int>& r){
  if(r.at(v)<0)return v;
  int u=root(r.at(v),r);
  r.at(v)=u;
  return u;
}
void merge(int u,int v,vector<int>& r){
  if(df)printf("[merge %d %d]\n",u,v);
  u=root(u,r); v=root(v,r);
  if(df)printf("[select %d(%d),%d(%d)]\n",u,r.at(u),v,r.at(v));
  if(u==v)return;
  int w=(r.at(u)<r.at(v))?u:v;
  r.at(w)=r.at(u)+r.at(v);
  r.at(u+v-w)=w;
  if(df)printf("->[%d(%d),%d(%d)]\n",u,r.at(u),v,r.at(v));
}
/// confirm df==0 ///

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  if((a==1&b==1)|(a==1&b==3)|(a==1&b==5)|(a==1&b==7)|(a==1&b==8)|(a==1&b==10)|(a==1&b==12)|(a==3&b==1)|(a==3&b==3)|(a==3&b==5)|(a==3&b==7)|(a==3&b==8)|(a==3&b==10)|(a==3&b==12)|(a==5&b==1)|(a==5&b==3)|(a==5&b==5)|(a==5&b==7)|(a==5&b==8)|(a==5&b==10)|(a==5&b==12)|(a==7&b==1)|(a==7&b==3)|(a==7&b==5)|(a==7&b==7)|(a==7&b==8)|(a==7&b==10)|(a==7&b==12)|(a==8&b==1)|(a==8&b==3)|(a==8&b==5)|(a==8&b==7)|(a==8&b==8)|(a==8&b==10)|(a==8&b==12)|(a==10&b==1)|(a==10&b==3)|(a==10&b==5)|(a==10&b==7)|(a==10&b==8)|(a==10&b==10)|(a==10&b==12)|(a==12&b==1)|(a==12&b==3)|(a==12&b==5)|(a==12&b==7)|(a==12&b==8)|(a==12&b==10)|(a==12&b==12)|(a==4&b==4)|(a==4&b==6)|(a==4&b==9)|(a==4&b==11)|(a==6&b==4)|(a==6&b==6)|(a==6&b==9)|(a==6&b==11)|(a==9&b==4)|(a==9&b==6)|(a==9&b==9)|(a==9&b==11)|(a==11&b==4)|(a==11&b==6)|(a==11&b==9)|(a==11&b==11)|(a==2&b==2))cout<<"Yes";else cout<<"No";}

Measured memory_bytes: 256
using System;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            string[] In = Console.ReadLine().Split(' ');
            int a = int.Parse(In[0]);
            int b = int.Parse(In[1]);
            bool flag = true;
            for(int i=1; i<=1000; i++)
            {
                int x = (int)(i * 0.08);
                int y = (int)(i * 0.10);
                if(x==a && y == b)
                {
                    Console.WriteLine(i);
                    flag = false;
                    break;
                }
                if (x > a && y > b) break;

            }
            if (flag) Console.WriteLine(-1);

        }
    }
}

Measured memory_bytes: 13140
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int number_n, number_m, i, max_left = 0, min_right = (int)Double.POSITIVE_INFINITY, answer;
    Scanner sc = new Scanner(System.in);
    number_n = Integer.parseInt(sc.next());
    number_m = Integer.parseInt(sc.next());
    int[] card_left = new int[number_m];
    int[] card_right = new int[number_m];
    for(i = 0; i < number_m; i++) {
      card_left[i] = Integer.parseInt(sc.next());
      card_right[i] = Integer.parseInt(sc.next());
      if(card_left[i] > max_left) max_left = card_left[i];
      if(card_right[i] < min_right) min_right = card_right[i];
    }
    answer = (min_right >= max_left)? min_right - max_left + 1 : 0;
    System.out.println(answer);
  }
}


Measured memory_bytes: 51196
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s: Vec<i32> = s.trim().split(' ').map(|x| x.parse::<i32>().unwrap()).collect();
    let (a, b, c, d) = (s[0], s[1], s[2], s[3]);

    let tk = (c + (b-1))/b;
    let ao = (a + (d-1))/d;

    if tk <= ao{
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int H,W;
  cin >> H >> W;
   
  for(int i = 0 ; i < W + 2 ; i++){
    cout << '#';
  }
  cout << endl;
  
  for(int i = 0 ; i < H ; i++){
    string temp;
    cin >> temp;
    cout << '#' << temp << '#' << endl;
  }
      
  for(int i = 0 ; i < W + 2 ; i++){
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if(n < 2)
    {
        cout << "1";
    }
    else if(n < 4)
    {
        cout << "2";
    }
    else if(n < 8)
    {
        cout << "4";
    }
    else if(n < 16)
    {
        cout << "8";
    }
    else if(n < 32)
    {
        cout << "16";
    }
    else if(n < 64)
    {
        cout << "32";
    }
    else
    {
        cout << "64";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
using namespace std;
int main(){
int N;
int a[110];

cin >>N;
for(int i=0;i<N;i++)
cin >>a[i];

sort(a,a+N);
cout<<a[N-1]-a[0]<<endl;

}


Measured memory_bytes: 256
import java.util.*;

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

        Map<String, Long> m = new TreeMap<>();

        for (int i=0; i<n; i++){
            String st = sc.next();
            char[] c = st.toCharArray();
            Arrays.sort(c);
            st = new String(c);
//            System.out.println(st);
            if (m.containsKey(st)){
                m.put(st, m.get(st)+1);
            }else{
                m.put(st, 1L);
            }
        }
//        System.out.println(m);

        long ans = 0;

        for (Long v: m.values()){
            ans += v*(v-1)/2;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 50272
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll dp[2][201][201][2];
ll ten[10001];
ll a[201];

int calcdigit(int v){
	int ret=0;
	if(v==0)return 1;
	while(v>0){
		v/=10;
		ret++;
	}
	return ret;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	ten[0]=1;
	for(int i=0;i<=10*n;i++){
		ten[i+1]=ten[i]*10LL%MOD;
	}
	sort(a,a+n);
	reverse(a,a+n);
	int now=1,prev=0;
	dp[0][0][0][0]=1;
	for(int i=0;i<n;i++){
		int dig=calcdigit(a[i]);
		for(ll j=0;j<=i;j++){
			for(ll k=0;k<=i;k++){
				for(int l=0;l<2;l++){
					if(dp[prev][j][k][l]>0){
						if(l==0){
							dp[now][j][k][l]+=dp[prev][j][k][l]%MOD;
							dp[now][j][k][l]%=MOD;

							if(a[i]!=0){
								dp[now][j+1][k][l]+=dp[prev][j][k][l]*(j+1)%MOD;
								dp[now][j+1][k][l]%=MOD;
							}else{
								dp[now][j+1][k][l]+=dp[prev][j][k][l]*j%MOD;
								dp[now][j+1][k][l]%=MOD;
							}
							

							dp[now][j][k+1][l]+=dp[prev][j][k][l]*(k+1)*ten[dig]%MOD;
							dp[now][j][k+1][l]%=MOD;

							dp[now][j][k][1]+=dp[prev][j][k][l]*a[i]%MOD;
							dp[now][j][k][1]%=MOD;
						}else{
							dp[now][j][k][l]+=dp[prev][j][k][l]%MOD;
							dp[now][j][k][l]%=MOD;

							if(a[i]!=0){
								dp[now][j+1][k][l]+=dp[prev][j][k][l]*(j+1)%MOD;
								dp[now][j+1][k][l]%=MOD;
							}else{
								dp[now][j+1][k][l]+=dp[prev][j][k][l]*j%MOD;
								dp[now][j+1][k][l]%=MOD;
							}

							dp[now][j][k+1][l]+=dp[prev][j][k][l]*(k+1)*ten[dig]%MOD;
							dp[now][j][k+1][l]%=MOD;
						}
					}
				}
			}
		}
		swap(now,prev);
		memset(dp[now],0,sizeof(dp[now]));
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ans=(ans+dp[prev][i][j][1])%MOD;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4556
#include <iostream>

using namespace std;

int main()
{
    int n, m, p;
    int num[101];
    while (cin >> n >> m >> p, n|m|p) {
        int total = 0;
        for (int i = 1; i <= n; i++) {
            cin >> num[i];
            total += num[i] * (100-p);
        }
        if (!num[m]) {
            cout << 0 << endl;
            continue;
        }
        cout << (total / num[m]) << endl;
    }
    return 0;
}

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

int N;
string S,T;
int main(){
	cin >> N >> S >> T;
	for(int i=N;i<=2*N-1;i++){
		string s = S.substr(i-N,2*N-i),t = T.substr(0,2*N-i);
		if(s==t){
			cout << i << endl;
			return 0;
		}
	}
	cout << 2*N << endl;
}

Measured memory_bytes: 256
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, K) = read!(usize, usize);
    let mut H = read![i64; N];

    let mut min_d = std::i64::MAX;
    H.sort();
    for i in K..N + 1 {
        let d = H[i - 1] - H[i - K];
        min_d = min(d, min_d);
    }

    println!("{}", min_d)
}


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


int main(){
	string s;cin>>s;
	int x= s.length();
	long long sum=0;
	for(int i=0;i<x;i++){
		sum += s[i]-'0';
	}
	if(sum%9){
		cout<<"No"<<"\n";
	}else{
		cout<<"Yes"<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

map<int, int> d;
void solve()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        d[x]++;
    }
    
    int res = 0;
    for(map<int, int>::iterator it = d.begin(); it != d.end(); it++)
    {
        if(it->second >= it->first)
        {
            res += it->second - it->first;
        }
        else
        {
            res += it->second;
        }
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    
    return 0;
}


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

bool prime(ll n){
    if(n==1) return false;
    for(int i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

ll kosuu(ll n,ll m){
    ll D[1000]={};
    for(int i=2;i<=n;i++){
        if(prime(i)){
            D[i]++;
            continue;
        }
        ll z=i;
        for(int j=2;j<=i&&z!=1;){
            if(z%j!=0||!prime(j)){
                j++;
                continue;
            }
            z/=j;
            D[j]++;
        }
    }
    ll ans=1;
    for(int i=2;i<1000;i++){
        ans=ans*(D[i]+1)%m;
    }
    return ans;
}

int main(void){
    ll n;
    cin>>n;
    cout<<kosuu(n,1e9+7)<<endl;
}

Measured memory_bytes: 256
'use strict';

const input = require("fs").readFileSync("/dev/stdin", "utf8");
const list = input.trim().split('');

const halfLength = Math.floor(list.length / 2);

let hugCount = 0;
for (let i = 0; i < halfLength; i++) {
    const head = list[i].trim();
    const tail = list[list.length - i - 1].trim();
    if (head !== tail) {
        hugCount++;
    }
}

console.log(hugCount);


Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define INF 1000000009
int n,k;
int h[MAX];
int dp[MAX];

int main()
{
    cin >> n >> k;
    for(int i=1;i<=n;i++)cin >> h[i];
    dp[1] = 0;
    for(int i=2;i<=n;i++)
    {
        dp[i] = INF;
        int x = 1;
        while(i-x>=1 && x<=k)
        {
            dp[i] = min(dp[i],dp[i-x]+abs(h[i]-h[i-x]));
            //cout << dp[i] << " ";
            x++;
        }
        //cout << endl;
    }

    cout << dp[n];
}

Measured memory_bytes: 1024
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
int ose[11][10001];
int num[10001];
int main(){
    while(1){
        int a,b;
        cin>>a>>b;
        int ans=0;
        if(a==0 and b==0) break;


        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                scanf("%d",&ose[i][j]);
            }
            
        }
        for(int i=0;i<1<<a;i++){
            int n=0;
            fill(num,num+10001,0);
            for(int j=0;j<a;j++){
                
                if((i>>j & 1)==1){
                    for(int k=0;k<b;k++){
                        if(ose[j][k]==0)num[k]=num[k] + 1;
                    }
                }
                else {
                    for(int k=0;k<b;k++){

                        if(ose[j][k]==1)num[k]=num[k] + 1;
                    }
                }

            
            }
            for(int j=0;j<b;j++){
                n=n+max(num[j],a-num[j]);
                
            }
            ans=max(n,ans);
        }
        cout<<ans<<endl;
    
    
    }
    return 0;
};

Measured memory_bytes: 3536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        HashMap<Integer,Integer> count = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int a = ni();
            count.putIfAbsent(a, 0);
            count.put(a,count.get(a)+1);
        }
        int numeven = 0;
        for (Integer val : count.values()) {
            if(val%2==0) numeven++;            
        }
        int ans = N;
        if(numeven%2==1) ans = count.size()-1;
        else ans = count.size();
 
        out.println(ans);
    }

    final int mod = 1000000007;
    int mul(int x, int y){
        return (int)((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        return x >= mod ? (x - mod) : x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

int main(){
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define first ff
#define second ss
#define ll long long int
int main()
{
    char c;
    cin>>c;
    if(c=='A') cout<<"T";
    else if(c=='T') cout<<"A";
    else if(c=='G') cout<<"C";
    else cout<<"G";
}


Measured memory_bytes: 3556
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if b < a {
		a, b = b, a
	}
	if c < b {
		b, c = c, b
	}

	if a == 5 && b == 5 && c == 7 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
//AtCoder ABC053 C - X: Yet Another Die Game
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll x;
    cin>>x;
    //6->5
    ll n=x/11;
    ll rest=x%11;
    ll ans=n*2;
    if(rest>0) {
		ans += (rest <= 6 ? 1 : 2);
	}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input=sys.stdin.readline
    from collections import deque
    inf=10**12

    class MinCostFlow:
        def __init__(self,n):
            self.n=n
            self.edges=[[] for i in range(n)]
        def add_edge(self,fr,to,cap,cost):
            self.edges[fr].append([to,cap,cost,len(self.edges[to])])
            self.edges[to].append([fr,0,-cost,len(self.edges[fr])-1])
        def MinCost(self,source,sink,flow):
            n=self.n; E=self.edges
            mincost=0
            prev_v=[0]*n; prev_e=[0]*n
            while flow:
                dist=[inf]*n
                dist[source]=0
                q=deque([source])
                Flag=[False]*n
                Flag[source]=True
                while q:
                    v=q.popleft()
                    if not Flag[v]:
                        continue
                    Flag[v]=False
                    for i,(to,cap,cost,_) in enumerate(E[v]):
                        if cap>0 and dist[to]>dist[v]+cost:
                            dist[to]=dist[v]+cost
                            prev_v[to],prev_e[to]=v,i
                            q.append(to)
                            Flag[to]=True
                f,v=flow,sink
                while v!=source:
                    f=min(f,E[prev_v[v]][prev_e[v]][1])
                    v=prev_v[v]
                flow-=f
                mincost+=f*dist[sink]
                v=sink
                while v!=source:
                    E[prev_v[v]][prev_e[v]][1]-=f
                    rev=E[prev_v[v]][prev_e[v]][3]
                    E[v][rev][1]+=f
                    v=prev_v[v]
            return mincost

    n=int(input())
    flow=MinCostFlow(2*n+6)
    s=0
    for i in range(n):
        rx,ry,rc=map(int,input().split())
        s+=rc
        flow.add_edge(0,i+1,rc,0)
        flow.add_edge(i+1,n+1,inf,-rx-ry)
        flow.add_edge(i+1,n+2,inf,rx-ry)
        flow.add_edge(i+1,n+3,inf,-rx+ry)
        flow.add_edge(i+1,n+4,inf,rx+ry)
    for i in range(n):
        bx,by,bc=map(int,input().split())
        flow.add_edge(n+5+i,2*n+5,bc,0)
        flow.add_edge(n+1,n+5+i,inf,bx+by)
        flow.add_edge(n+2,n+5+i,inf,-bx+by)
        flow.add_edge(n+3,n+5+i,inf,bx-by)
        flow.add_edge(n+4,n+5+i,inf,-bx-by)
    print(-(flow.MinCost(0,2*n+5,s)))

if __name__=='__main__':
    main()

Measured memory_bytes: 120156
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b,c,x,counter = 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){
					counter++;
				}
			}
		}
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
	int N; cin >> N;
	bool f = false;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == N) { f = true; }
		}
	}

	if (f == true) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  int a=0,b=0;
  char p,q,r,s;
  cin>>p>>q>>r>>s;
  a=(int)(p-'0')*10+(int)(q-'0');
  b=(int)(r-'0')*10+(int)(s-'0');
  bool f=false,g=false;
  if(1<=a&&a<=12) f=true;
  if(1<=b&&b<=12) g=true;
  if(f&&g) cout<<"AMBIGUOUS"<<endl;
  else if(f) cout<<"MMYY"<<endl;
  else if(g) cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;
}


Measured memory_bytes: 256
#include <iostream> 
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    int X;
    cin >> X;
    rep(i, 401) {
        rep(j, 401) {
            int x, y;
            x = j-200;
            y = i-200;
            if (pow(x, 5)-pow(y, 5) == X) {
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int h, w;
    cin >> h >> w;
    int start[10];
    int end[10];
    char a[10][10];
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= h; i++){
        start[i] = -1;
        end[i] = -1;
    }
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(a[i][j] == '#'){
                if(start[i] == -1){
                    start[i] = j;
                }
                if(end[i] != -1){
                    cout << "Impossible" << endl;
                    return 0;
                }
            } else {
                if((end[i] == -1) && (start[i] != -1)){
                    end[i] = j - 1;
                }
            }
        }
        if(start[i] == -1){
            cout << "Impossible" << endl;
            return 0;
        }
        if(end[i] == -1){
            end[i] = w;
        }
    }
    for(int i = 1; i < h; i++){
        if(end[i] != start[i + 1]){
            cout << "Impossible" << endl;
            return 0;
        }
    }
    if(a[1][1] == '.'){
            cout << "Impossible" << endl;
            return 0;
    }
    if(a[h][w] == '.'){
            cout << "Impossible" << endl;
            return 0;
    }
    cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
int main(){
		char s;
		cin >> s;
		if(s=='a'||s=='e'||s=='i'||s=='o'||s=='u')cout << "vowel" << endl;
		else puts("consonant");
		return 0;
	}//////

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

int n, d = 0;
int o[1000][1000];
int cp[1000];
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    memset(o, -1, sizeof(o));
    F0R(i, n) 
    {
        F0R(j, n - 1) 
        {
            cin >> o[i][j];
            o[i][j]--;
        }
    }
    // for(auto i : o) 
    // {
    //     for(auto j : i) cout << j << " ";
    //     cout << "\n";
    // }
    bool c = true;
    gp_hash_table<ll, int> m;
    stack<int> tc;
    F0R(i, n) tc.push(i);
    int tot = 0;
    while(c)
    {
        c = false;
        tot += sz(tc);
        vector<pair<int, int>> e;
        while(!tc.empty())
        {
            int j = tc.top();
            tc.pop();
            if(cp[j] < n - 1)
            {
                int a = o[j][cp[j]], b = j;
                if(a > b) swap(a, b);
                m[1005 * (a + 1) + (b + 1)]++;
                if(m[1005 * (a + 1) + (b + 1)] == 2) 
                {
                    // cout << a << " " << b << "\n";
                    c = true;
                    e.pb({a, b});
                }
            }
        }
        for(auto i : e) 
        {
            cp[i.f]++;
            cp[i.s]++;
            tc.push(i.f);
            tc.push(i.s);
            m.erase((i.f + 1) * 1005 + (i.s + 1));
        }
        // cout << "\n";
        d++;
        if(!c) break;
    }
    bool pos = true;
    F0R(i, n) if(cp[i] != n - 1) pos = false;
    cout << (pos ? d - 1 : -1);
    return 0;
}

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

using namespace std;

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> arr;
    while (n > 0) {
        int num;
        cin >> num;
        arr.push_back(num);
        n--;
    }

    int min_dist = 0;  // Set initial distance 0

    // Find the longest segment one has to walks
    for (int i = 0; i < arr.size() - 1; i++) {
        min_dist = max(min_dist, (arr[i + 1] - arr[i]));
    }

    // Compares if walking from start to end is shorter or not
    min_dist = max(min_dist, arr[0] + k - arr[arr.size() - 1]);

    // At most has to walk this much, so we can just subtract from k
    cout << k - min_dist << endl;

    return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num[] = new int[5];
		boolean possible = true;

		for (int i = 0; i < 5; i++) {
			num[i] = sc.nextInt();
		}
		int k = sc.nextInt();

		for (int i = 0; i < 5; i++) {
			for (int j = i + 1; j < 5; j++) {
				if (!(num[j] - num[i] <= k)) possible = false;
			}
		}

		if (possible) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

const ll MAX_N = 100010;
vec bit(MAX_N,0);
ll sum(ll i){
    ll s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}
void add(ll i, ll x){
    while(i < MAX_N){
        bit[i] += x;
        i += i & -i;
    }
}


ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}

int main() {
    cin>>N>>K;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll ans = 0;
    rep(i,N){
        ans += sum(100009) - sum(a[i]);
        add(a[i], 1);
    }
    ans *= K;
    ll temp = 0;
    if(K >= 2) {
        set<ll> ele;
        rep(i, N) ele.insert(a[i]);
        sort(a.begin(), a.end());
        for (ll s : ele) {
            //cout<<s<<endl;
            (temp += (upper_bound(a.begin(), a.end(), s) - lower_bound(a.begin(), a.end(), s)) *
                     (lower_bound(a.begin(), a.end(), s) - a.begin())) %= MOD;
        }
        (temp *= K)%=MOD;
        (temp *= K - 1)%=MOD;
        (temp *= fastpow(2LL, MOD - 2))%=MOD;
    }
    (ans += temp)%=MOD;
    cout<<ans<<endl;
}


Measured memory_bytes: 1152
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    suuretu = LI()
    q = I()
    dic = collections.Counter(suuretu)
    nowsum = sum(suuretu)
    
    for _ in range(q):
        b,c = LI()
        cnt = dic[b]
        nowsum += (c-b)*cnt
        print(nowsum)
        dic[b] = 0
        dic[c] += cnt
main()            


Measured memory_bytes: 90340
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  string S;
  cin >> S;
  int N = S.size();

  S += "R";
  
  vector<int> V(N, 0);
  int r = 0, l = 0;
  int mark = -1;
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == 'L') l++; else r++;
    if (S.substr(i, 2) == "RL") mark = i;
    if (S.substr(i, 2) == "LR")
    {
      V.at(mark) = (r % 2 == 0)? (r + l) / 2 : divCeil(r + l, 2);
      V.at(mark + 1) = l + r - V.at(mark);
      l = 0; r = 0;
    }
  }

  for (int i = 0; i < N; i++)
  {
    cout << V.at(i);
    if (i == N - 1) cout << endl;
    else cout << " ";
  }
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        int sum = 0;
        for (int i = 0 ; i < n ; i++) {
            t[i] = sc.nextInt();
            sum += t[i];
        }
        int m = sc.nextInt();
        int[] p = new int[m];
        int[] x = new int[m];
        for (int i = 0 ; i < m ; i++) {
            p[i] = sc.nextInt() - 1;
            x[i] = sc.nextInt();
        }

        for (int i = 0 ; i < m ; i++) {
            System.out.println(sum - t[p[i]] + x[i]);
        }

    }

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
     int x,y;
     cin >> x >> y;
     int a = 0, b = 0;
     if(x == 2) a = 1;
     if(y == 2) b = 1;
     if(x == 4 || x == 6 || x == 9 || x == 11) a = 2;
     if(y == 4 || y == 6 || y == 9 || y == 11) b = 2;

     if(a == b) cout << "Yes" << endl;
     else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

vector <int> sol;

int a[105];

int main() {
	int n;
	scanf("%d", &n);
	for (int i=1 ; i<=n ; i++) {
		scanf("%d", a+i);
	}
	for (int i=0 ; i<n ; i++) {
		int ind = -1;
		int off = i;
		for (int j=n ; j ; j--) {
			if (a[j] == -1) {
				off--;
				continue;
			}
			if (a[j] == j-off) {
				ind = j;
				break;
			}
		}
		if (ind == -1) {
			printf("-1\n");
			return 0;
		}
		sol.push_back(a[ind]);
		a[ind] = -1;
	}
	reverse(sol.begin(), sol.end());
	for (int i=0 ; i<n ; i++) {
		printf("%d\n", sol[i]);
	}
	return 0;
}

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

using ll = long long;

// 階乗
ll factorial(int n) {
  if(n == 0) return 1;
  return n * factorial(n - 1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 無向(有向)グラフの隣接行列
  int n, m, u, v;
  cin >> n >> m;
  
  int M[n][n]; // 頂点数がnのグラフを表す隣接行列
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      M[i][j] = 0;
    }
  }
  
  for(int i = 0; i < m; i++){
    cin >> u >> v;
    u--;
    v--;
    M[u][v] = 1;
    M[v][u] = 1; // 有向グラフではこの行をコメントアウト
  }
  
  vector<int> x(n);
  for(int i = 0; i < n; i++) x.at(i) = i;
  
  int ans = 0;
  for(ll i = 0; i < factorial(n - 1); i++){
    bool judge = true;
    for(int j = 1; j < n; j++){
      if(M[x.at(j - 1)][x.at(j)] == 0) judge = false;
    }
    if(judge) ans++;
    next_permutation(x.begin(), x.end());
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var ans = "Sunny";
        if (s[0] == 'S') ans = "Cloudy";
        else if (s[0] == 'C') ans = "Rainy";
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    string s=to_string(n);
    for(int i=0;i<3;i++)
        if(s[i]=='7')
        {
            cout<<"Yes\n";
            return 0;
        }
    cout<<"No\n";

    return 0;   
}




 
 


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  ll n,m; cin >> n >> m;
  if(n>m)swap(n,m);
  ll ans = 0;
  if (m == 1) {
    ans = 1;
  } else if (n==1) {
    ans = m-2;
  } else {
    ans = (n-2)*(m-2);
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
def main():
    N, M = MAP()
    dp = [INF] * (1<<N)
    dp[0] = 0

    for i in range(M):
        a, b = MAP()
        c = LIST()
        d = 0
        # 1を立てる
        for x in c:
            # 1が存在するなら，dの一番最後，右から0番目，0シフト目に必要
            d += 1<<(x-1)
        for j in range(1<<N): # 2 ** N 列見る
    #         # テーブルは一列ずつ見て更新しよう
            tmp = j|d
            dp[tmp] = min(dp[tmp], dp[j] + a)
    if dp[-1] == INF:
        print(-1)
    else:
        print(dp[-1])

if __name__ == "__main__":
    main()

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

constexpr long long mod{1000000007};

int main()
{
	int n;
	std::string s;
	std::cin >> n >> s;
	int count[26]{};
	for (auto& e: s) count[e - 'a']++;
	long long ans{1};
	for (int i{}; i < 26; i++)
		ans = ans * (count[i] + 1) % mod;
	ans = (ans + mod - 1) % mod;

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

Measured memory_bytes: 512
#include<cstdio>
 
int main()
{
	int X;
	scanf("%d", &X);
	for (int A = 0; A < 1000; ++A)
		for (int B = -1000; B < A; ++B)
			if (A * A * A * A * A - B * B * B * B * B == X)
			{
				printf("%d %d", A, B);
				return 0;
			}
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005

// it's swapnil07 ;)


signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int a; string s; cin>>a>>s;
    if(a<3200){
        cout<<"red";
    }
    else{
        cout<<s;
    }
    return 0;
}

Measured memory_bytes: 256