akhauriyash/Code-Regression huggingface dataset:
a,b,c = [list(map(int,input().split())) for i in range(3)]
for i in range(a[0]+1):
    b1=a[0]-i
    b2=a[1]-i
    b3=a[2]-i
    a2=[]
    a3=[]
    a2.append(b[0]-b1)
    a2.append(b[1]-b2)
    a2.append(b[2]-b3)
    a3.append(c[0]-b1)
    a3.append(c[1]-b2)
    a3.append(c[2]-b3)
    if len(set(a2))==1 and len(set(a3))==1:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n, w;
    cin >> n >> w;

    vector<int> x(n);
    for(int i=0; i<n; ++i)
        cin >> x[i];
    sort(x.begin(), x.end());

    if(x[0] > w || accumulate(x.begin(), x.end(), 0) <= w){
        cout << 1 << endl;
        return 0;
    }

    long long ret = 0;
    for(int i=0; i<n; ++i){
        if(x[i] > w)
            break;
        int sum = accumulate(x.begin(), x.begin()+i, 0);
        if(sum > w)
            break;

        vector<long long> dp(w+1, 0);
        dp[sum] = 1;
        for(int j=i+1; j<n; ++j){
            for(int k=w-x[j]; k>=0; --k){
                dp[k+x[j]] += dp[k];
                dp[k+x[j]] %= MOD;
            }
        }
        ret += accumulate(dp.end()-x[i], dp.end(), 0);
        ret %= MOD;
    }

    cout << ret << endl;

    return 0;
}

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

int main(void) {
	int X;
	scanf("%d", &X);
	if (400 <= X && X <= 599) printf("8\n");
	else if (600 <= X && X <= 799) printf("7\n");
	else if (800 <= X && X <= 999) printf("6\n");
	else if (1000 <= X && X <= 1199) printf("5\n");
	else if (1200 <= X && X <= 1399) printf("4\n");
	else if (1400 <= X && X <= 1599) printf("3\n");
	else if (1600 <= X && X <= 1799) printf("2\n");
	else if (1800 <= X && X <= 1999) printf("1\n");
	return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

const int NEU = -1;
const int UP = 1;
const int DOWN = 0;
int n;
int a[100010];
signed main() {
    cin >> n;
    rep(i,0,n) cin >> a[i];
    vector<int> v;
    int cnt = 1;
    int prev = -INF;
    int state = NEU;
    if(n != 1 && a[0] < a[1]) state = UP;
    if(n != 1 && a[0] > a[1]) state = DOWN;
    if(n != 1 && a[0] == a[1]) state = NEU;

    // bool ok = false;
    rep(i,1,n-1) {
        if(state == NEU) {
            if(a[i] < a[i+1]) state = UP;
            if(a[i] > a[i+1]) state = DOWN;
        }
        else if(state == UP) {
            if(a[i] > a[i+1]) {
                state = NEU;
                cnt++;
            }
        }
        else if(state == DOWN) {
            if(a[i] < a[i+1]) {
                state = NEU;
                cnt++;
            }
        }
    }
    /*
    rep(i,1,n-1) {
        if(state == NEU) {
            if(a[i] > a[i+1]) state = DOWN;
            if(a[i] < a[i+1]) state = UP;
        }
        if(state == UP && a[i] > a[i+1]) {
            state = DOWN;
            v.pb(i);
            if(i == n-2) ok = true;
        }
        if(state == DOWN && a[i] < a[i+1]) {
            state = UP;
            v.pb(i);
            if(i == n-2) ok = true;
        }
    }
    rep(i,0,v.size()) {
        printf("debug: v[i] = %lld\n", v[i]);
        if(prev == v[i]-1) continue;
        cnt++;
        prev = v[i];
    }
    if(ok && prev != n-2) cnt++;
    */
    cout << cnt << endl;
    return 0;
}

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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

const int N = 1e5+5;
int n,m;
vector<int> g[N];
int x,y;
int ans = 0;
int dp[N];
vector<bool> vis(N,0);

void dfs(int v)
{
  vis[v]=1;
  for(int u : g[v])
  {
    if(!vis[u])
    {
      dfs(u);
    }
    dp[v]=max(dp[v],dp[u]+1);
  }
}

void solve()
{
  cin >> n >> m;
  for(int i=0;i<m;i++)
  {
    cin >> x >> y;
    g[x].Pb(y);
  }
  for(int i=1;i<=n;i++)
  {
    if(!vis[i])
    {
      dfs(i);
    }
  }
  for(int i=1;i<=n;i++)
  {
    ans = max(ans,dp[i]);
  }
  cout << ans;
}

signed main()
{
  IOS;
  //freopen("input.txt", "rt", stdin);
  //freopen("output.txt", "wt", stdout);
  int t = 1;
  //cin >> t;
  //int tc = 1;
  while(t--)
  {
    //cout << "Case #" << tc << ": ";
    solve();
    //tc++;
  }
  return 0;
}
/*==============================================================================================================================================================*/


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

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

	auto N=in();

	while(N>0){
		N-=1000;
	}
	out(abs(N));
	return 0;
}


Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e12;


