akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007

bool dbgflag = false; //debug

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

  int n;
  cin >> n;
  vector<vector<ll>> distance(n, vector<ll>(n));
  vector<vector<bool>> existRoad(n, vector<bool>(n, true));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> distance[i][j];
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      //i->jで任意の点kを経由していくとき、もしAij>経由した経路が存在すれば-1, 同じ長さの辺が存在すればこの辺は不要（長い辺なので先に消されるべき）
      if (i == j) continue;
      ll d = distance[i][j];
      ll temp;
      for (int k = 0; k < n; k++) {
        if ((i == k) || (j == k)) continue;
        temp = distance[i][k] + distance[k][j];
        if (d > temp) {
          cout << -1 << endl;
          return 0;
        }
        if (d == temp) {
          existRoad[i][j] = false;
          break;
        }
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (existRoad[i][j]) ans += distance[i][j];
    }
  }
  
  cout << ans/2 << endl;
}


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

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

#include <vector>
#include <utility>


#include <algorithm>


typedef pair< pair<int, int>, pair<int, int> > cbcol;
map< cbcol , int > cube_cnt;

int n;
int c[410][4];
int tgt[4][4];
int tmp[4];
int rot_to[4][4];


int can[4];
int counts[4];


void rotate(int *c) {
	int t = c[3];
	for (int i = 2; i >= 0; i--) c[i+1] = c[i];
	c[0] = t;
}

void rotate(int idx) {
	rotate(c[idx]);
}

void solve() {
	scanf("%d", &n);
	REP(i,n) REP(j,4) scanf("%d", &c[i][j]);

	REP(i,n) {
		set<cbcol> seen;
		REP(j,4) {
			cbcol cur = {{c[i][0], c[i][1]}, {c[i][2], c[i][3]} };
			if (!seen.count(cur)) {
				seen.insert(cur);
				cube_cnt[cur]++;
			}
			rotate(i);
		}
	}
	
	long long ans = 0;
	REP(front, n) {
		for (int back = 0; back < front; back++) {
			for (int ro = 0; ro < 4; ro++) {

				tgt[0][0] = c[front][0];
				tgt[0][1] = c[back][1];
				tgt[0][2] = c[back][0];
				tgt[0][3] = c[front][1];

				tgt[1][0] = c[front][1];
				tgt[1][1] = c[back][0];
				tgt[1][2] = c[back][3];
				tgt[1][3] = c[front][2];

				tgt[2][0] = c[front][3];
				tgt[2][1] = c[front][2];
				tgt[2][2] = c[back][3];
				tgt[2][3] = c[back][2];

				tgt[3][0] = c[back][1];
				tgt[3][1] = c[front][0];
				tgt[3][2] = c[front][3];
				tgt[3][3] = c[back][2];

				REP(i,4) counts[i] = cube_cnt[ {{tgt[i][0], tgt[i][1]}, {tgt[i][2], tgt[i][3]}} ];

				REP(i,4) can[i] = 0;
				REP(ro, 4) {
					REP(i,4) {
						bool eq = true;
						REP(k,4) if (tgt[i][k] != c[front][k]) eq = false;
						can[i] += eq;
					}
					rotate(front);
				}
				REP(i,4) if (can[i]) counts[i]--;

				REP(i,4) can[i] = 0;
				REP(ro, 4) {
					REP(i,4) {
						bool eq = true;
						REP(k,4) if (tgt[i][k] != c[back][k]) eq = false;
						can[i] += eq;
					}
					rotate(back);
				}
				REP(i,4) if (can[i]) counts[i]--;

				REP(i,4) {
					REP(j,4) {
						rot_to[i][j] = 0;
						REP(k,4) tmp[k] = tgt[i][k];

						for (int ro = 0; ro < 4; ro++) {
							bool eq = true;
							REP(k,4) if (tmp[k] != tgt[j][k]) eq = false;
							rot_to[i][j] += eq;
							rotate(tmp);
						}
					}
				}


				long long th = 1;
				for (int i = 0; i < 4; i++) {
					int sub = 0;
					for (int j = 0; j < i; j++) if (rot_to[j][i]) sub++;
					th = (th * (counts[i]-sub) * rot_to[i][i]);
				}
				ans += th;
				
				rotate(back);
			}
		}
	}

	printf("%lld\n", ans/3);
}


int main() {
    solve();
}




Measured memory_bytes: 80128
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < n; i++) {
			map.put(sc.nextInt(), i + 1);
		}
		for (int i = 0; i < n; i++) {
			System.out.print(map.get(i + 1) + " ");
		}
		System.out.println();

		sc.close();
	}

}


