akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main
{
  public static void main(String args[])throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   StringTokenizer st = new StringTokenizer(br.readLine());
   int h1 = Integer.parseInt(st.nextToken());
   int s1 = Integer.parseInt(st.nextToken());
   int h2 = Integer.parseInt(st.nextToken());
   int s2 = Integer.parseInt(st.nextToken());
   int t1 = (h2%s1==0?h2/s1:h2/s1+1);
   int t2 = (h1%s2==0?h1/s2:h1/s2+1);
   if(t1<=t2)
   	System.out.println("Yes");
   else
   		System.out.println("No");
   }
}


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

using namespace std;

int main(){
	long long n;
	cin>>n;
	long long m=n;
	int sum=1;
	int ans2=0;
	while(m>=10)
	{
		ans2+=m%10;
		m/=10;
		sum++;
	}
	ans2+=m;
	int x=m;
	int ans1=x-1+(sum-1)*9;
	cout<<max(ans1,ans2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define rep(i,n) for(int i=0;(i)<(n);i++)
typedef long long ll;
using namespace std;
ll fact(ll n){
    if(n<=1) return 1;
    else return ((n%mod)*fact(n-1))%mod;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll modinv(ll a) {
    return modpow(a, mod - 2);
}
int main(void){
    ll n; cin >> n;
    ll inv [100003];
    ll x[100003];
    rep(i,n) cin >> x[i];
    ll ans = 0;
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = -1ll * (mod / i) * inv[mod % i] % mod;
    ll tmp = 0;
    rep(i,n-1){
        tmp = (tmp + inv[i+1])%mod;
        ans = (1ll*(x[i+1]-x[i])*tmp + ans)%mod;
    }
    rep(i,n-1) ans = 1ll*ans*(i+1)%mod;
    cout << (ans+mod)%mod << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
 
using namespace std;
 
using ll = long long int;
 
int result[310][310] = {};
 
int main(void) {
 
	int t, x;
	cin >> x >> t;
 
	cout << max(0,x - t) << endl;
 
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final long takahashi = Long.valueOf(scn.next());
			final long aoki = Long.valueOf(scn.next());
			final long actionCount = Long.valueOf(scn.next());
			
			long ret1,ret2;
			if(takahashi + aoki < actionCount){
			    ret1 = 0;
			    ret2 = 0;
			}else if(takahashi < actionCount){
			    ret1 = 0;
			    ret2 = aoki - actionCount + takahashi;
			}else {
			    ret1 = takahashi - actionCount;
			    ret2 = aoki;
			}
			
		
			System.out.println(ret1+ " " + ret2);
		}
	}
}


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

public class Main {

  private static void solve() {
    int n = nextInt();
    int m = nextInt();

    Map<Integer, List<Integer>> graph = new HashMap<>();

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

      graph.computeIfAbsent(a, (k) -> new ArrayList<>()).add(b);
    }

    Stack<Integer> order = new Stack<>();
    boolean[] vis = new boolean[n + 1];
    for (int i = 1; i <= n; i++) {
      if (!vis[i]) {
        dfs(i, graph, vis, order);
      }
    }

    int[] dist = new int[n + 1];
    int ans = 0;
    Arrays.fill(dist, 0);
    while (!order.isEmpty()) {
      Integer last = order.pop();
      List<Integer> neighbours = graph.getOrDefault(last, new ArrayList<>());

      for (Integer neighbour : neighbours) {
        dist[neighbour] = Math.max(dist[neighbour], dist[last] + 1);
        ans = Math.max(ans, dist[neighbour]);
      }
    }


    System.out.println(ans);
  }

  private static void dfs(int cur, Map<Integer, List<Integer>> graph, boolean[] vis, Stack<Integer> order) {
    vis[cur] = true;

    List<Integer> neighbours = graph.getOrDefault(cur, new ArrayList<>());

    for (Integer neighbour : neighbours) {
      if (!vis[neighbour]) {
        dfs(neighbour, graph, vis, order);
      }
    }

    order.push(cur);
  }

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

  private static int nextInt() {
    return Integer.parseInt(next());
  }

  private static long nextLong() {
    return Long.parseLong(next());
  }

  public static void main(String[] args) {
    run();
  }
}

Measured memory_bytes: 71460
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
vi v;
void sieve(int n)
{
    bool prime[n+1];
    memset(prime,true,sizeof(prime));
    prime[1]=false;
    for(int i=2;i*i<=n;i++)
    {
        for(int j=2*i;j<=n;j+=i)
        {
            prime[j]=false;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(prime[i])
            v.pb(i);
    }
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   sieve(55555);
   vi ans;
   int j=0;
   while(ans.size()<n)
   {
       if(v[j]%5 == 1)
        ans.pb(v[j]);
       j++;
   }
   for(auto x:ans)
    cout<<x<<" ";

}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,m;

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	if(abs(n-m)>1){puts("0");return 0;}
		int ans=1;
		for(int i=1;i<=n;i++)
			ans=(ll)ans*i%mod;
		for(int i=1;i<=m;i++) ans=(ll)ans*i%mod;
	if(n==m) ans=ans*2%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
    //#ifndef ONLINE_JUDGE
  //  freopen("input.txt","r",stdin);
   //// freopen("output.txt","w",stdout);
   // #endif
    cin>>s;
    int l=s.size();
    for(int i=0;i<l;i++){
    	cout<<'x';
    }cout<<endl;
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


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

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

const int MAXW = 9, MAXH = 9;

int tile[MAXW][MAXH];
bool e[MAXW][MAXH];
int c[10];
int dx[] = {0, 3, 6};
int dy[] = {0,3, 6};

int main()
{
    int n;
    cin >> n;
    rep(k,n)
    {
        if(k > 0) cout << endl;
        memset(c, 0, sizeof(c));
        memset(e, false, sizeof(e));
        rep(j,9)rep(i,9) cin >> tile[i][j];

        rep(i,9)
        {
            memset(c, 0, sizeof(c));
            rep(j,9) c[tile[j][i] ] ++;
            rep(j,9)if(c[tile[j][i] ] > 1) e[j][i] = true;

            //vartical
            memset(c, 0, sizeof(c));
            rep(j,9) c[ tile[i][j] ]++;
            rep(j,9) if(c[tile[i][j]] > 1) e[i][j] = true;
        }

        rep(t,3)rep(s,3)
        {
            memset(c, 0, sizeof(c));
            rep(i,3)rep(j,3) c[tile[i + dx[s]][j + dy[t]]]++;
            rep(i,3)rep(j,3)if(c[tile[i + dx[s]][j + dy[t]]] > 1) e[i + dx[s]][j + dy[t]] = true;
        }

        rep(j,9)
        {
            rep(i,9)
            if(e[i][j] ) cout << "*" << tile[i][j];
            else cout << " " << tile[i][j] ;
            
            cout << endl;
        }

    }
    

    return 0;
}

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

Measured memory_bytes: 256
import java.util.*;


public class Main  {
    private static Scanner sc= new Scanner(System.in);
    public static void main(String[] args) {
        int n=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        double s=a[0];
        for(int i=1;i<n;i++){
            s=(s+a[i])/2;
        }
        System.out.print(s);


    }}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int n;
char a[N];

int main()
{
    cin >> a;
    n = strlen(a);
    int q = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == 'A' || a[i] == 'C' || a[i] == 'G' || a[i] == 'T')
            ++q;
        else
        {
            ans = max(ans, q);
            q = 0;
        }
    }
    ans = max(ans, q);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l=[-1]*n
flag=0
for _ in range(m):
    i,el=map(int,input().split())
    if i==1 and el==0 and n!=1:
        flag=1
        break
    if l[i-1]==-1 :
        l[i-1]=el
    elif l[i-1]!=el:
        flag=1
        break
if(flag==1):
    print(-1)
elif m==0 and n==1:
    print(0)
else:
    if l[0]==-1:
        l[0]=1;
    for i in range(1,len(l)):
        if l[i]==-1:
            l[i]=0
    for i in l:
        print(i,end="")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

      String line = br.readLine();
      StringBuffer str = new StringBuffer(line.length());
      String s;

      for(int i = 0;i < line.length();i++) {
        s = line.substring(i,i+1);
        if( Character.isUpperCase(s.charAt(0)) )
          str.append(s.toLowerCase());
        else if ( Character.isLowerCase(s.charAt(0)) )
          str.append(s.toUpperCase());
        else
          str.append(s);
      }

      System.out.println(str);
    }
  }
}


