akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)


typedef map<string, int> map_type;
typedef pair<string, int> value_type;

struct second_order {
  bool operator()(const value_type& x, const value_type& y) const {
    if( x.second != y.second) return x.second < y.second;
    return x.first > y.first;
  }
};

typedef priority_queue<value_type, vector<value_type>, second_order> pqueue_type;


pqueue_type map_to_pqueue(map_type m) {
    pqueue_type que;
    for(auto it=m.begin(); it!=m.end(); ++it) {
        que.push(*it);
    }
    return que;
}


int main(void){
    int n, x;
    cin >> n >> x;
    vector<int> a(x);
    REP(i,x) cin >> a[i];
    int sum = n-accumulate(ALL(a),0);
    if(sum<0) cout << -1 <<endl;
    else cout << sum << endl;
    return 0;
}


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

int main() {


  int n;
  cin >> n;
  int a[100] = {};
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  reverse(&a[0],&a[n]);
  for(int i = 0; i < n; i++){
    if(i==n-1){
      cout << a[i];
      continue;
    }
    cout << a[i] << " ";
  }
  cout << endl;

}



Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
   int N;
   cin >> N;
   vector<int> a(N);
   for(int i = 0; i < N; i++) cin >> a[i];
   sort(a.begin(),a.end());
   int ans = 0;
   int x = a[0];
   int count = 0;
    for(int i = 0; i < N; i++)
    {
        if(x == a[i]) count++;
        else
        {
            if(count != x || count > x)
            {
                if(count > x) ans += count - x;
                else ans += count;
            }
            x = a[i];
            count = 1;
        }
    }
    if(count > x) ans += count - x;
    if(count < x) ans += count;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}