int main(){
	int n;
	cin>>n;
	LL res=1;
	REP(i,n)res*=(i+1);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  int res=0,cnt=0;
  while(n--){
    int a,b; cin>>a>>b;
    if(a==b) ++cnt; else cnt=0;
    res=max(res,cnt);
  }
  if(res>2) cout<<"Yes"; else cout<<"No";
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int a,b,c,d; cin >> a >> b >> c >> d;
  for(int i = 0; ;i++){
    c-=b;
    if(c <= 0){
      cout << "Yes" << endl;
      return 0;
    } else {
      a-=d;
      if(a <= 0){
	cout << "No" << endl;
	return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3596
import java.io.*;
import java.util.*;
import java.math.*;
 
class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;

    public static void main(String[] args) throws Exception {
        st = new StringTokenizer(br.readLine());
        int K = Integer.parseInt(st.nextToken());
        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());

        long ans = 0;
        if (A + 1 < B) {
            K -= (A - 1);
            ans += A;
            if (K > 0) {
                int times = K / 2;
                ans += times * ((long)B - A);
                K -= times * 2; 
            }
        }
        ans += K;

        pw.println(Math.max(K+1, ans));

        pw.close(); 
        br.close();
    }
}

class Pair implements Comparable<Pair>{
    public long x;
    public int y;
 
    Pair(long _x, int _y){
        x = _x;
        y = _y;
    }
 
    public String toString(){
        return x + " " + y;
    }

    public int compareTo(Pair p){
        if (x != p.x) return x < p.x ? -1 : 1;
        if (y != p.y) return y < p.y ? -1 : 1;
        return 0;
    }
} 

Measured memory_bytes: 22484
def f(n, x):
  """0 以上 n 以下の整数のうち、x で割り切れるものの個数"""
  return n // x + 1 if n >= 0 else 0
a, b, x = [int(i) for i in input().split()]
print(f(b, x) - f(a - 1, x))

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

#define mod 1000000007
#define ll long long
#define ld long double
typedef vector< long long > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sp(x) setprecision(x)
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define deb(x) cout<<#x <<x <<endl
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
        ll n;
        cin>>n;
        ll x=100;
        ll y=0;
        while(x<n){
        	x=x+(x/100);
        	y++;
        }
        cout <<y  << '\n';
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String tomorrow;
    switch (sc.next()) {
      case "Sunny":
        tomorrow = "Cloudy";
        break;
      case "Cloudy":
        tomorrow = "Rainy";
        break;
      case "Rainy":
      default:
        tomorrow = "Sunny";
        break;
    }

    System.out.println(tomorrow);
  }
}


Measured memory_bytes: 21460
N=int(input())
P=[]
for i in range(N):
    s=input()
    s=sorted(s)
    P.append(s)

P=sorted(P)
last=P[0]
cnt=0
ans=0
for i in range(1,N):
    if P[i]==last:
        cnt+=1
        ans+=cnt
    else:
        last=P[i]
        cnt=0
print(ans)

Measured memory_bytes: 31632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int n, m;
int h[100001];
int hh[100001];

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

    scanf( "%d %d", &n, &m );

    for( int i=1; i<=n; i++ ) 
        scanf( "%d", &h[i] );

    for( int i=0; i<m; i++ ) {

        scanf( "%d %d", &a, &b );
        if( h[a] >= h[b] ) hh[b] = 1;
        if( h[a] <= h[b] ) hh[a] = 1;
    }

    int tot = 0;
    for( int i=1; i<=n; i++ )
        if( hh[i] == 0 ) tot ++;

    printf( "%d\n", tot );
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(),(x).rend()

typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;

const int mod=1e+9+7;


int main(){
	int n,m;
	cin>>n>>m;

	if(abs(n-m)>=2){
		cout<<0<<endl;
		return 0;
	}

	bool bai=false;
	if(n==m)
		bai=true;

	ll ans=1;
	while(n){
		(ans*=n)%=mod;
		n--;
	}
	while(m){
		(ans*=m)%=mod;
		m--;
	}


	if(bai){
		cout<<2*ans%mod<<endl;
	}else{
		cout<<ans<<endl;
	}




	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

string str;

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

	ll n,i;

	cin >> str;
	n = str.size();

	if(n%2 == 1)
	{
		cout << "No" << "\n";
		return 0;
	}

	for(i=0;i<n;++i)
	{
		if(i%2 == 0 && str[i] != 'h')
		{
			cout << "No" << "\n";
			return 0;
		}
		else if(i%2 == 1 && str[i] != 'i')
		{
			cout << "No" << "\n";
			return 0;
		}
	}

	cout << "Yes" << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    cin >> n;
    vector<int>a(n+1);
    vector<int>b(n+1,0);
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=n;i>0;i--){
        int x=i;
        int sum=0;
        while(x<=n){
            sum+=b[x];
            x+=i;
        }
        sum%=2;
        if(sum!=a[i]) b[i]=1;
    }
    int ans=count(b.begin(),b.end(),1);
    cout << ans << endl;
    for(int i=1;i<=n;i++){
        if(b[i]==1) cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2432
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector> 
using namespace std;
//int tree[100001][100001];   too large
vector<int> tree[100005];
int checkbox[100005];
int snuke[100005];
int fennec[100005];
int N;

void dfs(int start, int dist, int member[]){

	checkbox[start] = 1;
	member[start] = dist;
	for(int i = 0; i < tree[start].size(); i++){
		if(tree[start][i] != 0 && checkbox[tree[start][i]] == 0){
			dfs(tree[start][i], dist+1, member);
		}
	}
	return;
}

void judge(int A[], int B[]){
	int fennec_s = 0;
	int snuke_s = 0;
	for(int i = 1; i <= N; i++){
		if(A[i] <= B[i]) fennec_s++;
		else snuke_s++;
	}
	if(fennec_s > snuke_s) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}



int main(){
	cin >> N;
	for(int i = 1; i <= N-1; i++){
		int x, y;
		cin >> x >> y;
		//tree[x][y] =1; tree[y][x] = 1;
		tree[x].push_back(y);
		tree[y].push_back(x);
	}

	for(int i = 1; i <= N; i++){
		checkbox[i] = 0;
		snuke[i] = 0;
		fennec[i] = 0;
	}



	dfs(1, 0, fennec);
	for(int i = 1; i <= N; i++){
		checkbox[i] = 0;
	}
	dfs(N, 0, snuke);
	/*
	cout << endl;
	for(int i = 1; i <= N; i++){
		cout << fennec[i] << " " << snuke[i] << endl;
	}

	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			cout << tree[i][j] << " ";
		}
		cout << endl;
	}
	*/
	judge(fennec, snuke);

}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e3;
int mt[N+2][N+2],cnt,f,dp[N*N+2],vis[N*N+2];
vector<int>adj[N*N+2];
void con(int n)
{
  cnt=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=i+1;j<=n;j++)
    {
      mt[i][j]=mt[j][i]=++cnt;
    }
  }
}
void findCycle(int nd)
{
  if(vis[nd]==1){f=1;return ;}
  if(vis[nd])return ;vis[nd]=1;
  for(auto x:adj[nd])
    findCycle(x);
  vis[nd]=2;
}
void dfs(int nd)
{
  if(dp[nd]!=-1)return ;
  dp[nd]=1;
  for(auto x:adj[nd])
  {
    dfs(x);
    dp[nd]=max(dp[nd],dp[x]+1);
  }
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n;cin>>n;con(n);
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;int nd=mt[i][x];
    for(int j=1;j<=n-2;j++)
    {
      cin>>x;adj[nd].push_back(mt[i][x]);
      nd=mt[i][x];
    }
  }
  for(int i=1;i<=cnt;i++)
  {
    findCycle(i);
    if(f)cout<<"-1"<<endl,exit(0);
  }
  memset(dp,-1,sizeof(dp));
  for(int i=1;i<=cnt;i++)
    dfs(i);
  int mx=0;
  for(int i=1;i<=cnt;i++)
    mx=max(mx,dp[i]);
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 51072
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <utility>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
int main(void) {
    int N;
    ll res = 0;
    cin >> N;
    for(int i = 0;i<N;i++) {
        int a;
        cin >> a;
        a--;
        res += a;
}
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5, inf = 1e9+7;
int n, k, i, j;
int dp[N];
vi adj[N];
int dfs(int id){
    if(dp[id]!=-1) return dp[id];
    dp[id]=0;
    for(auto i:adj[id]) dp[id] = max(dp[id], 1+dfs(i));
    return dp[id];
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n>>k;
    rep(i, 0, k){
        cin>>a>>b;
        adj[a].pb(b);
    }
    memset(dp, -1, sizeof dp);
    rep(i, 1, n+1) if(dp[i]==-1) dfs(i);
    cout<<*max_element(dp, dp+n+1);
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N,A,B;cin>>N>>A>>B;
    int X[N];
    REP(i,N)cin>>X[i];
    int ans=0;
    REP(i,N-1){
        ans+=min(B,A*(X[i+1]-X[i]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <queue>
#include <vector>
#include<iomanip>
using namespace std;
typedef long long ll;


int main(){
    int N, M, MAX_N = 1e5+10;
    vector<int> E[MAX_N];
    int ans[MAX_N];
    queue<int> q;
    cin >> N >> M;
    for(int i = 0; i < N; ++i){
        ans[i] = -1;
    }
    for(int i = 0; i < M; ++i){
        int a, b;
        cin >> a >> b;
        E[a-1].push_back(b-1);
        E[b-1].push_back(a-1);
    }

    q.push(0);
    while (!q.empty()){
        int v0 = q.front(); q.pop();
        for (int i = 0; i < E[v0].size(); ++i){
            int v1 = E[v0][i];
            if (ans[v1] == -1){
                ans[v1] = v0;
                q.push(v1);
            }
        }
    }
    bool check = true;
    for (int i = 1; i < N; ++i){
        check = check && (ans[i] != -1);
    }

    if (check) {
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    for (int i = 1; i < N; ++i){
        cout << ans[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10404
#include <stdio.h>
int binary(int );
int S[100000],n;
int main()
{
  int i,j,a,goukei =0;
  scanf("%d",&n);
  for(i=0; i<n; i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&a);
  for( i=0; i<a; i++)
    {
      scanf("%d",&j);
      if(binary(j)) goukei++;
    }
  printf("%d\n",goukei);
  return 0;
}


int binary(int x)
{
  int le=0,ri=n,mid;

  while(le<ri)
    {
      mid =(le+ri)/2;
      if(x==S[mid]) return 1;
      if(x>S[mid]) le =mid+1;
      if( x<S[mid]) ri= mid;
    }
  return 0;
}
  



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)

int main(void){
    ll K,tmp = 0;
    cin >> K;
    queue<ll> R;
    REP(i,9)R.push(i+1);

    FOR(i,0,K){
        tmp = R.front();
        if(tmp % 10 != 0){
            R.push(10*tmp + (tmp%10) - 1);
        }
        R.push(10*tmp + (tmp%10));
        if(tmp % 10 != 9){
            R.push(10*tmp + (tmp%10) + 1);
        }
        R.pop();
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, int> ll_i;

int main() {
    ll N;
    cin >> N;
    if (N % 2 == 0){
        cout << N << endl;
    } else {
        cout << 2*N << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main() {
  ll n; cin >> n;
  string ans = "";
  while(n>0){
    n--;
    ans += (char)('a' + (n%26));
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define MAXN 10010
#define pii pair<int, int>
#define pb push_back
#define mt make_tuple
typedef long long ll;

using namespace std;

int n;
ll dp[1010][30100];
vector<tuple<ll, ll, ll> > a;

bool sumsort(const tuple<ll, ll, ll>& a, const tuple<ll, ll, ll>& b){ 
    return (get<0>(a) + get<1>(a) < get<0>(b) + get<1>(b)); 
} 

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++){
        ll w, s, v;
    	cin >> w >> s >> v;
        a.pb(mt(w, s, v));
    }
    sort(a.begin(), a.end(), sumsort);
    for(int i = 0; i < n; i++){
        ll w, s, v;
        tie(w, s, v) = a[i];
        for(int j = 0; j <= 30000; j++){
            if(i == 0){
                if(j >= w) dp[i][j] = v;
                continue;
            }
            dp[i][j] = dp[i - 1][j];
            if(j < w) continue;
            dp[i][j] = max(dp[i][j], v + dp[i - 1][min(s, j - w)]);
        }
    }
    cout << dp[n - 1][30000];
}

Measured memory_bytes: 235776
n = int(input())
arr = []
for i in range(n):
    c = input()
    arr.append(c)
    
di = {"AC":0,"WA":0,"TLE":0,"RE":0}

for i in arr:
    if i in di:
        di[i] += 1 
    else:
        di[i] = 1 
        
print("AC x " + str(di.get("AC")))
print("WA x " + str(di.get("WA")))
print("TLE x " + str(di.get("TLE")))
print("RE x " + str(di.get("RE")))

Measured memory_bytes: 16124
/**
*
* Author: MARC
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl pi = 3.1415926535897932385;
const ldbl E = 2.71828182845904523536;
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1<<30;

/** /////////// ** Code ** /////////// **/

const int N=100100;
vector<int>adj[N];
int par[N];
int n;
int ans , res , res11;

void DFS(int u,int p,int cnt){
    if(u == n) ans=cnt;
    par[u]=p;
    for(auto v:adj[u]) if(v != p) DFS(v,u,cnt+1);
}

void DFS1(int u,int p){
    res11++;
    for(auto v:adj[u]) if(v != p) DFS1(v,u);
}

int main()
{
    scanf("%d",&n);
    for(int i=0 ; i<n-1 ; i++){
        int a,b; scanf("%d%d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    DFS(1,0,1);

    res=(ans/2)-1;

    int u=n;
    while(res--){
        if(par[u] == 1) break;
        u=par[u];
    }

    DFS1(u,par[u]);

    int Fen=n-res11;

    if(Fen > res11) printf("Fennec");
    else printf("Snuke");

    return 0;
}


Measured memory_bytes: 10752
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var k = sc.nextInt();
		var p = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		sc.close();

		Arrays.sort(p);
		var sum = 0L;
		for (int i = 0; i < k; i++) {
			sum += p[i];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 39148
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s)
{
  queue<int> q;
  q.push(s);
  for(int i = 0;i < n;i++) d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty())
    {
      u = q.front(); 
      q.pop();
      for(int v = 0;v < n;v++)
        {
          if(M[u][v] == 0) continue;
          if(d[v] != INFTY) continue;
          d[v] = d[u] + 1;
          q.push(v);
        }
    }
    for(int i = 0;i < n;i++)
      {
        cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
      }
}

int main()
{
  int u, k, v;
  int i,j;

  cin >> n;
  for(i=0;i < n;i++)
    {
      for(j=0;j < n;j++)
        {
          M[i][j] = 0;
        }
    }

  for(i=0;i < n;i++)
    {
      cin >> u >> k;
      u--;
      for(j=0;j < k;j++)
        {
          cin >> v;
          v--;
          M[u][v] = 1;
        }
    }

  bfs(0);

  return 0;

}


Measured memory_bytes: 3112
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, A, S, Goal;

struct Elem {
    int point;
    string s;
};

struct Edge {
    int to;
    string s;
};

signed main() {
    while(cin >> N >> A >> S >> Goal, N) {
        // dp テゥツ?催・ツ按? cnt テゥツ?催・ツ按療」ツつ津、ツスツ愿」ツつ?
        vector<string> dp(N, "");

        vector< vector<Edge> > G(N);
        rep(i,0,A) {
            int a, b; string s;
            cin >> a >> b >> s;
            G[b].push_back(Edge{a, s});
        }

        bool ng = false;
        rep(k,0,7*N) {
            bool updated = false;
            rep(i,0,N) {
                if(i != Goal && dp[i] == "") continue;
                for(auto e : G[i]) {
                    int to = e.to; string ss = e.s;
                    if((to != Goal && dp[to] == "") || dp[to] > ss + dp[i]) {
                        updated = true;
                        dp[to] = ss + dp[i];
                    }
                }
            }
            if(!updated) break;
        }

        if(dp[S].length() > 6*N) ng = true;
        if(ng || dp[S] == "") cout << "NO" << endl;
        else cout << dp[S] << endl;
    }
    return 0;
}

Measured memory_bytes: 3388
#include <iostream>
#include <vector>
using namespace std;
long long int arr[16][16];
vector<long long int> bits_on[200000];
long long int total_score[200000];

long long int dp[200000];

long long int foo(long long int mask)
{
    if(dp[mask] != -1) return dp[mask];
    if(mask == 0) 
        {
            dp[mask] = 0;
            return 0;
        }
    long long int maxm = -1;

    long long int sz = bits_on[mask].size();

    for (long long int i = 1; i < (1 << sz); ++i)
    {
         long long int tmpmask = 0;
         for (long long int j = 0; j < bits_on[mask].size(); ++j)
         {
             if(i & (1<<j))
             {
                tmpmask |= (1 << bits_on[mask][j]);
             }
         }
         maxm = max(total_score[tmpmask] + foo(mask ^ tmpmask), maxm);
    }
    dp[mask] = maxm;
    return maxm;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    for (int i = 0; i < 200000; ++i)
    {
        dp[i] = -1;
    }
    long long int n;
    cin >> n;
    for (long long int i = 0; i < n; ++i)
    {
        for (long long int j = 0; j < n; ++j)
        {
            cin >> arr[i][j];
        }
    }

    for (long long int i = 0; i < (1 << n); ++i)
    {
        for (long long int j = 0; j < 17; ++j)
        {
            if(i & (1 << j))
            {
                bits_on[i].push_back(j);
            }
        }
        long long int score = 0;
        for (long long int j = 0; j < bits_on[i].size(); ++j)
        {
             for (long long int k = j + 1; k < bits_on[i].size(); ++k)
             {
                 score += arr[bits_on[i][j]][bits_on[i][k]];
             }
        }
        total_score[i] = score;
    }



    cout << foo((1<<n)-1);
    return 0;
}

Measured memory_bytes: 16768
from collections import Counter
N, K = map(int, input().split())
A = list(map(str, input().split()))
A.sort()
A_set = list(set(A))
A_set.sort()
c = Counter(A)
if len(A_set) <= K:
    print(0)
    exit()
lists = []
for i in range(len(A_set)):
    lists.append(c[str(A_set[i])])
cnt = 0
lists.sort()
for i in range(len(lists) - K):
    cnt += lists[i]
print(cnt)


Measured memory_bytes: 42160
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    in(n);
    vector<int> vec(n);
    int ans=0;
    in(vec);
    sort(all(vec));
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(vec[k]>=(vec[i]+vec[j])){
                    break;
                }else{
                    ans++;
                }
            }
        }
    }
    out(ans);
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d", &n);
    int p[n];
    int i, k = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &p[i]);
    }
    for (i = 1; i < n - 1; i++)
    {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1]))
        {
            k++;
        }
    }
    printf("%d\n", k);
    return 0;
}

Measured memory_bytes: 128
X = int(input())
if 400<= X < 600:
  print(8)
elif 600<= X < 800:
  print(7)
elif 800<= X < 1000:
  print(6)
elif 1000<= X < 1200:
  print(5)
elif 1200<= X < 1400:
  print(4)
elif 1400<= X < 1600:
  print(3)
elif 1600<= X < 1800:
  print(2)
elif 1800<= X < 2000:
  print(1)

Measured memory_bytes: 9188
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n = int(input().strip())
    S = input().strip()
    stack = []
    ans = 0
    for c in S:
        if c == '#':
            stack.append('#')
        else:
            if len(stack) != 0:
                stack.pop()
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);
#define debug(x , y) cerr << #x << " = " << x << y ;

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int len , x ;

int main(){
 cin >> len >> x ;
 set < int > in ;
 vector < int > a ;
 forn( int , i , 0 , len ){
   a.pb( x - i ) ;
   in.insert( x - i ) ;
 }
 reverse( all( a ) ) ;
 fore( i , a ){
   forn( int , j , 0 , len ){
      in.insert( i + j ) ;
   }
 }

 fore( i , in ){
   cout << i << " " ;
 }

 return 0 ;
}

/*
A B C D
try to solve A , B in 30 min as possible
If their is subtask try to solve the second one first if the constraints are only differ
Read all Problem so you could find an ex that you can solve fast
A -- don't write big code focus again
B -- greedy , math , bit mask , tricks , DP
C -- solve A , B first then solve C but fast as possible
greedy
DP
binary search
DFS , BFS , DSU( detect a cycle , make sets )
bit mask
number theory , math
meet in the middle
focus on the problem and constraints.
*/


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

std::vector< int > L;

int binary_search(int key) {
    int left = -1;
    int right = (int)L.size();
    
    while(right - left > 1){
        int mid = left + (right - left) / 2;
        
        if(L[mid] >= key){
            right = mid;
        }else{
            left = mid;
        }
    }
    
    return left;
}

int main(){
    int N;
    std::cin >> N;
    L.resize(N);
    for(int i=0; i<N; i++){
        std::cin >> L[i];
    }
    
    std::sort(L.begin(), L.end());
    
    int cnt = 0;
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){
            int length2 = L[i] + L[j];
            int index = binary_search(length2);
            cnt += index - j;
        }
    }
    
    std::cout << cnt << std::endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#define MAX 1000000007
long long int fact(int n){
  if(n == 1){
    return n%MAX;
  }else{
    return ((n%MAX)*(fact(n-1)%MAX))%MAX;
  }
}
int max(int n,int m){
  if(n<m){
    return m;
  }else{
    return n;
  }
}
int min(int n,int m){
  if(n>m){
    return m;
  }else{
    return n;
  }
}
int main(void){
  int N,M;
  long long int ans=0;
  std::cin >> N >> M;
  if(abs(N-M) > 1){
    printf("0");
    return 0;
  }else if(abs(N-M) == 1){
    ans = fact(max(N,M));
    ans = ((ans%MAX)*(fact(min(N,M))%MAX))%MAX;
    printf("%lld",ans);
    return 0;
  }else{
    ans = fact(N);
    ans =((2%MAX)*(ans%MAX)*(ans%MAX))%MAX;
    printf("%lld",ans);
    return 0;
  }
}

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

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

	int ans = 1;

	while(true){
		if(ans*2 <= n) ans *= 2;
		else break;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void){
  int n;
  cin >> n;

  vector<int> idx(n);
  iota(idx.begin(), idx.end(), 0);

  vector<pair<string, int>> v(n);
  for(int i=0; i<n; i++){
    string s; int p;
    cin >> s >> p;
    v[i] = pair<string, int>(s, p);
  }

  sort(idx.begin(), idx.end(), [v](int x, int y) -> int {
      if(v[x].first == v[y].first){
        return (v[x].second > v[y].second);
      }
      return v[x].first < v[y].first;
  });

  for(auto i : idx) {
    cout << (i+1) << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
  string s=stin();
  if(s.size()%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
  rep(i,s.size()/2){
    if(!(s[i*2]=='h' && s[i*2+1]=='i')){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	a := eGetInt(scanner)
	b := eGetInt(scanner)
	s := ""
	if a > b {
		for i := 0; i < a; i++ {
			s = s + fmt.Sprintf("%d", b)
		}
	} else {
		for i := 0; i < b; i++ {
			s = s + fmt.Sprintf("%d", a)
		}
	}
	fmt.Println(s)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	return int(math.Pow(float64(a), float64(n)))
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    ll a,b;
    cin>>a>>b;
    ll ans=INF;
    if(b-a>=0)ans=min(ans,b-a);
    if(1+b+a>=0)ans=min(ans,1+b+a);
    if(-b-a+1>=0)ans=min(ans,-b-a+1);
    if(-b+a+2>=0)ans=min(ans,-b+a+2);
    fin(ans);
        
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	int a = A + B;
	int b = A - B;
	int c = A * B;

	cout << max({ a,b,c }) << endl;
}


Measured memory_bytes: 3628