Measured memory_bytes: 24464
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

vint edge[100000];
int group[100000];
vector<vector<ll>> add;

void dfs(int pos, int k) {
	group[pos] = k;
	rep(i, edge[pos].size()) {
		int to = edge[pos][i];
		if (group[to] == -1)	dfs(to, k);
	}
}

int main() {
	int n, m;	cin >> n >> m;
	vector<ll> a(n);
	rep(i, n)	cin >> a[i];
	rep(i, m) {
		int x, y;	cin >> x >> y;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	int k = 0;
	rep(i, n)	group[i] = -1;
	rep(i, n)	if (group[i] == -1)	dfs(i, k++);
	if (n < 2 * (k - 1)) {
		cout << "Impossible" << endl;
		return 0;
	}
	if (k == 1) {
		cout << 0 << endl;
		return 0;
	}
	add.resize(k);
	rep(i, n)	add[group[i]].push_back(a[i]);
	rep(i, k)	sort(all(add[i]));
	rep(i, k)	group[i] = i;
	ll ret = 0;
	rep(i, k)	ret += add[i][0];
	priority_queue<ll> pq;
	rep(i, k)	srep(j, 1, add[i].size())	pq.push(-add[i][j]);
	rep(i, k - 2) {
		ret += -pq.top();	pq.pop();
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 9600
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long ans = 0;
		String s = sc.next();
        int [] l = new int [s.length()+1];
        int [] r = new int [s.length()+1];        
        for(int i=0;i<s.length();i++){if(s.charAt(i)=='<'){l[i+1]=l[i]+1;}
                                     }
        for(int i=s.length()-1;i>=0;i--){if(s.charAt(i)=='>'){r[i]=r[i+1]+1;}
                                        }
        for(int i=0;i<s.length()+1;i++){ans+=Math.max(l[i],r[i]);}      
		System.out.println(ans);
	}
}

Measured memory_bytes: 32968
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
#include <cassert>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const LL MOD = 998244353;
const int MAX = 2 * 1000 * 100 + 47;

LL bp(LL n, LL k) {
    LL res = 1;
    while (k) {
        if (k & 1) res = (res * n) % MOD;

        k >>= 1;
        n = n * n % MOD;
    }

    return res;
}

LL inv(LL a) {
    return bp(a, MOD - 2);
}

LL F[MAX];
LL RF[MAX];
LL cc(int n, int k) {
    //if (n < k) return 1;

    LL res = F[n] * RF[k] % MOD;
    res = res * RF[n - k] % MOD;
    return res;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false); cin.tie(0);
    
    F[0] = RF[0] = 1;
    FOR(i, 1, MAX) {
        F[i] = F[i - 1] * i % MOD;
        RF[i] = inv(F[i]);
        assert(RF[i] * F[i] % MOD == 1);
    }

    LL n, m, k;
    cin >> n >> m >> k;

    LL res = 0;
    FOR(i, 0, k + 1) {
        LL dod = m * bp(m - 1, n - i - 1) % MOD;
        //cerr << i << ": " << dod << endl;
        //cerr << i << ">> " << n - i << " " << i << ": " << bp(n - i, i) << endl;
        dod = dod * cc(n - 1, n - i - 1) % MOD;
        //cerr << i << ": " << dod << endl;
        res = (res + dod) % MOD;
    }

    cout << res << endl;
}