Measured memory_bytes: 76272
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        string ans = "";
        while (N != 0)
        {
            if (N % 2 != 0)
            {
                N--;
                ans = "1" + ans;
            }

            else
            {
                ans = "0" + ans;
            }
            N /= -2;
        }
        if (ans == "") ans = "0";
        Console.WriteLine(ans);
        return;
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = strReverce(ret);
        return ret;
    }

}


Measured memory_bytes: 13140
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define boostIO                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, b, a) for (int i = b; i >= a; i--)
#define sz(v) (v.empty() ? 0 : v.size())
#define all(v) v.begin(), v.end()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define trav(a, x) for (auto &a : x)
#define fi first
#define se second
#define pb push_back
#define int long long
#define mod 1000000007
#define rem 998244353
#define maxn 500005
const int INF = 1e18;
typedef pair<int, int> pii;


signed main() {
    boostIO;
    int n, x, t;
    cin >> n >> x >> t;
    if(n%x == 0){
        cout << ((n / x) * t) << endl;
    }
    else{
        cout << ((n / x + 1) * t) << endl;
    }
    return 0;
}
// XD

Measured memory_bytes: 3632
n = int(input())
tmp = list(map(int, input().split()))
a = [0] + tmp + [0]

# Total Cost
c = 0
for i in range(len(a)-1):
    c += abs(a[i+1] - a[i])

# Partial Cost
for i in range(len(a)-1):
    if i == 0:
        continue
    elif i == len(a)-1:
        continue
    else:
        print(c - abs(a[i+1] - a[i]) - abs(a[i]-a[i-1]) + abs(a[i+1]-a[i-1]))

Measured memory_bytes: 14048
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int  a, b;
    while (cin >>a>>b)
    {
        for (int i=b*10;i<b*10+10;i++)
    {
        if (int(1.0*i*8/100)==a) {cout<<i<<'\n'; return 0;}
    }

    cout<<"-1\n";
    return 0;
    }
}



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

struct FenwickTree {
	typedef int T;
	vector<T> v;
	void init(int n) { v.assign(n, 0); }
	void add(int i, T x) {
		for(; i < (int)v.size(); i |= i + 1) v[i] += x;
	}
	T sum(int i) const {	//[0, i)
		T r = 0;
		for(-- i; i >= 0; i = (i & (i + 1)) - 1) r += v[i];
		return r;
	}
	T sum(int left, int right) const {	//[left, right)
		return sum(right) - sum(left);
	}
};

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<int> p(N);
		for(int i = 0; i < N; ++ i) {
			scanf("%d", &p[i]), -- p[i];
		}
		int BlockSize = 500;
		int NumBlocks = N / BlockSize + 1;
		vector<vector<long long> > memo(NumBlocks, vector<long long>(N));
		FenwickTree ft;
		for(int bi = 0; bi < NumBlocks; ++ bi) {
			vector<long long> &v = memo[bi];
			int i = bi * BlockSize;
			{
				ft.init(N);
				long long sum = 0;
				for(int j = i; j < N; ++ j) {
					sum += (j - i) - ft.sum(p[j]);
					v[j] = sum;
					ft.add(p[j], 1);
				}
			}
			{
				ft.init(N);
				long long sum = 0;
				for(int j = i - 1; j >= 0; -- j) {
					sum += ft.sum(p[j]);
					v[j] = sum;
					ft.add(p[j], 1);
				}
			}
		}
		vector<vector<pair<int, int> > > sortedBlocks(NumBlocks);
		vector<int> rankInBlock(N, -1);
		for(int bi = 0; bi < NumBlocks; ++ bi) {
			int L = bi * BlockSize, R = min((bi + 1) * BlockSize, N);
			vector<pair<int, int> > &v = sortedBlocks[bi];
			v.resize(R - L);
			for(int i = L; i < R; ++ i)
				v[i - L] = make_pair(p[i], i);
			sort(v.begin(), v.end());
			for(int i = 0; i < R - L; ++ i)
				rankInBlock[v[i].second] = i;
		}
		int Q;
		scanf("%d", &Q);
		for(int ii = 0; ii < Q; ++ ii) {
			int l; int r;
			scanf("%d%d", &l, &r), -- l, -- r;
			int bl = (l + BlockSize - 1) / BlockSize, br = (r + 1) / BlockSize;
			long long ans = 0;
			if(bl > br) {
				ft.init(BlockSize);
				for(int i = r; i >= l; -- i) {
					ans += ft.sum(rankInBlock[i]);
					ft.add(rankInBlock[i], 1);
				}
			} else {
				int L = bl * BlockSize, R = br * BlockSize;
				ans += memo[bl][r];
				ans += memo[br][l];
				if(bl < br)
					ans -= memo[bl][R - 1];
				if(l < L && R <= r) {
					const vector<pair<int, int> > &v = sortedBlocks[bl - 1], &w = sortedBlocks[br];
					int nv = (int)v.size(), nw = (int)w.size();
					for(int i = 0, j = 0, cnt = 0; i < nv; ++ i) {
						for(; j < nw && w[j].first < v[i].first; ++ j)
							cnt += w[j].second <= r;
						if(l <= v[i].second)
							ans += cnt;
					}
				}
			}
			printf("%lld\n", ans); fflush(stdout);
		}
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin>>n;
    vector<int> arr(n,0);
    vector<int> sum(n,0);
    int i,j;
    for(i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    long count = 0;
    count = arr[n/2] - arr[(n-1)/2];
    cout<<count<<"\n";
    return 0;
}


