akhauriyash/Code-Regression huggingface dataset:
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Feb  2 11:06:47 2020
//
package main

import "fmt"

type pair struct {
	x int
	y int
}

var N int

func top(n int) int {
	m := 1
	for {
		if n/(m*10) == 0 {
			return n / m
		}
		m *= 10
	}
}

func main() {
	fmt.Scan(&N)
	m := map[pair]int{}

	for i := 1; i <= N; i++ {
		m[pair{top(i), i % 10}]++
	}

	ans := 0
	for p, x := range m {
		y := m[pair{p.y, p.x}]
		ans += x * y
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
n,l=map(int,input().split())
*a,=map(int,input().split())

for i in range(n-1):
  if a[i]+a[i+1]>=l:
    print("Possible")
    print(*range(i+2,n)[::-1],sep="\n")
    print(*range(1,i+2),sep="\n")
    break
else:
  print("Impossible")

Measured memory_bytes: 14060
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
typedef long long ll;

int len;

int main() {
    string s;
    cin >> s;
    ll res = 0;
    for (int i = 0; i < 1 << (s.length() - 1); i++) {
        int prev = 0;
        for (int j = 0; j < s.length(); j++) {
            if (i >> j & 1) {
                res += stoll(s.substr(prev, j - prev + 1));
                prev = j + 1;
            }
        }
        if (prev < s.length()) {
            res += stoll(s.substr(prev, s.length() - prev));
        }
    }
    cout << res << endl;
}


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

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N, P;
  std::cin >> N >> P;
  std::vector<int> A(N);
  for (int &x: A) {
    char c;
    std::cin >> c;
    x = c - '0';
  }
  if (P == 2 || P == 5) {
    long long ans = 0;
    for (int i: range(0, N)) {
      if (A[i] % P == 0) {
        ans += i + 1;
      }
    }
    std::cout << ans << '\n';
  }
  else {
    std::vector<int> rem(P);
    long long ans = 0;
    int now = 0, ten = 1;
    std::reverse(A.begin(), A.end());
    for (int x: A) {
      ++rem[now];
      now = (now + ten * x) % P;
      ten = (ten * 10) % P;
      ans += rem[now];
    }
    std::cout << ans << '\n';
  }
  return 0;
}


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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,k,m = LI()
        if n == 0:
            break
        a = list(range(1,n+1))
        t = m - 1
        for i in range(n-1):
            a = a[:t] + a[t+1:]
            t = (t - 1 + k) % len(a)
        rr.append(a[0])

    return '\n'.join(map(str, rr))


print(main())




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

int32_t main()
{

    //

//    while(1){
//
//    int x,y,z;
//    cin>>x>>y>>z;
//
//    int ans = x*x + y*y + z*z + x*y+ y*z + z*x;
//
//    cout<<ans<<endl;
//    }


     int n;
     cin>>n;

     int val[n+2]={0};

     for(int x=1; x<=100; x++){
        for(int y=1; y<=100; y++){
            for(int z=1; z<=100; z++){

                //cout<<x<<" "<<y<<" "<<z<<endl;
                int ans = x*x + y*y + z*z + x*y+ y*z + z*x;
                if(ans>n) break;
                else {
                    val[ans]++;
                }
               //cout<<ans<<endl;
            }
        }
     }

     for(int i=1; i<=n; i++){
        cout<<val[i]<<endl;
     }

    return 0;
}



Measured memory_bytes: 3616
import java.util.*;
import java.io.*;

class Main {

	static final int INF = Integer.MAX_VALUE/2;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		int v = Integer.parseInt(line.substring(0,line.indexOf(" ")));
		int e = Integer.parseInt(line.substring(line.indexOf(' ')+1));

		int[][] d = new int[v][v];
		for (int i=0; i<v; i++) {
			Arrays.fill(d[i],-1);
		}

		for (int i=0; i<e; i++) {
			line = br.readLine();
			String[] str = line.split(" ");
			int si = Integer.parseInt(str[0]);
			int ti = Integer.parseInt(str[1]);
			int di = Integer.parseInt(str[2]);
			d[si][ti] = di;
		}

		int[][] dp = new int[1<<v][v];
		for (int i=0; i<1<<v; i++)
			Arrays.fill(dp[i],INF);
		dp[(1<<v)-1][0] = 0;

		for (int i=(1<<v)-2; i>=0; i--) {
			for (int j=0; j<v; j++) {
				for (int k=0; k<v; k++) {
					if ((i>>k&1) == 0 && d[j][k] != -1)
						dp[i][j] = Math.min(dp[i][j],dp[i|1<<k][k]+d[j][k]);
				}
			}
		}

		System.out.println(dp[0][0]>=INF?-1:dp[0][0]);

		br.close();
	}
}