Measured memory_bytes: 6776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, n) for (int i = (a); i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (ll)1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll money = 1000;
  ll stock = 0;

  for (int i = 0; i < n - 1;i++) {
    if (a[i] >= a[i + 1]) continue;
    stock = money / a[i];
    money += stock * (a[i + 1] - a[i]);
  }
  cout << money << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<cstdlib>
#include<cmath>
#define MAX_OPERANTD 1000000

int operand_count;
int operands[MAX_OPERANTD];


void push(int num) {
  operands[operand_count] = num;
  operand_count++;
}

int pop() {
  int poped;
  poped = operands[operand_count - 1];
  operand_count--;
  return poped;
}

int main() {
  int operand_max_digit;
  operand_max_digit = log10(MAX_OPERANTD) + 1;
  char expression[operand_max_digit];
  int left_operand, right_operand;

  while(true) {
    if(scanf("%s", expression) == EOF) {
      break;
    }

    switch(expression[0]) {
      case '+':
        right_operand = pop();
        left_operand = pop();
        push(left_operand + right_operand);
        break;
      case '-':
        right_operand = pop();
        left_operand = pop();
        push(left_operand - right_operand);
        break;
      case '*':
        right_operand = pop();
        left_operand = pop();
        push(left_operand * right_operand);
        break;
      default:
        push(atoi(expression));
      }
  }

  int result = pop();
  printf("%d\n", result);
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(a>b)swap(a,b);
    cout<<max(0ll,b-a-w)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    int n,m,x,y,z,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(x=1;x<n;x++){
            for(y=1;y<n;y++){
                for(z=1;z<n;z++){
                    if(x*x+y*y+z*z+x*y+x*z+y*z==i) cnt++;
                    if(x*x+y*y+z*z+x*y+x*z+y*z>i) break;
                }
                z=1;
                if(x*x+y*y+z*z+x*y+x*z+y*z>i) break;
            }
            z=1,y=1;
            if(x*x+y*y+z*z+x*y+x*z+y*z>i) break;
        }
        cout<<cnt<<endl;
        cnt=0;
    }
    return 0;
}

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