Measured memory_bytes: 1024
n=int(input())
p=[int(input()) for _ in range(n)]
q=[0]*(n+1)

for i in range(n):
    q[p[i]]=i+1
cnt=1
curcnt=0
for i in range(1,n+1):
    if q[i]>q[i-1]:
        curcnt+=1
        cnt=max(cnt,curcnt)
    else:
        curcnt=1

print(n-cnt)

Measured memory_bytes: 89740
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <queue>
#include <iostream>


#define MAX_H 1100
#define MAX_W 1100


struct status
{
  int x;
  int y;
  int step;
  int n;
};


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

  
int H,W,N;
char maze[MAX_H][MAX_W];
int flag[MAX_H][MAX_W];
int xs,ys;
std::queue<status> Q;


int BFS();

int main(int argc, char* argv[])
{
  //freopen("in.txt","r",stdin);
  while(std::cin>>H>>W>>N)
    {

      std::cin.get();
      //std::cout << H << W << N << std::endl;

      for(int i = 0 ; i < H ; i++)
	std::cin.getline(maze[i],MAX_W);

      //for(int i = 0 ; i < H ; i++)
      //	std::cout << maze[i] << std::endl;

      for(int j = 0 ; j < H ; j++)
	for(int i = 0 ; i < W ; i++)
	  if(maze[j][i] == 'S' )
	    {
	      xs = i;
	      ys = j;
	      break;
	    }
      memset(flag,0,sizeof(flag));
      std::cout<<BFS()<<std::endl;
      
    }
}


int BFS()
{

  while(Q.empty()==false)
    Q.pop();
  status start;
  start.x = xs;
  start.y = ys;
  start.step = 0;
  start.n = 1;

  Q.push(start);

  while(Q.empty() == false )
    {
      status tmp = Q.front();
      Q.pop();


      for(int i = 0 ; i < 4 ; i++)
	{
	  int cx = tmp.x + dx[i];
	  int cy = tmp.y + dy[i];
	  int cstep = tmp.step + 1;
	  int cn = tmp.n;

	  if(cx < 0 || cx >= W ) continue;
	  if(cy < 0 || cy >= H ) continue;
	  if(maze[cy][cx] == 'X' ) continue;

	  if( (maze[cy][cx] - '0') == tmp.n )
	    cn = tmp.n + 1;
	  else
	    cn = tmp.n;

	  if(cn == N+1)
	    return cstep;

	  
	  
	  if(flag[cy][cx] >= cn  ) continue;

	  flag[cy][cx] = cn;

	  status nstatus;
	  nstatus.x = cx;
	  nstatus.y = cy;
	  nstatus.n = cn;
	  nstatus.step = cstep;
	  Q.push(nstatus);
	  
	}
    }

  return -1;
  
}

Measured memory_bytes: 7024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		
		int a, b, menseki ,syu;
		a = sc.nextInt();
		b = sc.nextInt();
		
		menseki = a*b;
		syu = (a * 2) + ( b *2);
		
		System.out.println(menseki + " "  + syu);
		
	}

}

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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    int ans = b/c-a/c;
    if(a%c==0) ans++;
    cout<<ans;
}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const int INF = 1e+9+7;
const int H_MAX = 510;
const int W_MAX = 510;
int H,W;
vector<vector<int>> a(H_MAX,vector<int>(W_MAX,0));

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int tmp;
    rep(i,n){
        cin>>a[i];
    }

    sort(a.begin(),a.end());

    int a1,a2,a_cur;
    double ans=0;

    a1=a[n-1];

    int num = lower_bound(a.begin(),a.end()-1,(double)(a1)/2) - a.begin();
    
    if(num==0||a[num]- (double)(a1)/2< (double)(a1)/2 - a[num-1]){
        a2=a[num];
    }else{
        a2=a[num-1];
    }



    cout << a1 << " " << a2 << endl;

}