Measured memory_bytes: 23236
h, w = map(int, input().split())
maptrans = []
for i in range(10):
    l = list(map(int, input().split()))
    maptrans.append(l)
costtoone = []
# ダイレクトに1に行くときのコスト
for i in range(10):
    costtoone.append(maptrans[i][1])

for loop in range(10): # 念のためループ
    for tonum in range(10): # この数経由
        for i in range(10):
            costtoone[i] = min(costtoone[i], costtoone[tonum] + maptrans[i][tonum])

#print(costtoone)


maze = []
for hh in range(h):
    l = list(map(int, input().split()))
    maze.append(l)

res = 0
for hh in range(h):
    for ww in range(w):
        if maze[hh][ww] == 1 or maze[hh][ww] == -1:
            continue
        #print(maze[hh][ww], "=" ,costtoone[maze[hh][ww]])
        res += costtoone[maze[hh][ww]]
print(res)


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

std::vector<uint64_t> NumberOfBurgerLayer;
std::vector<uint64_t> NumberOfBurgerPatty;

void init(uint64_t N)
{
  NumberOfBurgerLayer = std::vector<uint64_t>(N + 1, 0);
  NumberOfBurgerPatty = std::vector<uint64_t>(N + 1, 0);
  
  NumberOfBurgerLayer[0] = 1;
  NumberOfBurgerPatty[0] = 1;
  for (uint64_t n = 0; n < N; ++n) {
    NumberOfBurgerLayer[n + 1] = 2 * NumberOfBurgerLayer[n] + 3;
    NumberOfBurgerPatty[n + 1] = 2 * NumberOfBurgerPatty[n] + 1;
  }
}

// index
// |
// v
// [ B ] :: [ f(n - 1) ] :: [ P ] :: [ f(n - 1) ] :: [ B ]
// <-1->    <- l(n-1) ->    <-1->    <- l(n-1) ->    <-1->

uint64_t search(uint64_t N, uint64_t X)
{
  if (N == 0) {
    return 1;
  }
  
  if (X < 1) {
    return 0;
  } else if (X < 1 + NumberOfBurgerLayer[N - 1]) {
    return search(N - 1, X - 1);
  } else if (X < 2 + NumberOfBurgerLayer[N - 1]) {
    return NumberOfBurgerPatty[N - 1] + 1;
  } else if (X < 2 + 2 * NumberOfBurgerLayer[N - 1]) {
    uint64_t Y = X - (2 + NumberOfBurgerLayer[N - 1]);
    return NumberOfBurgerPatty[N - 1] + 1 + search(N - 1, Y);
  } else if (X < 3 + 2 * NumberOfBurgerLayer[N - 1]) {
    return NumberOfBurgerPatty[N];
  }
  
  return -1;
}

int main()
{
  uint64_t N, X;
  std::cin >> N >> X;
  
  init(N);
  
  uint64_t patties = search(N, X - 1);
  std::cout << patties << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>


#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5 + 10;
const int inf = 1e9 + 7;

int n, m, x, y, f, u[N], cnt;

vector <int> g[N];

void dfs( int v )
{
    u[v] = 1;
    for( int i = 0; i < sz(g[v]); i++ )
    {
        int to = g[v][i];
        if( !u[to] )
        {
            dfs(to);
        }
    }
}

main()
{
    scanf("%d%d", &n, &m);
    for( int i = 1; i <= n; i++ )
    {
        scanf("%d", &x);
        for( int j = 1; j <= x; j++ )
        {
            scanf("%d", &y);
            g[y + n].pb(i);
            g[i].pb(y + n);
        }
    }
    dfs(1);
    for( int i = 1; i <= n; i++ )
        if( !u[i] )
        {
            puts("NO");
            return 0;
        }
    puts("YES");
}


Measured memory_bytes: 9088
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using uInt = long long unsigned int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        string s;
        cin >> s;
        bool f = s[2] == s[3] && s[4] == s[5];
        if (f) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
import java.io.*;
import java.util.StringTokenizer;






public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int N = in.nextInt();

        String Lucas [] = new String [N+2];
        Lucas[0] = "2";
        Lucas[1] = "1";

        for (int i = 2; i <= N+1; i++)
        {
            String L1 = Lucas[i-1];
            String L2 = Lucas[i-2];

            long newL1 = Long.valueOf(L1);
            long newL2 = Long.valueOf(L2);

            long L3 = newL1 + newL2;

            Lucas[i] = Long.toString(L3);
        }

        System.out.println(Lucas[N]);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)cin>>a.at(i);
    sort(a.begin(),a.end());
    priority_queue<P> p;
    for(int i=1;i<n;i++){
        if(a.at(i-1)==a.at(i)){p.push(P(a.at(i-1),a.at(i)));i++;}
    }
    if(p.size()<2)cout<<0<<endl;
   else { P p1=p.top();p.pop();
          P p2=p.top();p.pop();
          cout<<p1.first*p2.first<<endl;
   }
}