int main() {
    ll N, M;

    cin >> N >> M;

    ll ans = N;

    vector<int> A(M);

    for (ll i = 0; i < M; i++) {
        cin >> A.at(i);

        ans -= A.at(i);
    }


    if (ans < 0) ans = -1;


    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {

	/*??????????????????*/
	public static void judge(int S){
		if(S<0||S>=86400){
			System.out.println("0~86400????????????.???????????????.");
			System.exit(0); ;
		}

	}

	 public static void main(String[] args) throws IOException{
		// TODO ?????????????????????????????????????????????

		/*?????°?????£?¨?*/
		int h,m,s,S=0; //?????????????????¨????????????????§???°
		int hour,minutes; //??????(?§?)?????????
		String str;

		/*?§???°???????????????*/

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		str = br.readLine();
		S = Integer.parseInt(str);

		judge(S); /*?§???°S?????¶?´???????*/

		/*???????????????*/
		h = S/3600;
		hour = S%3600;

		m = hour/60;
		minutes = hour%60;

		s = minutes;


		System.out.println(h+":"+m+":"+s);

	}

}

Measured memory_bytes: 24060
class Integer
    def popcnt
        v = self
        v -= (v >> 1) & 0x55555555
        v = (v & 0x33333333) + ((v >> 2) & 0x33333333)
        (((v + (v >> 4) & 0x0f0f0f0f) * 0x01010101) >> 24) & 0x3f
    end
end

# 参考
# https://takeda25.hatenablog.jp/entry/20130303/1362301095
# https://www.slideshare.net/pfi/ss-15916040
class WaveletMatrix
    def initialize(a)
        m = a.max.bit_length
        @bits = []; @bits_popcnt = []; @offset = []
        m.times do |i|
            mask = 1 << m - 1 - i
            jj = i - m
            @bits.push(a.each_slice(32).map { |x| j = jj;res = 0;x.each { |k| res += ((k & mask) << (j += 1)) };res })
            @bits_popcnt.push(@bits[i].push(tmp=0).map { |x| tmp += x.popcnt })
            a, b = a.partition { |x| (x & mask).zero? }
            @offset.push(a.size)
            a.concat(b)
        end
        @omega = (1 << m) - 1
    end

    def _rank1(lev, k) @bits_popcnt[lev][k>>5] - (@bits[lev][k>>5] >> (k & 31)).popcnt end

    # Algorithm 7 of F. Claude, G. Navarro, and A. Ordóñez. (2015) doi:10.1016/j.is.2014.06.002
    def count(l, r, x, y) sub_count(0, l, r, x, y, 0, @omega) end

    def sub_count(lev, x1, x2, y1, y2, alpha, omega)
        ### comment out for speed ###
        #  return 0 if (x2 < x1) || (y2 < alpha) || (omega < y1)
        #  return x2 - x1 + 1 if (y1 <= alpha) && (omega <= y2)
        xr1 = _rank1(lev, x1-1)
        xr2 = _rank1(lev, x2)
        xl1 = x1 - xr1
        xl2 = x2 - xr2
        xr1 += @offset[lev] + 1
        xr2 += @offset[lev]
        mu = alpha + omega >> 1
        ### comment out for speed ###
        # return sub_count(lev+1, xl1, xl2, y1, y2, alpha, mu) + sub_count(lev+1, xr1, xr2, y1, y2, mu+1, omega)
        (((xl2 < xl1) || (mu < y1)) ? 0 : (mu <= y2) ? xl2 - xl1 + 1 : sub_count(lev+1, xl1, xl2, y1, y2, alpha, mu)) + \
            (((xr2 < xr1) || (y2 <= mu)) ? 0 : (omega <= y2) ? xr2 - xr1 + 1 : sub_count(lev+1, xr1, xr2, y1, y2, mu+1, omega))
    end
end

N, M, Q = gets.split.map(&:to_i)

lr = $<.read.split.map!(&:to_i) 
pq = lr.pop(Q<<1)
lr = lr.each_slice(2)
idx = Array.new(N+2, 0)
lr.each { |l, _| idx[l] += 1 }

# return
tmp = 0
idx.map! { |x| tmp += x }
wm = WaveletMatrix.new lr.sort_by(&:shift).map!(&:pop)

puts pq.each_slice(2).map { |pp, qq| wm.count(idx[pp-1]+1, idx[qq], pp, qq) }

# こんなことよりも色に見合った精進すべきなんだよなぁ。


Measured memory_bytes: 80204
#include<bits/stdc++.h>
#define re register
#define LL long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read() {
	char c=getchar();int x=0;while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
const int mod=1e9+7;const int maxn=1e5+5;
int n,m,b[maxn];
struct Vector{int v[3];}D,ans;
struct Matrix{int a[3][3];}C,pw[32],G;
inline int qm(int x) {return x>=mod?x-mod:x;}
inline Matrix operator*(const Matrix &A,const Matrix &B) {
	for(re int i=0;i<3;i++)
		for(re int j=0;j<3;j++)C.a[i][j]=0;
	for(re int k=0;k<3;k++)
		for(re int i=0;i<3;i++)
			for(re int j=0;j<3;j++)C.a[i][j]=qm(C.a[i][j]+1ll*A.a[i][k]*B.a[k][j]%mod);
	return C;
}
inline Vector operator^(const Vector &A,const Matrix &B) {
	for(re int i=0;i<3;i++)D.v[i]=0;
	for(re int i=0;i<3;i++) 
		for(re int j=0;j<3;j++) D.v[i]=qm(D.v[i]+1ll*A.v[j]*B.a[i][j]%mod);
	return D;
}
inline void mul(int x) {
	for(re int i=0;(1<<i)<=x;i++) 
		if(x>>i&1) ans=ans^pw[i];
}
int main() {
	n=read(),m=read();ans.v[0]=1;
	for(re int i=1;i<=m;i++)b[i]=read();
	std::sort(b+1,b+m+1);
	for(re int i=0;i<3;i++)
		for(re int j=0;j<3;j++) pw[0].a[i][j]=1;
	pw[0].a[0][0]=pw[0].a[1][0]=2,pw[0].a[1][2]=0;
	for(re int i=1;(1<<i)<=n;++i) pw[i]=pw[i-1]*pw[i-1];
	G.a[1][0]=2;G.a[0][0]=G.a[1][1]=G.a[2][2]=G.a[2][0]=G.a[2][1]=1;
	for(re int i=1;i<=m;i++) mul(b[i]-b[i-1]-1),ans=ans^G;
	mul(n-b[m]);printf("%d\n",ans.v[2]); 
	return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
V = list(map(int, input().split()))

s = 0
for i in range(K + 1): # 左から取り出す回数
    for j in range(K + 1 - i): # 右から取り出す回数
        if i + j > N:
            continue
        
        a = V[:i] + V[N-j:]
        r = K - i - j # 戻すことのできる回数

        a.sort()
        for k in range(min(len(a)+1, r+1)):
            s = max(s, sum(a[k:]))

print(s)

Measured memory_bytes: 3060
var
  n,k,i,j,t,x:longint;
  a:array[1..50]of longint;
begin
  readln(n,k);
  for i:=1 to n do
    read(a[i]);
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if a[i]<a[j] then begin t:=a[i];a[i]:=a[j];a[j]:=t;end;
  for i:=1 to k do
    x:=x+a[i];
  writeln(x);
end.

Measured memory_bytes: 128
n, m = map(int, input().split())
if n%2 == 1:
    a = 1
    b = n+1
    ans = []
    for i in range(m):
        a += 1
        b -= 1
        ans.append((a, b))
else:
    a = 1
    b = n+1
    S = set()
    ans = []
    for i in range(m):
        a += 1
        b -= 1
        r = min(b-a, n-(b-a))
        if r in S or r == n//2:
            b -= 1
            r = min(b-a, n-(b-a))
        ans.append((a, b))
        S.add(r)
for i in range(m):
    print(*ans[i])


Measured memory_bytes: 84344
use whiteread::parse_line;

fn main() {
    let (a, b): (isize, isize) = parse_line().unwrap();

    if a > 0 {
        println!("Positive");
    } else if b >= 0 {
        println!("Zero");
    } else if (b - a) % 2 == 1 {
        println!("Positive");
    } else {
        println!("Negative");
    }
}


Measured memory_bytes: 2184
n = int(input())
b = []
ASUM = 0
BSUM = 0
for i in range(n):
  x,y = map(int,input().split())
  b.append([x,i])
  b.append([y,i])
  ASUM += x
  BSUM += y
a = sorted(b)
tuka = [0] * n
flag = 0
for i in range(n):
  if tuka[a[i][1]] == 1:
    flag = 1
    break
  else:
    tuka[a[i][1]] = 1
ans = 0
for i in range(n):
  ans += a[i][0]
if flag == 0:
  tmp = float("inf")
  las = a[n-1]
  bu = a[n-2]
  for i in range(n):
    if las[1] == i:
      tmp = min(tmp,max(b[i*2][0],b[i*2+1][0])-bu[0])
    else:
      tmp = min(tmp,max(b[i*2][0],b[i*2+1][0])-las[0])
  ans += tmp
ans = min(ans,ASUM,BSUM)
print(ans)

Measured memory_bytes: 37096
n=int(input());a=list(map(int,input().split()));e=[[]for _ in[0]*n]
for x,y in[map(int,input().split())for _ in[0]*(n-1)]:e[x-1].append(y-1);e[y-1].append(x-1)
def b(r,v):return sum((r!=i)and(a[v]>a[i])and(not(b(v,i)))for i in e[v])
print(*[i+1for i in range(n)if b(n,i)])

Measured memory_bytes: 62680
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	if(s[2] == s[3]  && s[4] == s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;

int main(void) {

    int n; cin >> n;
    vector<string> d;
    set<int> ds;
    for (int i = 0; i < n; i++) { // ??????
        string s; cin >> s;
        d.push_back(s);
        ds.insert(stoi(s));
    }
    for (int i = 0; i < n-1; i++) { // ??????
        ds.insert(stoi(d[i]+d[i+1]));
    }
    for (int i = 0; i < n-2; i++) { // ??????
        ds.insert(stoi(d[i]+d[i+1]+d[i+2]));
    }

    int cnt = 0;
    for (auto x : ds) {
        if (cnt != x) break;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3260
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        a: u64,
        b: u64,
        c: u64,
        x: u64,
        y: u64,
    }

    let ab_only = c * 2 * x.max(y);
    let no_ab = a * x + b * y;
    let ab_and = if x < y {
        c * 2 * x + b * (y - x)
    } else {
        c * 2 * y + a * (x - y)
    };
    println!("{}", ab_only.min(no_ab.min(ab_and)));
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
  //  #endif
   ll k,q;
   cin>>n>>k>>q;
   vector<int>v(n,k),v2(n);
   for(int i=0;i<q;i++)
   	{
   		cin>>a;
   		a--;
   		v2[a]++;
   	}

   for(int i=0;i<n;i++){
   	v[i]-=(q-v2[i]);
   	if(v[i]<=0)cout<<"No"<<endl;
   	else cout<<"Yes"<<endl;
   }

   //for(auto it:v)cout<<it<<" ";
   //	cout<<endl;
  

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


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

void solve(long long N, long long x, std::vector<long long> A){
    vector<ll> a = A;
    ll res = 0;
    if(a[0] > x) a[0] = x;
    for(ll i = 0; i < N-1; ++i){
        if(a[i] + a[i+1] > x){
            if(a[i+1] >= a[i] + a[i+1] - x){
                a[i+1] -= a[i] + a[i+1] - x;
            }
            else{
                a[i] -= abs(a[i+1] - (a[i] + a[i+1] - x));
                a[i+1] = 0;
            }
        }
    }
    for(ll i = 0; i < N; ++i){
        res += A[i] - a[i];
    }
    cout << res << endl;
    return;
}

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


Measured memory_bytes: 4832
import itertools
from copy import deepcopy

abc = input().split()
a = int(abc[0])
b = int(abc[1])
c = int(abc[2])
k = int(input())

perms = itertools.product([0, 1, 2], repeat=k)
bool_ = False

for perm in perms:
  tmp = [deepcopy(a), deepcopy(b), deepcopy(c)]
  
  for idx in perm:
    tmp[idx] *= 2
    
  if tmp[0] < tmp[1] and tmp[1] < tmp[2]:
    print('Yes')
    bool_ = True
    break
    
if not bool_:
  print('No')
  

Measured memory_bytes: 9340
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#define ll long long

using namespace std;

int main(){
    int N;
    cin >>N;
    vector<int> H(N,0);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    int ans=1;
    int max=H[0];
    for(int i=1;i<N;i++){
        if(max<=H[i]){
            ans++;
            max=H[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  long long N;
  cin >> N;
  long long A = N / 15;
  long long B = N / 3;
  long long C = N / 5;
  long long sum1 = 0;
  long long sum2 = 0;
  long long sum3 = 0;
  long long sum4 = 0;
  for (long long i = 0; i < N; i++) {
    sum1 = sum1 + i + 1;
  }
  for (long long i = 0; i < A; i++) {
    sum2 = sum2 + 15 * i + 15;
  }
  for (long long i = 0; i < B; i++) {
    sum3 = sum3 + 3 *i + 3;
  }
  for (long long i = 0; i < C; i++) {
    sum4 = sum4 + 5 * i + 5;
  }
  cout << sum1 + sum2 - sum3 - sum4 << endl;
}

Measured memory_bytes: 3552
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int c = scan.nextInt();
		int [][]a = new int[r][c];
		for(int i = 0; i < r; i++) {
			for(int j = 0; j < c; j++) {
				a[i][j] = scan.nextInt();
			}
		}
		scan.close();
		int k = 0;
		for(int i = 0; i < r; i++) {
			int sum = 0;
			for(int j = 0; j < c; j++) {
				System.out.print(a[i][j] + " ");
				sum += a[i][j];
			}
			k += sum;
			System.out.println(sum);
		}
		for(int j = 0; j < c; j++) {
			int sum = 0;
			for(int i = 0; i < r; i++) {
				sum += a[i][j];
			}
			if(j == c - 1) {
				System.out.println(sum + " " + k);
			}else {
				System.out.print(sum + " ");
			}
		}
	}
}


Measured memory_bytes: 41580
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
#include <climits>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
 
  typedef long long ll;
  typedef long double lld;
  typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 1000000007;
  // lld PI = 3.141592653;
 
// const ll N = 2e5 + 5;
  

  

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

      ll ans = 0;
      int n;
      cin>>n;
      vector<int> a(n);
      for (int i = 0;i<n;i++) cin>>a[i];
      sort(a.begin(), a.end());
      
      for (int i = 0;i<n;i++){
        for (int j = i+1;j<n;j++){
          for (int k=j+1;k<n;k++){
            if (a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k] && a[i]+a[j]>a[k]) {ans++; }
          }
        }
      }
      cout<<ans<<"\n";



}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
long long int dp[101][100001];
long long int  knapSack(int wt[],int val[],int W,int n)
{
    if(n==0 || W == 0)return 0;
    if(dp[n][W]!=-1)return dp[n][W];

    if(wt[n-1]<=W)
    {
        dp[n][W] =  max(val[n-1]+knapSack(wt,val,W-wt[n-1],n-1),knapSack(wt,val,W,n-1));
        return dp[n][W];
    }
    else if(wt[n-1]>W) 
    {
        dp[n][W] = knapSack(wt,val,W,n-1);
        return dp[n][W];
    }

}
int main()
{
    //#ifndef ONLINE_JUDGE 
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    //#endif

    memset(dp,-1,sizeof(dp));

    int n,W;
    cin>>n>>W;

    int wt[n],val[n];

    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }

    cout<<knapSack(wt,val,W,n);
}


Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    vector<pair<int, int> > a(5);
    for(int i = 0; i < 5; ++i) {
        cin >> a[i].second;
        a[i].first = a[i].second%10;
        if(a[i].first == 0)
            a[i].first = 10;
    }
    sort(a.begin(), a.end(), greater<pair<int, int> >());
    int ret = 0;
    for(int i = 0; i < 4; ++i) {
        ret += a[i].second + (10 - a[i].first);
    }
    ret += a[4].second;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N int
	fmt.Scan(&N)

	A := 0
	B := 0
	BA := 0

	ans := 0
	for i := 0; i < N; i++ {
		var S string
		fmt.Scan(&S)
		ans += strings.Count(S, "AB")
		if S[0] == 'B' && S[len(S)-1] == 'A' {
			BA++
		} else if S[0] == 'B' {
			B++
		} else if S[len(S)-1] == 'A' {
			A++
		}
	}
	if BA > 1 {
		ans += BA-1
		BA = 1
	}

	if BA > 0 {
		if A > 0 {
			ans++
			A--
		}
		if B > 0 {
			ans++
			B--
		}
	}
	if A > B {
		ans += B
	} else {
		ans += A
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n, T;
    cin >> n >> T;
    vector<int> c(n), t(n);
    REP(i, n) cin >> c[i] >> t[i];

    int ans = INF;
    REP(i, n){
        if(t[i] <= T) ans = min(ans, c[i]);
    }
    cout << (ans != INF ? to_string(ans) : "TLE") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <fstream>
#include <numeric>
#include <algorithm>

using namespace std;

int main(int argc, char **argv) {
  int n, a[4], b[4];
  while (cin >> n) {
    if (n == 0)
      break;
    for (int k = 0; k < n; k++) {
      for (int i = 0; i < 4; i++)
        cin >> a[i];
      for (int i = 0; i < 4; i++)
        cin >> b[i];

      cout << a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3];
      cout << ' ';
      cout << a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2];
      cout << ' ';
      cout << a[0] * b[2] - a[1] * b[3] + a[2] * b[0] + a[3] * b[1];
      cout << ' ';
      cout << a[0] * b[3] + a[1] * b[2] - a[2] * b[1] + a[3] * b[0];
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    string s; cin >> s;
    int n = s.size();
    map<char,int> mp;

    rep(i,n) mp[s[i]]++;
    rep(i,n){
        if(mp[s[i]] % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n;
  scanf("%d", &n);
  
  int f = 0; int temp = n;
  for(int i = 0; i < 10; i++){
    f += temp % 10;
    temp /= 10;
  }
  if(n % f == 0) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
static const int MAX = 50*50;
int main(){
    int n, a, ans = 0,sum; sc(n), sc(a);
    vector<int> x(n);
    vector<vector<ll> > dp(n+1, vector<ll>(2*MAX+1,0));
    rep(i, 0, n) sc(x[i]), x[i] -= a;
    dp[0][MAX] = 1;
    rep(i, 1, n+1){
        rep(j, 0, 2*MAX+1){
            if (j-x[i-1]<0 || j-x[i-1]>2*MAX){
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]];
            }
        }
    }
    cout << dp[n][MAX] - 1 << endl;
    return 0;
}

Measured memory_bytes: 2304
n=int(input())
a=[0]
for _ in range(n):
    a.append(int(input()))
visited=set([1])
answer=0
x=1
while True:
    x=a[x]
    if x in visited:
        answer=-1
        break
    visited.add(x)
    answer+=1
    if x==2:
        break
print(answer)

Measured memory_bytes: 13216
//Atcoder
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        int[] h = new int[n];
        int[] max = new int[n];
        int best = 0;
        for(int i=0;i<n;i++) {
            h[i] = sc.nextInt();
            if(h[i] > best) best = h[i];
            max[i] = best;
        }

        //pw.println(Arrays.toString(h));
        //pw.println(Arrays.toString(max));

        int ans = 0;
        for(int i=n-1;i>0;i--) {
            if(h[i] >= max[i-1]) {
                ans++;
            }
        }

        pw.println(ans+1);
        pw.close();
    }
}


Measured memory_bytes: 21076
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, m, a, ans = 0, num = 0; cin >> n >> m;
	int test[101][101] = { 0 };
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= m; i++) {
			cin >> a;
			test[h][i] = a;
		}
	}
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= m; i++) {
			cout << test[h][i] << ' ';
			ans += test[h][i];
		}
		cout << ans << endl;
		ans = 0;
	}
	for (int h = 1; h <= m; h++) {
		for (int i = 1; i <= n; i++) {
			ans += test[i][h];
		}
		cout << ans << ' ';
		num += ans;
		ans = 0;
	}
	cout << num << endl;
	cin >> n;
}


Measured memory_bytes: 3152