Measured memory_bytes: 1664
def main():
 
  n,k=map(int,input().split())
  r,s,p=map(int,input().split())
  t=list(input())
 
  point=dict()
  point["p"]=s  #s wins p
  point["s"]=r  #r wins s
  point["r"]=p  #p wins r
  point["checked"]=0
 
  ans=0
  for i in range(n):
    tmp=i-k
    if tmp>=0 and t[tmp]==t[i]:
      ans+=0
      t[i]="checked"
    else:
      ans+=point[t[i]]
  print(ans)
 
main()

Measured memory_bytes: 4084
def func(a,b,c,d):
  result = a * c
  if a * d > result:
    result = a * d
  if b * c > result:
    result = b * c
  if b * d > result:
    result = b * d
  return result

if __name__ == "__main__":
  inputStr = input().split()
  a = int(inputStr[0])
  b = int(inputStr[1])
  c = int(inputStr[2])
  d = int(inputStr[3])
  print(func(a,b,c,d))

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c) \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 1000000007LL;

map<pair<ll, ll>, ll> memo;

ll func(ll S, ll X) {
  if (S == 0 && X == 0) return 1;
  if (S == 0 && X == 1) return 1;
  if (S == 1 && X == 0) return 1;
  if (memo.count(make_pair(S, X)) > 0) return memo[make_pair(S, X)];

  ll ret = 0;
  ret += func(S / 2, X / 2);
  ret %= MOD;
  if (S >= 1 && X >= 1) {
    ret += func((S - 1) / 2, (X - 1) / 2);
    ret %= MOD;
  }
  if (S >= 2) {
    ret += func((S - 2) / 2, X / 2);
    ret %= MOD;
  }

  return memo[make_pair(S, X)] = ret;
}