Measured memory_bytes: 2168
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
using namespace std;
int read(){
	int nm=0,fh=1;char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
int n,m,fs[M],nt[M],ans,to[M],p[M],tmp,D[M];
void link(int x,int y){nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;}
void DFS(int x){
	D[x]=1;
	for(int i=fs[x];i!=-1;i=nt[i]){
		DFS(to[i]),D[x]=max(D[x],D[to[i]]+1);
	}
	if(D[x]==m&&p[x]!=1) ans++,D[x]=0;
}
int main(){
	n=read(),m=read(),p[1]=read(),memset(fs,-1,sizeof(fs));
	for(int i=2;i<=n;i++) p[i]=read(),link(p[i],i);
	for(int i=fs[1];i!=-1;i=nt[i]) DFS(to[i]);
	printf("%d\n",ans+(p[1]!=1));
	return 0;
}

Measured memory_bytes: 5760
/*#### bits/stdc++.h */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<deque>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
/*####*/

/*#### modular_arithmetic */
class modular_arithmetic{
public:
	int mod, range;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	void set_mod(int _mod){mod = _mod;}
	int add(int x,int y){return (x+y)%mod;}
	int sub(int x,int y){return (x-y+mod)%mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
};
/*####*/
modular_arithmetic ma;
void addto(int&x,int y){
	x = ma.add(x,y);
}

#define ran 400
int n;
int fac[ran];
int a[ran],b[ran],c[ran],posA[ran],posB[ran];
int dp[ran][ran][136][4];
void upd(int A,int B,int C,int t,int w){
	if(A > n || B > n || C > n/3 || C < 0)return;
	addto(dp[A][B][C][t],w);
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d",&a[i]);
		posA[a[i]] = i;
	}
	for(int i=1; i<=n; i++){
		scanf("%d",&b[i]);
		posB[b[i]] = i;
	}
	fac[0] = 1;
	for(int i=1; i<=n; i++)
		fac[i] = ma.mul(fac[i-1], i);
	dp[1][1][0][0] = 1;
	int res = 0;
	for(int A=1; A<=n; A++){
		int sum = A;
		for(int B=1; B<=n; B++){
			if(posA[b[B]] > A) sum++;
			for(int C=0; C<=n/3; C++)for(int t=0; t<4; t++){
				int now = dp[A][B][C][t];
				if(now == 0)continue;
//				printf("%d %d %d %d\n",A,B,C,t,now);
				if(t == 0){
					if(a[A] == b[B] || posB[a[A]] < B || posA[b[B]] < A)continue;
					if(sum + (C+1) == n){
						addto(res, ma.mul(now, fac[C+1]));
					}else{
						upd(A+1, B+1, C+1, 0, now);
						upd(A+1, B+1, C+1, 1, now);
						upd(A+1, B+1, C+1, 2, now);
						upd(A+1, B+1, C+1, 3, now);
					}
				}else
				if(t == 1){
					if(posB[a[A]] < B)continue;
					if(posA[b[B]] <= A){
						upd(A, B+1, C, 0, now);
						upd(A, B+1, C, 1, now);
					}else{
						upd(A, B+1, C-1, 0, ma.mul(now, C));
						upd(A, B+1, C-1, 1, ma.mul(now, C));
					}
				}else
				if(t == 2){
					if(posA[b[B]] < A)continue;
					if(posB[a[A]] <= B){
						upd(A+1, B, C, 0, now);
						upd(A+1, B, C, 2, now);
					}else{
						upd(A+1, B, C-1, 0, ma.mul(now, C));
						upd(A+1, B, C-1, 2, ma.mul(now, C));
					}
				}
				else{
					if(posB[a[A]] < B){
						upd(A+1, B, C, 1, now);
						upd(A+1, B, C, 3, now);
					}else{
						upd(A+1, B, C-1, 1, ma.mul(now, C));
						upd(A+1, B, C-1, 3, ma.mul(now, C));
					}
				}
			}
		}
	}
	for(int i=1; i<=n; i++)if(i%3!=0)
		res = ma.mul(res, i);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 338176
h,w,k=gets.chomp.split(" ").map(&:to_i)
ans = 0
arr = Array.new()
h.times do
  arr.push($stdin.gets.chomp.split(''))
end
[0, 1].repeated_permutation(h) do |nuru_h|
  arr_sousa = []
  h.times do |i|
    if nuru_h[i] == 0
      arr_sousa.push(arr[i])
    end
  end
  [0, 1].repeated_permutation(w) do |nuru_w|
  arr_d = arr_sousa.dup
  arr_d = arr_d.transpose
    w.times do |j|
      if nuru_w[j] == 1
        arr_d[j] = []
      end
    end

    arr_d.flatten!
    if  arr_d.count("#") == k
      ans += 1
    end
  end
end
puts ans

Measured memory_bytes: 14400
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,d,e,f;
	scanf("%lld %lld %lld",&a,&b,&c);
	d=4*a*b;
	e=c-a-b;
	if(e<0)
		printf("No");
	else 
	{
	f=e*e;
	if(d<f)
	{
		printf("Yes");
	}
	else
	{ 
		printf("No");
	}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;

  double m = 60 * H + M;

  // double As = m / (12 * 60);
  // double Al = m / 60;
  
  double theta = abs(11 * m / (12 * 60)) * 2 * M_PI;

  double result = sqrt(pow(A,2) + pow(B, 2) - 2 * A * B * cos(theta));

  cout << setprecision(20) << result << endl;

  return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> coins(m);
    vector<int> dp(n+1, 500000);
    for (int i = 0; i < m; ++i) {
        cin >> coins[i];
    }
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (const auto coin : coins) {
            if (coin + i > n) continue;
            dp[coin + i] = min(dp[coin + i], dp[i] + 1);
        }
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 3200
/* 
Mohit Dhattarwal
*/
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define gcd(a,b) __gcd(a,b)
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define filewr() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
 
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,ll> psl;
typedef pair<ll,string> pls;
 
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}
 
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
 
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
const ld PI = 3.1415926535897932384626433832795;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;

void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i =0; i<n; i++)
	{
		cin>>a[i];
	}
	sort(a, a+n);
	ll sum = 0;
	for(ll i =0; i<k; i++)
	{
		sum+=a[i];
	}
	cout<<sum<<'\n';
}