/*
 Atcoder 100~200点代
 アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
void abc042_a(){ ll A,B,C; cin >> A >> B >> C; if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;} if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;} if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;} cout << "NO" << endl; return ; }
// https://abc043.contest.atcoder.jp/tasks/abc043_a
void abc043_a(){ ll N; cin >> N; cout << N*(N+1)/2 << endl; }
// https://abc044.contest.atcoder.jp/tasks/abc044_a
void abc044_a(){ll N,K,X,Y;cin>>N>>K>>X>>Y; cout<<X*min(N,K)+Y*max(0LL,N-K)<<endl;}
// https://abc045.contest.atcoder.jp/tasks/abc045_a
void abc045_a(){}
// https://abc046.contest.atcoder.jp/tasks/abc046_a
void abc046_a(){ ll a,b,c; cin >> a >> b >> c; set<ll> s; s.insert(a); s.insert(b); s.insert(c); cout << s.size() << endl; }
// https://abc047.contest.atcoder.jp/tasks/abc047_a
void abc047_a(){}
// https://abc048.contest.atcoder.jp/tasks/abc048_a
void abc048_a(){string s1,s2,s3;cin>>s1>>s2>>s3;cout<<"A"<<s2[0]<<"C"<<endl;}
// https://abc049.contest.atcoder.jp/tasks/abc049_a
void abc049_a(){}
// https://abc050.contest.atcoder.jp/tasks/abc050_a
void abc050_a(){}
// https://abc051.contest.atcoder.jp/tasks/abc051_a
void abc051_a(){}
// https://abc052.contest.atcoder.jp/tasks/abc052_a
void abc052_a(){}
// https://abc053.contest.atcoder.jp/tasks/abc053_a
void abc053_a(){}
// https://abc054.contest.atcoder.jp/tasks/abc054_a
void abc054_a(){}

// Main function
int main(void) {cin.tie(0); ios::sync_with_stdio(false); abc044_a(); return 0; }


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int N[21];

int solve(int i,int m){
    if(m==0){
        return true;
    }
    if(i>=n){
        return false;
    }
    int res = solve(i + 1, m) || solve(i + 1, m - N[i]);
    return res;
}

int main(){
    int q;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>N[i];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        int m;
        cin>>m;
        if(solve(0,m)){
            cout<<"yes"<<endl;
        }
        else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
N=int(input())
l=[int(x) for x in input().rstrip().split() if int(x)%2==0]
flag=1
for i in l:
  if i%3==0 or i%5==0:
    continue
  else:
    flag=0
    break
if flag==1:
  print("APPROVED")
else:
  print("DENIED")
    

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int x, y;
	cin >>x >>y;
	rep(i, 101) rep(j, 101){
		if(i+j==x && 2*i+4*j==y){
			puts("Yes"); return 0;
		}
	}
	puts("No");;
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
using ll = long long;
using ld = long double;
const ll inf = 1000000000000000008;
ll N, A, B, C, D;
vector<ll> mul = {2, 3, 5};

unordered_map<ll, ll> Map;

ll calc(ll n) {
	if(n==0ll) return 0ll;
	if(n==1ll) return D;
	if(Map.count(n)) return Map[n];
    
	ll ret = inf;
	if(n<ret/D) ret = n*D;
	for(auto x:mul) {
		ll ex;
		if(x==2) ex = A;
		else if(x==3) ex =B;
		else ex = C;
		if(n%x==0) ret = min(ret, calc(n/x)+ex);
		else {
			ll up = (n/x+1)*x;
			ll down = (n/x)*x;
			ret = min(ret, calc(down/x)+D*(n-down)+ex);
			ret = min(ret, calc(up/x)+D*(up-n)+ex);
		}
	}
	return Map[n] = ret;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll tc; cin>>tc;
	while(tc--) {
		cin>>N>>A>>B>>C>>D;
		cout << calc(N) << '\n';
		Map.clear();
	}
	return 0;
}

Measured memory_bytes: 3892
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(n-2):
    if (p[i]<p[i+1] and p[i+1]<p[i+2]) or (p[i+1]<p[i] and p[i+1]>p[i+2]):
        count+=1
print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(char x,char y)
{
	return x>y;
}
int main()
{
	string a,b;
	cin>>a>>b;
	int a1,b1;
	a1=a.size();
	b1=b.size();
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(),cmp);
	if(a<b)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;


int main()
{ 
	int n;
	cin>>n;
	int arr [200000];
	for(int i=0;i<n;i++)cin>>arr[i];
	int cnt=0;
	int num=n+1;
	for(int i=1;i<=n,cnt<n;i++){
		for(int j=cnt;j<n;j++){
			if(arr[j]==i){
				cnt=j+1;
				num=i;
				break;
			}
		}
		if(num!=i)break;
	}
	cout<<n-num<<endl;		
	return 0;
}


	


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CStreamline solver = new CStreamline();
        solver.solve(1, in, out);
        out.close();
    }

    static class CStreamline {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // サボれる区間はn-1個

            int n = in.nextInt();
            int m = in.nextInt();
            int[] x = new int[m];
            int[] dif = new int[m - 1];

            for (int i = 0; i < m; i++) {
                x[i] = in.nextInt();
            }
            Arrays.sort(x);
            for (int i = 0; i < m - 1; i++) {
                dif[i] = x[i + 1] - x[i];
            }
            Arrays.sort(dif);

            int think = Math.max(0, m - n);
            long sum = 0;
            for (int i = 0; i < think; i++) {
                sum += dif[i];
            }
            out.println(sum);

        }

    }
}



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

using namespace std;

int co[100][100];
int main()  {
    int n;
    char str[100];
    scanf("%d",&n);
    for ( int c=1 ; c<=n ; c++ )
    {
        scanf("%s",str);
        int l = strlen(str);
        for ( int d=0 ; d<l ; d++ )
        {
            co[c][str[d]-'a']++;
        }
    }
    for ( int c=0 ; c<26 ; c++ )
    {
        int mn = 100;
        for ( int d=1 ; d<=n ; d++ )
        {
            mn = min ( mn , co[d][c] );
        }
        for ( int d=1 ; d<=mn ; d++ )   printf("%c",'a'+c);
    }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

flag = True
count = 0

while flag:
    flag = False
    for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            count += 1
            flag = True

print(*A)
print(count)



Measured memory_bytes: 5608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  ll x, y; cin >> x >> y;

  if (x % y == 0) outl(-1);
  else outl(x);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var raw = ReadLine().Split().Select(int.Parse).ToArray();
            var K = raw[0];
            var N = raw[1];

            var A = ReadLine().Split().Select(int.Parse).ToArray();
            var max = 0;
            for (int i = 0; i < A.Length - 1; i++)
            {
                max = Math.Max(max, A[i + 1] - A[i]);
            }
            max = Math.Max(max, A[0] + K - A[N - 1]);
            WriteLine(K - max);
        }
    }
}

Measured memory_bytes: 34780
a=input()
b=input()
c=input()
turn="a"
while True:
  if turn=="a":
    if len(a)==0:
      print("A")
      break
    else:
      turn,a=a[0], a[1:]
  if turn=="b":
    if len(b)==0:
      print("B")
      break
    else:
      turn,b=b[0], b[1:]
  if turn=="c":
    if len(c)==0:
      print("C")
      break
    else:
      turn,c=c[0], c[1:]


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, Q;
	cin >> N >> M >> Q;
	vvi VL(N);
	vvi VR(N);
	REP(i, M) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		VL[l].push_back(i);
		VR[r].push_back(i);
	}
	vvi VV(N, vi(N, -1));
	REP(i, N) {
		vector<bool> VB(M);
		int cnt = 0;
		FOR(j,i, N) {
			REP(k, SZ(VL[j])) {
				VB[VL[j][k]] = true;
			}
			REP(k, SZ(VR[j])) {
				if (VB[VR[j][k]])cnt++;
			}
			VV[i][j] = cnt;
		}
	}

	REP(i, Q) {
		int p, q;
		cin >> p >> q;
		p--; q--;
		cout << VV[p][q] << endl;
	}
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}


const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    string s;
    cin >> s;

    bool flag;
    if (s[0] == 'W') flag = false;
    else flag = true;
    int ans = 0;
    rep(i,s.size()) {
        if (flag == false && s[i] == 'W') {
            ++ans;
            flag = true;
        }
        else if (flag == true && s[i] == 'B') {
            ++ans;
            flag = false;
        }
    }
    --ans;
    
    cout << ans << endl;
    
}





//              g++ -std=c++1z


Measured memory_bytes: 1144
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dbg
#define dprintf      printf
#define dout(x)      printf(#x" = %d\n",(x))
#define dary(x,n)    {int i;for(i=0;i<(n);i++)printf(#x"[%d] = %d\n",i,*((x)+i));}
#define dloop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for((i)=0;(i)<(n);(i)++)
#else
#define dbg          (1)?0:
#define dprintf      (1)?0:printf
#define dout(x)
#define dary(x,n)
#define dloop(i,s,g) if(0)
#define drep(i,n)    if(0)
#define dary(x,n)
#endif

#define INF  (0x7fffffff)
#define LINF (0x7fffffffffffffff)

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())

//#define int long long;
typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

signed main(void)
{
  char a[BUFSIZ]={};
  char b[BUFSIZ]={};
  char c[BUFSIZ]={};

  scanf("%s %s %s",a,b,c);
  printf("%c%c%c\n",a[0]+'A'-'a',b[0]+'A'-'a',c[0]+'A'-'a');
  return 0;
}



Measured memory_bytes: 256
n = int(input())

def dfs(a):
    if int(a) > n:
        return 0
    ret = 1 if all(a.count(c) > 0 for c in '753') else 0
    for v in '753':
        a += v
        ret += dfs(a)  # この3行を ret += dfs(a+v) とも書ける
        a = a[:-1]  # numはそのまま繰り返される
    return ret


print(dfs('0'))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long N, vector<long long> A) {
    vector<ll> rev(N);
    for (int i = 0; i < N; i++) {
        rev[A[i]-1] = i+1;
    }
    for (int i = 0; i < N - 1; i++) {
        cout << rev[i] << " ";
    }
    cout << rev[N-1] << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  solve(N, move(A));
  return 0;
}


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

using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll LNF = __LONG_LONG_MAX__;

int main(){
    string S; cin >> S;
    if(S[S.size()-1]!='s') S += 's';
    else S += "es";
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 3596
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7


def dfs(u):
    if memo[u] == -2:
        print(-1)
        exit()
    if memo[u] != -1:
        return memo[u]
    memo[u] = -2
    res = 0
    for v in nodes[u]:
        res = max(res, dfs(v))
    memo[u] = res + 1
    return res + 1

N = INT()
NN = N * N
nodes = [set() for i in range(NN+1)]
for a in range(N):
    B = [b-1 for b in LIST()]
    for j in range(N-2):
        a1 = a2 = a
        b1 = B[j]
        b2 = B[j+1]
        if a1 > b1:
            a1, b1 = b1, a1
        if a2 > b2:
            a2, b2 = b2, a2
        nodes[a1*N+b1].add(a2*N+b2)
        if j == 0:
            nodes[NN].add(a1*N+b1)

memo = [-1] * (NN+1)
ans = dfs(NN) - 1
print(ans)


Measured memory_bytes: 232804
import java.util.*;
public class Main {

	class C {
		int deep;
		StringBuilder data;
		public C(int deep, String data) {
			this.deep = deep;
			this.data = new StringBuilder(data);
		}

	}

	private boolean isRange(int ind){
		if(ind < 0 || ind >= 8){
			return false;
		}
		else{
			return true;
		}
	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int [] dir = {-1,1,4,-4};
		LinkedList<C> open = new LinkedList<C>();
		HashMap<String,Integer> close =  new HashMap<String,Integer>();

		open.addFirst(new C(0,"01234567"));
		close.put("01234567", 0);

		while(! open.isEmpty()){
			C pat = open.getFirst();

			open.removeFirst();
			StringBuilder patStr = pat.data;

			int ind = patStr.indexOf("0");
			for(int i=0; i < 4; i++){
				int ind2 = ind + dir[i];

				if((ind == 3 && dir[i] == 1) || (ind == 4 && dir[i] == -1) ){
					continue;
				}

				if(isRange(ind2)){

					String newStr = patStr.toString();
					char temp = newStr.charAt(ind2);
					newStr = newStr.replace('0','*');
					newStr = newStr.replace(newStr.charAt(ind2), '0');
					newStr = newStr.replace('*',temp);
					if(! close.containsKey(newStr)){
						open.addLast(new C(pat.deep+1,newStr));
						close.put(newStr,pat.deep+1 );
					}
				}
			}
		}
		while(sc.hasNext()){
			StringBuilder st = new StringBuilder();
			for(int i=0; i < 8; i++){
				st.append(sc.next());
			}
			String input = st.toString();
			System.out.println(close.get(input));
		}

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}

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

int main() {
  double N, M;
  double sum = 0; //得票数
  double count = 0;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  //cout << "sum" << sum << endl;
  double border = sum / (4 * M);
  //cout << "border" << border << endl;
  for (int i = 0; i < N; i++) {
    if (A[i] >= border) count++;
  }
  
  //cout << "count" << count << endl;
  if (count >= M) {
    cout << "Yes" << endl; 
  } else {
    cout << "No" << endl; 
  }
  
}

Measured memory_bytes: 3708
import java.util.*;
class Main {
public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  
  int N = sc.nextInt();
  int A = sc.nextInt();
  int B = sc.nextInt();
  
  int max,min;
  
  if(A > B) { 
    max = B;
  } else {
    max = A;
  }
  
  if(N < A + B) {
    min = A + B - N;
  } else {
    min = 0;
  }
  
  System.out.println(max + " " + min);
}
}

Measured memory_bytes: 21844
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter, Binary};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn primes(upper_limit: usize) -> Vec<i64> {
    let mut is_prime = vec![true; upper_limit + 1];
    let mut i = 2;
    while i * i <= upper_limit {
        if is_prime[i] {
            let mut j = i * i;
            while j <= upper_limit {
                is_prime[j] = false;
                j += i;
            }
        }
        i += 1;
    }
    let mut result = Vec::new();
    for i in 2 .. is_prime.len() {
        if is_prime[i] {
            result.push(i as i64);
        }
    }
    result
}
fn main() {
    let mut prime = primes(1000000);
    let mut suspects = Vec::with_capacity(1000000);
    for i in 0 .. 1000000 {
        suspects.push((i + 1) as i64);
    }
    for &p in &prime {
        let mut i = p as usize;
        while i <= suspects.len() {
            suspects[i - 1] /= p;
            suspects[i - 1] *= p - 1;
            i += p as usize;
        }
    }
    suspects[0] += 1;
    for i in 1 .. suspects.len() {
        suspects[i] += suspects[i - 1];
    }
    let_all!(r: usize);
    for _ in 0 .. r {
        let_all!(n: usize);
        println!("{}", suspects[n - 1]);
    }
}


Measured memory_bytes: 15160
#include <iostream>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int a[100001];

int main(){
    int n;
    cin>>n;
    int count = 1;
    bool simple_increase, simple_decrease;
    
    int prev_val, curr_val;
    simple_increase = true; simple_decrease = true;

    cin>>prev_val;
    rep(i, n-1) {
        cin>>curr_val;
        if (curr_val>prev_val) simple_decrease = false;
        if (curr_val<prev_val) simple_increase = false;
        if (!simple_increase & !simple_decrease) {
            count++;
            simple_increase = true; simple_decrease = true;
        }
        prev_val = curr_val;
    }

    cout<<count<<endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {

	int n, m;
	cin >> n >> m;
	if ( n < 1 || n > 9 || m < 1 || m > 9 )
		cout << -1 << "\n";
	else
		cout << n * m << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    int res = n;
    for (int i = 0; i <= n; i++) {
        int cc = 0;
        int t = i;
        while(t > 0) cc += t % 6, t /= 6;
        t = n - i;
        while(t > 0) cc += t % 9, t /= 9;
        if (res > cc) res = cc;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e5+5,LG=19,SM=4000+5,inf=1e18+1;
ll mod=924844033;

ll n,m;
ll a[M],b[M];

bool check(ll x)
{
    //ER(x);
    For(i,0,m) b[i]=(a[i]<x);
    //For(i,0,m) cout << b[i] << ' '; ER(".");
    ll ted=0;
    For(i,1,m) ted+=b[i]==b[i-1];
    if (ted==0) return b[0];
    ll lf=-2,lv,rf=-2,rv;
    For(i,0,n)
        if (b[i]==b[i-1])
        {
            lf=i;
            lv=b[i];
        }
    For(i,n,m)
        if (b[i]==b[i-1])
        {
            rf=i-1;
            rv=b[i];
            break;
        }
    //ER(lf);ER(lv);ER(rf);ER(rv);
    if (lf==-2 || lv==rv) return rv;
    if (rf==-2) return lv;
    while (1)
    {
        if (lf==rf) return b[n-1];
        if (lf==n-1) return lv;
        if (rf==n-1) return rv;
        lf++;
        rf--;
    }
}

int main()
{
	ios::sync_with_stdio(0);
    cin >> n;
    m=2*n-1;
    For(i,0,m) cin >> a[i];
    ll lo=1,hi=m;
    while (hi-lo>1)
    {
        //ER(hi); ER(lo);
        ll mid=(hi+lo)>>1;
        if (check(mid)) hi=mid; else lo=mid;
    }
    RET(lo);
}    

Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		char str[] = sc.next().toCharArray();
		char str2[] = (char[])str.clone();
		
		char target;
		char overWrite;
		
		if(str[0] == 'L'){
			target = 'R';
			overWrite = 'L';
		}
		else {
			target = 'L';
			overWrite = 'R';
		}
		
		for(int i = 1; i < n ; i++){
			if(str[i] != target){
				if(k == 0){
					break;
				}
				continue;
			}
			
			if(str[i - 1] != target){
				k--;
			}
			
			str2[i] = overWrite;
		}
		
//		System.out.println(str2);
		
		int result = 0;
		
		for(int i = 0; i < n; i++){
			if(i != 0 && str2[i - 1] == str2[i] && str2[i] == 'L'){
				result++;
			}
			
			else if (i != n - 1 && str2[i + 1] == str2[i] && str2[i] == 'R'){
				result++;
			}
		}
		
		System.out.println(result);
	}

}


Measured memory_bytes: 27732
// clang-format

#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

const long long mod = 998244353;

lli pow(lli p, lli n){
  lli ans = 1;
  rep(i, n)
  {
    ans *= p;
    ans %= mod;
  }
  return ans;
}
void solve(long long n, std::vector<long long> D) {
  if(D[0] != 0) {
    cout << 0 << endl;
    return;
  }
  sort(D.begin(), D.end());
  lli cur = 0;
  lli f = *max_element(D.begin(), D.end());
  vector<lli> a(f+1);
  rep(i, n){
    if(D[i] == cur){
      a[cur]++;
      continue;
    }
    if(D[i] == cur + 1) {
      cur++; 
      a[cur]++;
      continue;
    }
    cout << 0 << endl;
    return;
  }
  if(a[0] != 1) {
    cout << 0 << endl;
    return;
  }
  lli ans = 1;
  for(int i = 1;i<=f;i++){
    ans *= pow(a[i-1],a[i]);
    ans %= mod;
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> D(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &D[i]);
  }
  solve(N, std::move(D));
  return 0;
}


Measured memory_bytes: 1792
import sys

sys.setrecursionlimit(100000)
input=lambda : sys.stdin.readline().rstrip('\n')

n=int(input())
g=[[]for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append((c,b-1))
    g[b-1].append((c,a-1))

def dijkstra(g,st):
    from heapq import heappush, heappop, heapify
    inf=10**18
    dist=[inf for i in range(len(g))]
    visited=[False for i in range(len(g))]
    dist[st]=0
    que=[]
    heappush(que,(0,st))
    while que:
        c,v=heappop(que)
        if visited[v]:
            continue
        visited[v]=True
        for x in g[v]:
            tmp=x[0]+c
            if tmp<dist[x[1]] and not visited[x[1]]:
                dist[x[1]]=tmp
                heappush(que,(tmp,x[1]))
    return dist

q,k=map(int,input().split())
dist=dijkstra(g,k-1)

for i in range(q):
    x,y=map(int,input().split())
    print(dist[x-1]+dist[y-1])


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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto n = load<int>();
    auto mass = loadMany<int>(n);
    auto joint = vector<vector<long long>>(n+1, vector<long long>(n+1, 0ll));
    for (auto l=1; l<=n; ++l)
        for (auto i=0; i+l<=n; ++i)
            joint[i][i+l] = mass[i] + joint[i+1][i+l];
    auto dyn = vector<vector<long long>>(n+1, vector<long long>(n+1, numeric_limits<long long>::max()));
    for (auto i=0; i<=n; ++i)
        dyn[i][i] = 0ll;
    for (auto i=0; i<n; ++i)
        dyn[i][i+1] = 0ll;
    for (auto l=2; l<=n; ++l)
        for (auto i=0; i+l<=n; ++i)
            for (auto m=i+1; m<i+l; ++m)
                dyn[i][i+l] = min(dyn[i][i+l], dyn[i][m] + dyn[m][i+l] + joint[i][m] + joint[m][i+l]);
    cout << dyn[0][n] << '\n';
}


Measured memory_bytes: 2816
#include<algorithm>
#include<cstdio>
#include<cstring>
#define M 202
#define N 101
using namespace std;
int a[N],b[M],c[M],d[N],f[N],g[N],h[N],i,j,l,n,q[N],r,u,v,w;long long e[N],x;
inline long long solve()
{
    for(memset(d+1,0,n<<2),memset(g+1,0,n<<2),h[f[f[q[l=1]=v]=q[2]=w]=v]=h[w]=1,r=v==w?2:3;l<r;g[h[u]]=max(g[h[u]],d[u]))for(i=a[u=q[l++]];i;i=b[i])if(c[i]!=f[u])f[q[r++]=c[i]]=u,d[u]++,h[c[i]]=h[u]+1;
    for(e[i=h[q[n]]]=1;--i;)e[i]=g[i]*e[i+1];
    return e[1]<<1;
}
int main()
{
    for(scanf("%d",&n),i=1;i<n;i++)scanf("%d%d",&u,&v),b[i<<1]=a[u],c[a[u]=i<<1]=v,b[i<<1|1]=a[v],c[a[v]=i<<1|1]=u;
    for(q[l=1]=1,r=2;l<r;)for(i=a[u=q[l++]];i;i=b[i])if(c[i]!=f[u])f[q[r++]=c[i]]=u;
    for(f[q[l=1]=q[n]]=0,r=2;l<r;)for(i=a[u=q[l++]],h[u]=h[f[u]]+1;i;i=b[i])if(c[i]!=f[u])f[q[r++]=c[i]]=u;
    for(i=q[n],printf("%d ",h[q[n]]+1>>1),v=0;i;i=f[i])if(h[i]==h[q[n]]+1>>1||h[i]==h[q[n]]+2>>1)w=v,v=i;
    if(w)x=solve();
    else for(j=a[w=v],x=solve()>>1;j;j=b[j])w=c[j],x=min(x,solve());
    return 0&printf("%lld\n",x);
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

class Prime {
public:
    Prime(ll n) {
        mPrimeTbl.clear();
        vector<bool> u(n, false);
        for (ll i = 2; i <= n; ++i) {
            if (u[i])
                continue;
            mPrimeTbl.push_back(i);
            for (ll p = i; p <= n; p += i)
                u[p] = true;
        }
    }

    ~Prime() {}

    ll num() {
        return static_cast<ll>(mPrimeTbl.size());
    }

    ll get(ll index) {
        return mPrimeTbl[index];
    }

private:
    vector<ll> mPrimeTbl;
};

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

    Prime prime(1005);

    vector<ll> v(prime.num(), 1);
    REP(i, N) {
        ll n = i + 1;
        REP(j, prime.num()) {
            while (n % prime.get(j) == 0) {
                n /= prime.get(j);
                v[j]++;
            }
        }
    }

    ll ans = 1;
    REP(i, v.size()) {
        ans = (ans * v[i]) % MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

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

    bool alreadyExist[1000000];
    fill(alreadyExist, alreadyExist + 1000000, false);

    int before;
    int res = 1;
    int now = s;
    while (1) {
        if (alreadyExist[now - 1]) {
            cout << res << endl;
            return 0;
        }

        alreadyExist[now - 1] = true;
        before = now;
        if (before % 2 == 0) now = before / 2;
        else now = before * 3 + 1;
        ++res;
    }
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

ll func(){
  rep(i,0,s.sz)dp[i][0] = 0;
  rep(i,0,t.sz)dp[0][i] = 0;
  rep(i,0,s.sz){
    rep(j,0,t.sz){
      if(s[i] == t[j]){
        dp[i+1][j+1] = dp[i][j] + 1;
      }else{
        dp[i+1][j+1] = max(dp[i+1][j] , dp[i][j+1]);
      }
    }
  }
  return dp[s.sz][t.sz];
}

int main(){
  cin >> n;
  rep(i,0,n){
    cin >> s >> t;
    print(func());
  }
  return 0;
}


Measured memory_bytes: 11056
#include <iostream>
using namespace std;
const int SIZE=500000;

int A[SIZE+1];
int H;//heapsize

void maxheap(int v)
{
	int l=v*2,r=v*2+1,lar;
	int sto;
	
	if(l<=H&&A[l]>A[v])lar=l;
	else lar=v;
	if(r<=H&&A[r]>A[lar])lar=r;
	
	if(lar!=v)
	{
		sto=A[v];
		A[v]=A[lar];
		A[lar]=sto;
		maxheap(lar);
	}
	return;
}

void buildmaxh()
{
	for(int i=H/2;i>=1;i--)maxheap(i);
	return;
}

int main() {
	cin>>H;
	for(int i=1;i<=H;i++)cin>>A[i];
	buildmaxh();
	for(int i=1;i<=H;i++)cout<<" "<<A[i];
	cout<<endl;
	return 0;
}

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

int main() {
  vector<vector<int>> v(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> v.at(i).at(j);
    }
  }

  vector<int> x(3);
  vector<int> y(3);

  x.at(0) = 0;
  for (int i = 0; i < 3; i++) {
    y.at(i) = v.at(0).at(i) - x.at(0);
  }
  for (int i = 0; i < 3; i++) {
    x.at(i) = v.at(i).at(0) - y.at(0);
  }

  bool enabling = true;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (v.at(i).at(j) != (x.at(i) + y.at(j))) {
        enabling = false;
      }
    }
  }

  cout << (enabling ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
acum=[1]
for i in range(2,n+1):
  tmp=acum[-1]+pow(i,mod-2,mod)
  tmp%=mod
  acum.append(tmp)
ans=0
for i in range(n-1):
  ans+=(arr[i+1]-arr[i])*acum[i]
  ans%=mod
for i in range(1,n):
  ans*=i
  ans%=mod
print(ans)

Measured memory_bytes: 14224
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

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

  int a,b;
  cin>>a>>b;
  if(a!=b){
    if(a<b) swap(a,b);
    for(int i=0;i<a;i++){
      cout<<b;
    }
    cout<<endl;
  }else{
    for(int i=0;i<a;i++){
      cout<<b;
    }
    cout<<endl;
  }

  return 0;
}




Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		int[] a = {-1,-1,-1,-1,-1,-1};
		int dis;
		boolean is = true;
		Scanner sc = new Scanner(System.in);
		while(a[0] < 0 || a[1] < 0 || a[2] < 0 || a[3] < 0 || a[4] < 0 || a[5] < 0|| a[0] > 123 || a[1] > 123 || a[2] > 123 || a[3] > 123 || a[4] > 123|| a[5] > 123|| a[0] > a[1] || a[1] > a[2] || a[2] > a[3] || a[3] > a[4]){
			for(int i = 0; i < 6; i++){
				a[i] = sc.nextInt();
			}
		}
		for(int i = 0; i < 4; i++){
			for(int j = i + 1; j < 5; j++){
				dis = a[j] - a[i];
				if(dis > a[5]){
					System.out.println(":(");
						i = 4;
						j = 6;
						is = false;
				}
			}
		}
			if(is){
				System.out.println("Yay!");
			}
	}
}

Measured memory_bytes: 22612
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

# sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, C, D):
    while True:
        C -= B
        if C <= 0:
            return 'Yes'
        A -= D
        if A <= 0:
            return 'No'


def main():
    A, B, C, D = read_int_n()
    print(slv(A, B, C, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 76904
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll a, b;
	string op;

	cin >> a >> op >> b;

	if (op == "+") {
		cout << a + b << endl;
	}
	else if (op == "-") {
		cout << a - b << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int num, c1, c2;
  int score1[1000], score2[1000];
  int i;
  int count;

  count = 0;
  for(i = 0; i < 1000; i++){
    score1[i] = 0;
    score2[i] = 0;
  }

  while(scanf("%d", &num) != 0){
    if(num == 0) break;
    for(i = 0; i < num; i++){
      scanf("%d %d", &c1, &c2);
      if(c1 > c2){
	score1[count] += c1 + c2;
      }else if(c2 > c1){
	score2[count] += c1 + c2;
      }else{
	score1[count] += c1;
	score2[count] += c2;
      }
    }
    count ++;
  }

  for(i = 0; i < count; i++){
    printf("%d %d\n", score1[i], score2[i]);
  }

  return 0;
}

Measured memory_bytes: 0
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <queue>
#include <stack>
#define lson rt<<1
#define rson rt<<1|1
using namespace std;
typedef long long ll;
typedef pair<int, int>  P;
typedef pair<int, P>  PP;
const int maxn=2e5+10;
char ans[10];
int n;
void dfs(int loc,int top)
{
    if(loc==n)
    {
        printf("%s\n",ans);
//        cout<<ans<<endl;
        return;
    }
    for(int i=0;i<=top;i++)
    {
        ans[loc]='a'+i;
        dfs(loc+1, max(top,i+1));
    }
}
int main()
{
    scanf("%d",&n);
//    cin>>n;
    dfs(0, 0);
}



Measured memory_bytes: 1536
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <math.h>
#include <iomanip>
#define int unsigned long long
#define ll long long
//#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	//int x;

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	int a, b;
	//int m;
	//int k;
	//string s;
	//string t;
	//int m1, m2;
	//int a, b, c, k;

	//int box[1000000000000000000];
	int box;

	//long double aaa;

	//int k, d;
	int all = 1;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	//int b = 0;

	//int box[10000] = { 0 };

	bool flag = true;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	cin >> n;
	//cin >> a >> b;

	for (int i = 0; i < n; i++)
	{
		cin >> box;
		if (box == 0)
		{
			all = 0;
			flag = false;
			break;
		}
		all *= box;
	}

	//all = a * b;

	//n = t.length();

	//cout << b << "\n";
	/*for (int i = 0; i < n; i++)
	{
		if (t[i] == '?')
		{
			t[i] = 'D';
		}
	}*/

	/*if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}*/
	if (all == 0 && flag == true)
	{
		cout << "-1\n";
	}
	else if (all > 1000000000000000000)//1000000000000000000
	{
		cout << "-1\n";
	}
	else
	{
		cout << all << "\n";
	}

	//cout << fixed << setprecision(111) << all;
}


Measured memory_bytes: 3636
import heapq
N = int(input())
P = list(int(x) for x in input().split())
list = P.copy()
heapq.heapify(list)
count = 0

for i in range(N):
    if P[i] != heapq.heappop(list):
        count += 1

    if count == 3:
        break

if count == 3:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s,t;
   cin >> s >> t;
   cout << t << s << '\n';
   return 0;
} 

Measured memory_bytes: 256
import math
a,b,x = map(int, input().split())
if x <= a*a*b/2:
    print((180/math.pi)*math.atan(a*b*b/(2*x)))
else:
    r = a*a*b-x
    print((180/math.pi)*math.atan(2*r/(a**3)))

Measured memory_bytes: 38384