int main() {
  ll N;
  cin >> N;

  cout << func(N, N) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll l[51], p[51];
ll solve(int n, ll x){
	if(n==0) return 1;
	if(x==1) return 0;
	if(x<=l[n-1]+1) return solve(n-1, x-1);
	if(x==l[n-1]+2) return p[n-1]+1;
	if(x<=2+2*l[n-1]) return p[n-1]+1+solve(n-1, x-2-l[n-1]);
	return p[n-1]*2+1;
}
int main()
{
	int n; ll x;
	cin>>n>>x;
	l[0]=1, p[0]=1;
	for(int i=1; i<=n; i++){
		l[i]=2*l[i-1]+3;
		p[i]=2*p[i-1]+1;
	}
	cout<<solve(n, x)<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	string s; cin >> s;
	if(s.length()%2 != 0){
		cout << "No" << endl;
		return 0;
	}
	rep(i, s.length()){
		if(i%2 == 0){
			if(s[i] != 'h'){
				cout << "No" << endl;
				return 0;
			}
		} else{
			if(s[i] != 'i'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int n,m;
double g[100][100],dp[2][100],M;

int main(){
	while(cin>>n>>m&&m){
		rep(i,n)rep(j,n)cin>>g[i][j];
		rep(i,m){
			rep(j,n){
				if(!i)dp[1][j]=1;
				else{
					M=0;
					rep(k,n)M=max(M,dp[0][k]*g[k][j]);
					dp[1][j]=M;
				}
			}
			rep(j,n)dp[0][j]=dp[1][j];
			//rep(j,n)cout<<dp[0][j]<<(j<n-1?" ":"\n");
		}
		M=0;
		rep(i,n)M=max(M,dp[0][i]);
		printf("%.2f\n",M);
	}
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// random {{{ 1
ll rnd(){
    static ll x = time(0);
    x = x ^ (x << 13); x = x ^ (x >> 7);
    return x = x ^ (x << 17);
}
// }}}
// }}} 0

int main() {

    int a,b;
    Scd2(a,b);

    if( a>9||b>9 ) a=-1,b=1;
    printf ("%d\n", a*b );

    return 0;
}




Measured memory_bytes: 256
import bisect,sys
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in sys.stdin:
 x=int(x)
 if x:print(sum(1 for d in p[:bisect.bisect(p,x//2)]if a[x-d]))


Measured memory_bytes: 8448
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int cnt[26], n;
int s[26];
char x, y[100];

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    scanf("%d", &n);
    if(!n)break;
    rep(i, 26)cnt[i] = 0;
    rep(i, 26)s[i] = 0;
    rep(i, n)cin >> y[i];

    for(j = n;j--;){
      x = y[n - j - 1];
      ++cnt[x - 'A'];
      rep(i, 26)s[i] = cnt[i];
      sort(s, s + 26);
      if(s[25] > s[24] + j){
        rep(i, 26)if(cnt[i] == s[25])break;
        printf("%c %d\n", 'A' + i, n - j);
        break;
      }
    }
    if(j == -1)puts("TIE");

  }
  return 0;
}

Measured memory_bytes: 3148
import java.util.Scanner;

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

        for (int i = 0; i < N; i++) {
            H[i] = sc.nextInt();
        }

        int ans = 0;
        int tmp = 10000000;
        for (int i = 0; i < N; i++) {
            int d = Math.abs(A * 1000 - (T * 1000 - H[i] * 6));
            if (d < tmp) {
                tmp = d;
                ans = i + 1;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 24916
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    string s;
    cin >> s;

    if (s.back() == 's') s += "es";
    else s+='s';
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

#define MAX 1000000
int prime[MAX];

int main()
{
    int number, i, j, count;
    for (i = 2; i < MAX; i++) {
        prime[i] = 1;
    }
    for (i = 2; i <= 1000; i++) {
        if (prime[i]) {
            for (j = 2 * i; j < MAX; j += i) {
                prime[j] = 0;
            }
        }
    }
    while (scanf("%d", &number) != EOF) {
        count = 0;
        for (i = 2; i <= number; i++) {
            count += prime[i];
        }
        printf("%d\n", count);
    }
    return 0;
}


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000000000000000
using namespace std;

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

int main() {

	int n, m;
	char c[200][11];
	bool cf[200] = { 0 };

	vector<string> vt;
	cin >> n;

	for (int i = 0; i <n; i++) {
		char a[11];
		cin >> a;
		vt.push_back(a);
	}

	cin >> m;

	for (int i = n; i < m + n; i++) {
		char a[11];
		cin >> a;
		vt.push_back(a);
	}

	int ans = 0;

	for (int i = 0; i < m + n; i++) {
		int sum = 0;
		for (int k = 0; k < m + n; k++) {
			if (vt[i] == vt[k]) {
				if (k < n){
					sum += 1;
				}
				else {
					sum = sum - 1;
				}
			}
		}
		ans = max(ans, sum);
	}

	cout << ans << endl;
	

	return 0;
}




Measured memory_bytes: 384
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

using p = pair<ll, ll>;

int main(void){
	int N; cin >> N;
	vector<int> A(N);
	for (auto& ai : A) cin >> ai;
	vector<vector<p>> dp(N + 1, vector<p>(2, {0, 0}));
	dp[0][0] = dp[0][1] = {1000, 0};
	for (int i = 1; i <= N; ++i){
		// dp[i][0]
		ll money = dp[i - 1][1].second * A[i - 1] + dp[i - 1][1].first;
		if (money > dp[i - 1][0].first)
			dp[i][0] = {money, 0};
		else dp[i][0] = dp[i - 1][0];
		// dp[i][1]
		ll st = dp[i - 1][0].first / A[i - 1] + dp[i - 1][0].second;
		if (st > dp[i - 1][1].second || (st == dp[i - 1][1].second && dp[i - 1][0].first % A[i - 1] > dp[i - 1][1].first))
			dp[i][1] = {dp[i - 1][0].first % A[i - 1], st};
		else dp[i][1] = dp[i - 1][1];
	}
	cout << dp[N][0].first << endl;
	return 0;
}

Measured memory_bytes: 3592
//0052
#include<cstdio>
#include<climits>
using namespace std;

int main(void)
{
	int n;
	int canDiv5;
	int i, j;

	const int a[] = {5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
		48828125, 244140625, 1220703125, INT_MAX, /*6103515625, 30517578125*/};

	while(scanf("%d", &n), n)
	{
		canDiv5 = 0;

		for(i = 5; i <= n; i+=5)
		{
			for(j = sizeof(a)/sizeof(a[0])-1; j>=0; j--)
			{
				if(i >= j && i%a[j] == 0)
				{
					canDiv5 += j+1;
					break;
				}
			}
		}

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

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

int main() {
  int X;
  cin >> X;

  
 int y=0;
 for(int i = 0; i <= 10*10*10*10*10; i++) {
      
          for(int j = -(10*10); j <= (10*10*10*10*10); j++) {
              if((i*i*i*i*i)-(j*j*j*j*j) == X){
                  cout << i << " " << j << endl;
                  y =1;
                  break;
              }
          }
    if(y == 1){
      break;
    
    }
 }


 }



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

int combination(int n){
  int temp = 0;
  for(int i = 0;i < 10;i++)
    for(int j = 0;j < 10;j++)
      for(int k = 0;k < 10;k++)
	if((n - i - j - k) >= 0 && (n -i -j -k) <10)
	  temp++;
  return temp;
}


int main(){
  int n;
  while(cin >> n){
    cout << combination(n) << endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        if(x>=k)
        {
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> a = new ArrayList<>();
    while (sc.hasNext()){
      a.add(sc.nextInt());
    }
    
    boolean ans = (a.size() == new HashSet<>(a).size());
    
    if(ans){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }

    
    
  }
}

Measured memory_bytes: 68892
#include <stdio.h>

int main(){
  int i,n,k,x,y;
  int total = 0;
  
  scanf("%d",&n);
  scanf("%d",&k);
  scanf("%d",&x);
  scanf("%d",&y);
  
  for( i = 1; i <= n; i++ ){
    if( i < ( k + 1 ) ){
      total += x;
    } else {
      total += y;
    }    
  }
  
  printf( "%d\n", total );
  
  return 0;
}

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

int main() {
  int D;
  cin >> D;
  if (D == 25)
    cout << "Christmas" << endl;
  else if (D == 24)
    cout << "Christmas Eve" << endl;
  else if (D == 23)
    cout << "Christmas Eve Eve" << endl;
  else if (D == 22)
    cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#define ll long long
 
using namespace std;
 
bool check (int a,int b, int c)
{
	if (a+b>c) {
	return true;
	}
	else {
	return false;
	}	
}
int main()
{
	int n;
	cin >> n;
	int a[n];
	for (int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	int otpt = 0;
	for (int i=0;i<n;i++)
	{
		for (int j=i+1;j<n;j++)
		{
			for (int k=j+1;k<n;k++)
			{
				if (check(a[i],a[j],a[k])) {
				otpt++;}
			}
		}
	}
	cout << otpt;
}

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

#define ll long long

int main () {
  ll n;
  cin >> n;
  ll a[n + 1], sum[n + 1];
  a[0] = 0;
  sum[0] = 0;
  for (ll i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];  
  }  
  ll min = -1;
  for (ll i = 2; i <= n - 2; i++) {
    // 1 ~ i番目と (i + 1)番目 ~ n番目
    // で2つの部分にとりあえず区切る
    
    // [1] 1 ~ i番目で
    ll center = sum[i] / 2;
    // centerを超えるときのiを求める
    ll left = 0;
    ll right = i + 1;
    while (left < right - 1) {
      ll mid = (left + right) / 2;
      if (sum[mid] > center) {
        right = mid;  
      }  
      else {
        left = mid;  
      }
    }  
    // rightの値の時に初めて越すのである。
    ll a[4] = {
      sum[right], sum[i] - sum[right],
      sum[right - 1], sum[i] - sum[right - 1]  
    };

    center = (sum[n] - sum[i]) / 2;
    left = i;
    right = n + 1;
    while (left < right - 1) {
      ll mid = (right + left) / 2;
      if ((sum[mid] - sum[i]) > center) {
        right = mid;  
      }  
      else {
        left = mid;  
      }
    }
    
    ll b[4] = {
      sum[right] - sum[i], sum[n] - sum[right],
      sum[right - 1] - sum[i], sum[n] - sum[right - 1]
    };
    ll ans[4];
    for (ll i = 0; i < 4; i++) {
      if (i % 2 == 0) {
        ans[0] = a[0];
        ans[1] = a[1];  
      }  
      else {
        ans[0] = a[2];
        ans[1] = a[3];  
      }
      if (i <= 1) {
        ans[2] = b[0];
        ans[3] = b[1];  
      }
      else {
        ans[2] = b[2];
        ans[3] = b[3];  
      }
      sort(ans, ans + 4);
      if (ans[0] != 0) {
        ll now = ans[3] - ans[0];
        if (min == -1 || min > now) {
          min = now;  
        }  
      }
    }
  }
  cout << min << endl;
}

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

int main(){
	int n;
  	string s;
  	cin >> n >> s;
  	
  	int a = 0, b = 0;
  	rep(i, n) if(s[i] == 'R') a++;
  	
  	int ans = max(a, b);
  
  	rep(i, n){
    	if(s[i] == 'R') a--;
      	else b++;
      	int now = max(a, b);
      	ans = min(ans, now);
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
template <long long mod>
class Combination
{
    std::vector<long long> fact, finv, inv;
public:
    Combination(int sz)
    {
        fact.resize(sz);
        finv.resize(sz);
        inv.resize(sz);
        fact[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            fact[i] = fact[i - 1] * i % mod;
        }
        inv[0] = 0;
        inv[1] = 1;
        for (int i = 2; i < sz; ++i)
        {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
        finv[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    long long C(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return (fact[n] * finv[k] % mod) * finv[n - k] % mod;
    }
    long long P(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fact[n] * finv[n - k] % mod;
    }
    long long H(long long n, long long k)
    {
        return this->C(n + k - 1, k);
    }
    long long getfact(int i)
    {
        return fact[i];
    }
    long long getinv(int i)
    {
        return inv[i];
    }
    long long getfinv(int i)
    {
        return finv[i];
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  Combination<MOD> comb(100000);
  string s; cin >> s;
  int k; cin >> k;
  int dig = (int)(s.size());
  vector<int> a(dig);
  for(int i=0;i<dig;++i) {
    a[i] = s[i] - '0';
  }
  ll ans = 0;
  ll mul = 1;
  for(int i=0;i<k;++i) {
    mul *= 9;
  }
  for(int i=k;i<dig;++i) {
    ans += mul * comb.C(i-1, k-1);
  }
  vector<vector<vector<ll>>> dp(dig, vector<vector<ll>>(k+1, vector<ll>(2, 0)));
  if(a[0] > 0) {
    dp[0][1][1] = 1;
    dp[0][1][0] = a[0] - 1;
  }
  for(int i=0;i<dig-1;++i) {
    for(int j=0;j<k+1;++j) {
      dp[i+1][j][0] += dp[i][j][0];
      if(j > 0) dp[i+1][j][0] += 9 * dp[i][j-1][0];
      if(a[i+1] > 0) {
        dp[i+1][j][0] += dp[i][j][1];
        if(j > 0) dp[i+1][j][0] += (a[i+1]-1) * dp[i][j-1][1];
      }
      if(a[i+1] == 0) dp[i+1][j][1] += dp[i][j][1];
      else if(j > 0) dp[i+1][j][1] += dp[i][j-1][1];
    }
  }
  ans += dp[dig-1][k][1] + dp[dig-1][k][0];
  cout << ans << endl;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n;

  vector<string> vs(n);
  for (int i = 0; i < n; ++i) {
    cin >> vs[i];
  }

  cin >> m;
  vector<string> vt(m);
  for (int i = 0; i < m; ++i) {
    cin >> vt[i];
  }

  auto pt = [&](string &s) {
    int ans = 0;
    ans += count(vs.begin(), vs.end(), s);
    ans -= count(vt.begin(), vt.end(), s);
    return ans;
  };

  int ans = 0;
  for (int i = 0; i < vs.size(); ++i) {
    ans = max(ans, pt(vs[i]));
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>

using namespace std;

const int Max = 1e5;

int main(){
	int n, m, i, j;
	int ans;
	while(~scanf("%d", &n)){
		ans = n * 800;
		m = n / 15;
		ans -= m * 200;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    string s;cin >> s;
    string t = s;
    ll k;cin >> k;
    ll ans = 0;
    int size = s.size();
    if(size == count(ALL(s),s[0])){
        cout << (size*k)/2 << endl;
    }else{
        for(int i=0;i<size;i++){
            if(i+1<size && s[i]==s[i+1]){
                s[i+1] = '0';
                i++;
                ans++;
            }
        }
            if(s[0] != s[size-1]){
                cout << ans*k << endl;
            }else{
                int a = 0;
                rep(i,size)if(t[0] == t[i])a++;else break;
                int b = 0;
                repr(i,size-1)if(t[size-1] == t[i])b++;else break;
                cout << ans*k - (a/2 + b/2)*(k-1) + (a+b)/2*(k-1) << endl;
            }
    }
    return 0;
}


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

using namespace std;
typedef long long LL;

int count_permutation(vector<int> input) {
  vector<int> start = input;
  sort(start.begin(), start.end());
  int cnt = 0;
  do {
    if (start == input) return cnt;
    cnt++;
  } while (next_permutation(start.begin(), start.end()));
}

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];

  int a = count_permutation(p);
  int b = count_permutation(q);
  cout << abs(a - b) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
typedef pair<int,int> iP;
int power(int x,int y){
    int res=1;
    x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        x=(x*x)%mod;
        y/=2;
    }
    return res;
}
int mulmod(int a,int b){ 
    int res=0;
    a=a%mod; 
    while(b>0){
        if(b%2==1) 
        res=(res+a)%mod; 
        a=(a*2)%mod; 
        b/=2;
    } 
    return res%mod; 
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;
    int n,m,k;
    cin>>n>>m>>k;
    if(k<=n){
        cout<<n-k<<" "<<m;
    }
    else if(k>=n&&k<=m+n){
        cout<<0<<" "<<m+n-k;
    }
    else
    cout<<"0 0";
}

Measured memory_bytes: 256
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define endl "\n"
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
         ll n;
         cin>>n;
         ll f=0;
         while(n)
         {
            ll p1 = n%10;
            if(p1==7)
            {
                f=1;
                break;
            }
            n=n/10;
         }
         if(f) cout<<"Yes\n";
         else cout<<"No\n";
         

      }
      






}



























Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ll n,i,c=0,ans=0;
	cin>>n;
	unordered_map<ll , ll>mp;
	while(n%2==0){
		mp[2]++;
		n/=2;
	}
	for(i=3;i<=sqrt(n);i+=2){
		while(n%i==0){
			mp[i]++;
			n/=i;
		}
	}
	if(n>2)mp[i]++;
	vector<ll>dp(1e6,0);
	dp[0]=0;
	dp[1]=1;
	for(i=2;i<=1e6;i++){
		dp[i]=dp[i-1]+i;
	}
	ll c1,c2;
	for(auto it=mp.begin();it!=mp.end();it++){
		c1=(lower_bound(dp.begin(),dp.end(),it->second)-dp.begin());
		if(dp[c1]!=it->second)c1--;
		ans+=c1;
		//cout<<it->first<<" "<<it->second<<" "<<ans<<"\n";
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 11244
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	string str;
	cin >> str;

	int maxLen = 0;
	int a = 2000000;
	int b = 0;
	for(int i=0 ; i<str.size() ; i++)
	{
		if(str[i] == 'A' && a == 2000000)
		    a = i;       
		   
		if(str[i] == 'Z')
		    b = i;
	}
	cout << b-a+1;
	return 0;
}

Measured memory_bytes: 720
#include<iostream>
int a, b, c, d;
int main(){
	std::cin>>a>>b>>c>>d;
	int sed = a + b + c + d;
	int mi = 0;
	if(sed >= 60){
		mi = sed / 60;
		sed = sed % 60;
	}
	std::cout<< mi << std::endl;
	std::cout<< sed <<std::endl;
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <numeric>
#include <queue>
#include <string>

/* INSERT HERE  - ALWAYS - include the 'always include' toolset*/
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using ll = long long;

template <typename T>
std::ostream &operator<<(std::ostream &os, std::vector<T> vec) {
  if (!vec.empty()) {
    std::copy(vec.begin(), vec.end() - 1, std::ostream_iterator<T>(os, " "));
    os << vec.back();
  }
  return os;
}

/**/


using namespace std;
using st = std::size_t;
using bo = uint8_t;
typedef std::numeric_limits<double> dbllims;

auto solve_wrapper() -> void {
  int n;
  cin >> n;
  string s = "ACL";
  for (int i{0}; i < n - 1; ++i) {
    s += "ACL";
  }
  std::cout << s << "\n";
}

auto main() -> int {
  ll t = 1;
  while (t-- > 0) {
    solve_wrapper();
  }
  return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const int INF = 1e9;

int n;

int main() {
   cin >> n;
   vec<int> a(n);
   rep (i, n) { cin >> a[i]; }
   vec<int> dp(n+1);
   dp[0] = -1;
   repp (i, 1, n+1) {
      dp[i] = INF;
   }
   repp (i, 1, n+1) {
      vec<int>::iterator ite = lower_bound(all(dp), a[i-1]);
      if (ite != a.end()) *ite = a[i-1];
   }
   int res = 0;
   rep (i, n+1) {
      if (dp[i] != INF) res = i;
   }
   cout << res << endl;

   return 0;
}


Measured memory_bytes: 3600
import sys
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines

# 0-indexed
class UnionFind:
  N=0
  parent=None
  size=None
  def __init__(self,N):
    self.N=N
    self.parent=[i for i in range(self.N)]
    self.size=[1]*self.N
    
  def root(self,x):
    while x!=self.parent[x]:
      self.parent[x]=self.parent[self.parent[x]]
      x=self.parent[x]
    return x
  
  def same(self,x,y):
    return self.root(x)==self.root(y)
  
  def unite(self,x,y):
    x=self.root(x)
    y=self.root(y)
    if x==y:
      return
    if self.size[x]>self.size[y]:
      # 大きい方にくっつける
      self.parent[y]=x
      self.size[x]+=self.size[y]
    else:
      self.parent[x]=y
      self.size[y]+=self.size[x]
      
  def get_group_size(self,x):
    return self.size[self.root(x)]
  
  def get_roots(self):
    r=set()
    for i in range(self.N):
      r.add(root(i))
    return r
  
  def show_parent(self):
    print(self.parent)
    
  def show_size(self):
    print(self.size)
    
N,M=map(int,readline().split())
edges=[None]*M
for i in range(M):
  a,b=map(int,readline().split())
  edges[i]=[a-1,b-1]

ans=0
# どの辺を使用しないかのループ
for i in range(M):
  # 辺iを使用しない場合
  UF=UnionFind(N)
  for m in range(M):
    if m==i:
      continue
    UF.unite(edges[m][0],edges[m][1])
  # 連結であれば0が属するグラフのサイズはNである
  if UF.get_group_size(0)!=N:
    ans+=1
    
print(ans)  


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            Console.WriteLine(Math.Abs(A.Max() - A.Min()));
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 28220