int main(){
	fastio();
	ll t;
	t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int sum=1;
  vector<int> vct(n);
  for(int i=0;i<n;i++) cin >> vct[i];
  sort(vct.begin(),vct.end());
  reverse(vct.begin(),vct.end());
  int A=vct[0];
  for(int i=0;i<n;i++){
   if(vct[i]<A)sum++; A=vct[i];
  }
  cout<<sum<<endl;
  }

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  ll h,w; cin >> h >> w;
  ll s = h * w;

  if(w==1 || h==1){
    cout << 1 << endl;
    return 0;
  }
  
  if(h%2!=0 && w%2!=0){
    cout << (ll)((s-1)/2 + 1) << endl;
  }else{
    cout << (ll) s / 2 << endl;
  }



  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
int ask;
scanf("%d",&ask);
for(int i=1;i<ask+1;i++){
if(i%3==0)printf(" %d",i);
else if(i%10==3)printf(" %d",i);
else if(i/10%10==3)printf(" %d",i);
else if(i/100%10==3)printf(" %d",i);
else if(i/1000%10==3)printf(" %d",i);
}
printf("\n");
}

Measured memory_bytes: 1028
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,string> P;
map<string,int> mp;
int n,b;
string a,s;
vector<P> v;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    }
    for(auto x:mp){
        a=x.first,b=x.second;
        //cout<<a<<" "<<b<<endl;
        v.push_back({-b,a});
    }
    sort(v.begin(),v.end());
    int A=v[0].first;
    for(auto x:v){
        if(x.first==A)cout<<x.second<<endl;
    }
}


Measured memory_bytes: 28916
#include <stdio.h>
#define N 100

void insertionSort(int*, int);

int main(){
  int i,A[N],n;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  insertionSort(A,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i==n-1)break;
    printf(" ");
  }
  printf("\n");
  return 0;
}

void insertionSort(int* A, int n){
  int i,j,v,k;
  for(i=1;i<n;i++){
    v=A[i];
    j=i-1;
    for(k=0;k<n;k++){
      printf("%d",A[k]);
      if(k==n-1)break;
      printf(" ");
    }
    printf("\n");
  
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
  }
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


vector<string> split(const string &s, char c = ' ') {
	vector<string> ret;
	stringstream ss(s);
	string t;
	while (getline(ss, t, c)) {
		ret.push_back(t);
	}
	return ret;
}



int main() {
	string s;
	vector<string> v;
	int p, t, n;
	while (getline(cin, s)) {
		v = split(s);
		if (v[0] == "0")break;
		p = 0;
		n = 0;
		for (int i = 0; i < v.size(); i++) {
			t = atoi(v[i].c_str());
			//cout << " " << t;
			if (t < 10)p += t;
			else p += 10;
			if (t == 1)n++;
		}
		//cout << endl;
		while (n > 0) {
			if (p + 10 <= 21)p += 10;
			n--;
		}
		if (p > 21)p = 0;
		cout << p << endl;
	}
}

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

class UnionFind {
public:
    UnionFind(int n) : par(n), rnk(n, 1) {
        rep(i, 0, n) par[i] = i;
    }

    int root(int a) {
        if (par[a] == a) return a;
        return par[a] = root(par[a]);
    }

    void unite(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rnk[a] > rnk[b]) swap(a, b);
        par[a] = b;
        rnk[b] += rnk[a];
    }

    bool same(int a, int b) {
        return root(a) == root(b);
    }

    int size(int a) {
        return rnk[a];
    }

private:
    vector<int> par, rnk;
};

int main() {
    int n, k, l;
    cin >> n >> k >> l;

    UnionFind road(n);
    rep(i, 0, k) {
        int p, q;
        cin >> p >> q;
        road.unite(--p, --q);
    }

    UnionFind railway(n);
    rep(i, 0, l) {
        int r, s;
        cin >> r >> s;
        railway.unite(--r, --s);
    }

    map<pair<int, int>, int> mp;
    rep(i, 0, n) mp[make_pair(road.root(i), railway.root(i))]++;

    rep(i, 0, n) {
        cout << mp[make_pair(road.root(i), railway.root(i))] << (i + 1 == n ? "\n" : " ");
    }
    
    return 0;
}

Measured memory_bytes: 15104
import java.util.*;
class Main
{
		public static void main(String[] args) 
		{
			Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			
			int s1 = s.charAt(0);
			int s2 = s.charAt(1);
			int s3 = s.charAt(2);
          	
          int total = 700;
          
          if(s1!='x'){
            total+=100;
          }
          if(s2!='x'){
            total+=100;
          }
          if(s3!='x'){
            total+=100;
          }
          
          System.out.println(total);
        }
}

Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s1 = sc.next();
		String s2 = sc.next();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < s1.length(); i++) {
			if(s1.substring(i, i+1).equals(s2.substring(i, i+1))) {
				sb.append("T");
			} else {
				sb.append("Y");
				i++;
			}
		}
		String joge = sb.toString();
		int num[] = new int[joge.length()];
		Arrays.fill(num, 1);
		char[] isTate = joge.toCharArray();
		num[0] = isTate[0]=='T' ? 3 : 6;
		for(int i = 1; i < isTate.length; i++) {
			if(isTate[i-1]=='T'&&isTate[i]=='T') {
				num[i]=2;
			} else if(isTate[i-1]=='T'&&isTate[i]=='Y') {
				num[i]=2;
			} else if(isTate[i-1]=='Y'&&isTate[i]=='T') {
				num[i]=1;
			} else if(isTate[i-1]=='Y'&&isTate[i]=='Y') {
				num[i]=3;
			}
		}
		Long count = 1L;
		for(int i : num) {
			count = (count * i) % 1000000007;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23380
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

f (a,b) (c,d) = (a+c, max (a+c+d) (b+d))

main = do
    getInt
    zip <$> getInts <*> getInts >>= print . snd . foldl f (0,0)

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int n;
    vector<int> abc(3);

    cin >> n;
    cin >> abc[0] >> abc[1] >> abc[2];

    vector<pair<int, int>> s;

    for (int i = 0; i < n; ++i) {
        string s_temp;
        cin >> s_temp;
        if (s_temp == "AB") s.emplace_back(0, 1);
        else if (s_temp == "AC") s.emplace_back(0, 2);
        else s.emplace_back(1, 2);
    }

    string ans;
    auto add = [&](int a, int b) {
        abc[a]++;
        abc[b]--;
        ans += 'A' + a;
    };

    s.emplace_back(1, 0);
    for (int i = 0; i < n; ++i){
        if (abc[s[i].first] == 0 && abc[s[i].second] == 0) {
            cout << "No" << endl;
            return 0;
        } else if (abc[s[i].first] == 0) {
            add(s[i].first, s[i].second);
        }
        else if (abc[s[i].second] == 0) {
            add(s[i].second, s[i].first);
        }
        else {
            if (s[i].first == s[i+1].first || s[i].first == s[i+1].second) {
                add(s[i].first, s[i].second);
            } else {
                add(s[i].second, s[i].first);
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4332
n,k = map(int,input().split())
s = input()
if s[k-1:k] == "A":
    s = s[:k-1] + "a" + s[k:]
elif s[k-1:k] == "B":
    s = s[:k-1] + "b" + s[k:]
else:
    s = s[:k-1] + "c" + s[k:]
print(s)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

#define FOR(i,n) for(ll i=0;i<n;i++)

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   int X;
   cin >> X;
   for(ll i=X;i>=1;i--){
      for(ll j=i;j>=2;j--){
         ll i_ = i;
         ll count = 0;
         while(true){
            if(i_ % j == 0){
               i_ /= j;
               count++;
            }
            else break;
            if(i_ == 1&&count > 1){
               cout << i << endl;
               return 0;
            }
         }
      }
   }
   cout << 1 << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const MAXA = 1e6;
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> c(MAXA+1, 0), a(N, 0);
  for(int i = 0; i < N; ++i) {
    std::cin >> a[i];
    ++c[a[i]];
  }
  for(int i = 2; i <= MAXA; ++i) {
    for(int j = 1; j*i <= MAXA; ++j) c[j*i] += c[j];
  }
  int ans = 0;
  for(int Ai: a) if(c[Ai]==1) ++ans;
  fin(ans);
  return 0;
}


Measured memory_bytes: 8312
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  var ans = 0L
  for (i <- 1 to n) {
    val l = (n / i).toLong
    ans += i * ((l * (l+1)) / 2)
  }
  println(ans)
}


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

int main() {
	int n,q,m,d,saidai,ans;
	while(1){
		saidai = 0;
		cin >> n >> q;
		if(n == 0)break;
		int a[101] = {};
		for(int i = 0;i < n;i++){
			cin >>m;
			for(int j = 0;j < m;j++){
				cin >> d;
				a[d]++;
			}
		}
		for(int i = 1;i < 101;i++){
			if(saidai < a[i]){
			saidai = a[i];
			ans = i;
			}
		}
		if(saidai >= q)cout << ans << endl;
		else cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

int main(){
	fast;
	
	ll int n,r;
	cin>>n>>r;
	
	ll int cnt=0;
	while(n!=0){
		n=n/r;
		cnt++;
	}
	
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
long long Case1(int h, int w) {
    if (h % 3 == 0) {
        return 0;
    } else {
        return w;
    }
}
long long Case2(int h, int w) {
    long long block[3];
    long long mindiff = 1e10;
    for (long long i = 1; i < h; ++i) {
        block[0] = i * w;
        block[1] = (w / 2 + w % 2) * (h - i); // () is important!
        block[2] = w / 2 * (h - i);
        mindiff = min(mindiff, max(block[0], block[1]) - min(block[0], block[2])); //bl1 >= bl2
    }
    return mindiff;
}
int main() {
    int h, w; cin >> h >> w;
    cout << min({Case1(h, w), Case1(w, h), Case2(h, w), Case2(w, h)}) << endl;
    return 0;
}




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

vector<vector<ll>> edges;
vector<ll> value;
vector<pair<ll, ll>> conds;
bool flag;

pair<ll, ll> solve(ll curr, ll pre) {
    pair<ll, ll> cond{ INT_MIN, INT_MAX };
    if (value[curr] != -1) {
        cond.first = cond.second = value[curr];
    }
    for (ll i = 0; i < edges[curr].size(); i++) {
        ll next = edges[curr][i];
        if (next == pre) {
            continue;
        }
        auto next_cond = solve(next, curr);
        cond.first = max(cond.first, next_cond.first);
        cond.second = min(cond.second, next_cond.second);
        if (cond.first > cond.second) {
            flag = false;
            return { INT_MAX, INT_MIN };
        }
    }
    conds[curr] = cond;
    return { cond.first - 1, cond.second + 1 };
}

void write(ll curr, ll pre) {
    if (pre != -1) {
        if (conds[curr].first <= value[pre] + 1 && value[pre] + 1 <= conds[curr].second) {
            value[curr] = value[pre] + 1;
        } else if(conds[curr].first <= value[pre] - 1 && value[pre] - 1 <= conds[curr].second) {
            value[curr] = value[pre] - 1;
        } else {
            flag = false;
            return;
        }
    }

    for (ll next : edges[curr]) {
        if (next == pre) {
            continue;
        }
        write(next, curr);
    }
}

int main() {
    ll N;
    cin >> N;
    value.resize(N, -1);
    conds.resize(N);
    edges.resize(N);
    for (ll i = 0; i < N - 1; i++) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        edges[A].push_back(B);
        edges[B].push_back(A);
    }

    ll K;
    cin >> K;
    vector<ll> V(K), P(K);
    for (ll i = 0; i < K; i++) {
        cin >> V[i] >> P[i];
        V[i]--;
        value[V[i]] = P[i];
    }

    flag = true;
    solve(V[0], -1);

    if (!flag) {
        cout << "No" << endl;
    } else {
        write(V[0], -1);
        if (!flag) {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        for (ll i = 0; i < N; i++) {
            cout << value[i] << endl;
        }
    }
}

Measured memory_bytes: 15360
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vi x(N),y(N);
  rep(i,N) {
    cin >> x[i] >> y[i];
  }
  int ans = -INF;
  {
    vi z(N);
    int mi=INF,ma=-INF;
    rep(i,N) {
      z[i]=x[i]-y[i];
      chmin(mi,z[i]);
      chmax(ma,z[i]);
    }
    chmax(ans,ma-mi);
  }
  {
    vi z(N);
    int mi=INF,ma=-INF;
    rep(i,N) {
      z[i]=x[i]+y[i];
      chmin(mi,z[i]);
      chmax(ma,z[i]);
    }
    chmax(ans,ma-mi);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5632
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int main()
{

    int x,ans=0;
    scanf("%d",&x);
    
    while(x>=500)
    {
        ans=ans+1000;
        x=x-500;
    }
    while(x>=5)
    {
        ans=ans+5;
        x=x-5;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll x;
  cin >> x;
  ll m = 100;
  ll ans = 0;
  while(m < x){
    ans++;
    m *= 1.01;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second



using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 


int pow(int a, int b)
{
    int prod=1;
    int mult=a%mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod;
        }
        mult*=mult;
        mult%=mod;
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int mod)
{
    return pow(q, mod-2);
}



bool is_palindrome(string s)
{
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[n-1-i])
            return false;
    }
    return true;
}

signed main()

{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
       cout.tie(NULL);
     #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        }
     #endif
    auto clk=clock(); 
    // -------------------------------------Code starts here---------------------------------------------------------------------     
    
    string s;
    cin>>s;
    int n=s.size();
    if(is_palindrome(s) && (is_palindrome(s.substr(0, (n-1)/2)))&& is_palindrome(s.substr((n+1)/2, n)))
    {
        cout<<"Yes";
    }
    else
        cout<<"No";

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int k;
	cin >> k;
	int even = k/2;
	cout << even*(k-even) << endl;
}

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

LL digits(LL num) {
  LL count = 0;

  while (num > 0) {
    num /= 10;
    count++;
  }

  return count;
}

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

  LL ans = 100;
  LL N;
  cin >> N;

  for (LL A = 1; A * A <= N; A++) {
    if (N % A) {
      continue;
    }

    LL B = N / A;
    LL cur = max(digits(A), digits(B));
    ans = min(ans, cur);
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int cnt[SIZE];
int main(){
    DRI(N);
    int mi=N,ma=0;
    REP(i,N){
        DRI(x);
        cnt[x]++;
        ma=max(ma,x);
        mi=min(mi,x);
    }
    REP(i,ma+1){
        cnt[max(i,ma-i)]--;
    }
    REP(i,(ma+1)/2){
        if(cnt[i])return 0*puts("Impossible");
    }
    REP(i,N)
        if(cnt[i]<0)return 0*puts("Impossible");
    if(cnt[(ma+1)/2])return 0*puts("Impossible");
    return 0*puts("Possible");
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,m;
cin >> n >> m;
cout << (n-1)*(m-1) << endl;
return 0;
}


Measured memory_bytes: 256
Uses math;
var n, m, i, a : int64;
    dp : array[1..100010] of int64;
    remainder : int64;
begin
  remainder := 1000000007;
  readln(n, m);
  
  for i := 1 to 100010 do dp[i] := 0;
  for i := 1 to m do begin
    read(a);
    dp[a] := -1;
  end;
  dp[0] := 1;
  
  for i := 0 to 100005 do begin
    if dp[i] = -1 then Continue;
    if dp[i+1] <> -1 then dp[i+1] := (dp[i+1] + dp[i]) mod remainder;
    if dp[i+2] <> -1 then dp[i+2] := (dp[i+2] + dp[i]) mod remainder;
  end;
  writeln(dp[n]);
end.


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
namespace QiFeng233{
	const int maxn=4010;
	typedef long long ll;
	ll ans;
	int n;
	char s[maxn];
	ll sum[maxn][4];//1=R,2=G,3=B
	void solve(){
		scanf("%d",&n);
		scanf("%s",s+1);
		for(int i=1;i<=n;++i){
			sum[i][1]=sum[i-1][1];
			sum[i][2]=sum[i-1][2];
			sum[i][3]=sum[i-1][3];
			if(s[i]=='R')++sum[i][1];
			if(s[i]=='G')++sum[i][2];
			if(s[i]=='B')++sum[i][3];
		}
		for(int i=1;i<=n-2;++i){
			for(int j=i+1;j<=n-1;++j){
				if(s[i]=='R'){
					if(s[j]=='G')ans+=sum[n][3]-sum[j][3];
					if(s[j]=='B')ans+=sum[n][2]-sum[j][2];
				}
				else if(s[i]=='G'){
					if(s[j]=='R')ans+=sum[n][3]-sum[j][3];
					if(s[j]=='B')ans+=sum[n][1]-sum[j][1];
				}
				else if(s[i]=='B'){
					if(s[j]=='G')ans+=sum[n][1]-sum[j][1];
					if(s[j]=='R')ans+=sum[n][2]-sum[j][2];
				}
			}
		}
		for(int i=1;i<=n-2;++i){
			for(int j=i+1;j<=n-1;++j){
				int k=j+j-i;
				if(k>n)continue;
				if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])--ans;
			}
		}
		printf("%lld",ans);
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

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

fn main() {
    let n: usize = read();
    let a: usize = read();
    let b: usize = read();
    print!("{} ", std::cmp::min(a, b));
    if n <= a + b {
        println!("{}", a + b - n);
    } else {
        println!("{}", 0);
    }
}

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


Measured memory_bytes: 4352
def fact(n):
  ret=1
  for i in range(2,n+1):
    ret=ret*i
  return ret

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
cnt1=0
cnt2=0
checked1=[0]*(n+1)
checked2=[0]*(n+1)
for i in range(n):
  checked1[arr1[i]]=1
  checked2[arr2[i]]=1
  cnt1+=(arr1[i]-1-sum(checked1[:arr1[i]]))*fact(n-i-1)
  cnt2+=(arr2[i]-1-sum(checked2[:arr2[i]]))*fact(n-i-1)
print(abs(cnt1-cnt2))

Measured memory_bytes: 3064
using System;

namespace ABC065B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int count = 0;
            int[] next = new int[N];
            int[] light = new int[N];
            for(int i=0;i<N;i++){
                next[i] = int.Parse(Console.ReadLine())-1;
            }
            int tmp = 0; //light
            light[0] = 1;
            for(int i=0;i<N;i++){
                count++;
                tmp = next[tmp];
                if(tmp == 1) break;
                if(light[tmp] == 1) {count = -1; break;} 
                light[tmp] = 1;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 15292
#include <stdio.h>

int main()
{
 int S,W;
scanf("%d %d",&S, &W);

 if(W >= S){	 	//狼の数が、羊の数以上の場合
  printf("unsafe\n");
 }
 else if(S > W){			//羊の数が、狼の数より多い場合
  printf("safe\n");
 }

 return 0;
}

Measured memory_bytes: 1664