akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
int main(){
	string s;
	cin>>s;
	string mm, dd;
	mm += s[5];
	mm += s[6];
	dd += s[8];
	dd += s[9];
	int month = toInt(mm);
	int day = toInt(dd);
	if(month <= 4 && day <= 30){
		cout<<"Heisei"<<endl;
	}
	else{
		cout<<"TBD"<<endl;
	}
	return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
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<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

//nの素因数分解する
map<int,int> mp;
void factorize(ll n){
    map<ll,ll> ret;
    ll x = n;
    for(ll i = 2; i*i<=n;i++){
        while(x % i == 0){
            mp[i]++;
            x /= i;
        }
    }
    if(x != 1)mp[x]++;
    return;
}
vl a;
ll dfs(int idx,int num){
    if(idx == a.size()){
        if(num == 1)return 1;
        else return 0;
    }
    ll res = 0;
    for(int i=1;i<=a[idx];i++){
        if(num % i == 0)res += dfs(idx+1,num/i);
    }
    return res;
}
signed main()
{   
    gearup;
    ll n; cin >> n;
    for(int i = 2;i<=n;i++)factorize(i);
    for(auto m:mp)a.push_back(m.second+1); 
    //debug(a);
    ll res = dfs(0,75);
    out(res);
}


Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    set<char> s;
    rep(i, S.size()) {
        s.insert(S[i]);
    }
    rep(i, 26) {
        if (s.find('a' + i) == s.end()) {
            print((char)('a'+i));
            return 0;
        }
    }
    print("None");
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast


        
    string str1,str2;    
    cin>>str1>>str2;
    int n = str1.sze;
    int m = str2.sze;
    v2i dp(n+1,vi(m+1,0));

    forn(i,1,n+1)
    {
        forn(j,1,m+1)
        {
            if(str1[i-1] == str2[j-1])
            {
                dp[i][j] = 1 + dp[i-1][j-1];
            }
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }

    int idx = dp[n][m];
    int i = n, j = m;
    string str = "";
    while(i > 0 && j > 0)
    {
        if(str1[i-1] == str2[j-1])
        {   
            str = str1[i-1] + str;
            i--,j--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }


    cout<<str;




    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    bool flag = false;
    REP(i, 3){
        if(n[i] == '7'){
            flag = true;
        } 
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

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

  long long n, t, T;
  cin >> n >> T;
  set<pair<long long, long long>> count;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    count.insert({t, 1});
    count.insert({t+T, -1});
  }
  long long res = 0, p, cnt = 0;
  for (auto &c : count) {
    if (c.second == 1) {
      if (cnt == 0) p = c.first;
    } else {
      if (cnt == 1) res += c.first-p;
    }
    cnt += c.second;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 25216
import sys
input = sys.stdin.readline
import math
def print_ans(N, D):
    """Test Case
    >>> print_ans(6, 2)
    2
    >>> print_ans(14, 3)
    2
    >>> print_ans(20, 4)
    3
    """
    print(math.ceil(N / (D * 2 + 1)))
    

if __name__ == '__main__':
    N, D = map(int,input().rstrip().split())
    print_ans(N, D)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
 int main(){
 char x[1000],y[1000];
 int n,i,j;
 scanf("%d",&n);
 for(i = 0;i < n;i++){
    scanf("%s %s",x, y);
   printf("%d\n",cal(x,y));
 }
 return 0;     
}
 
int cal(char x[], char y[]){
 
 int i,j;
 int m = strlen(x);
 int n = strlen(y);
 int cou[m+1][n+1];
 
 for(i = 0;i <= m; i++){
  cou[i][0] = 0;
  }
 for(j = 0;j <= n; j++){
  cou[0][j] = 0;
  }
 for(i = 1;i <= m; i++){
  for(j = 1;j <= n; j++){
    if(x[i-1] == y[j-1])
     cou[i][j] = cou[i-1][j-1] + 1;
    else if(cou[i-1][j] >= cou[i][j-1]){
     cou[i][j] = cou[i-1][j];
  }
    else
     cou[i][j] = cou[i][j-1];
  }
 }
 return cou[m][n];
}

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll n;
vl a, dif;
ll tot = 0;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n; a.resize(n);
    F0R(i,n) {
        cin >> a[i];
        tot += a[i];
    }
    F0R(i,n) dif.pb(a[i]-a[(i+1)%n]);
    ll mindif = 2*MOD;
    F0R(i,n) mindif = min(mindif,dif[i]);
    
    FOR(i,1,n) if ((dif[i]-dif[0]) % n != 0) {
        cout << "NO";
        exit(0);
    }
    F0R(i,n) {
        // cout << dif[i]-mindif << "\n";
        tot -= (dif[i]-mindif)*(n+1)/2;
    }
    // cout << tot << "\n";
    if (tot >= 0 && tot % (n*n*(n+1)/2) == 0) {
        cout << "YES";
    } else cout << "NO";
    // +n to biggest difs
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 2168
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 300010
#define mdn 1000000007
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
char ch[N]; int lst[3],n,l[N],r[N],pre[N],f[N],s[N];
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
int query(int l,int r){return l>=0?(pre[r]-pre[l]+mdn)%mdn:pre[r];}
int main()
{
	scanf("%s",ch+1); n=strlen(ch+1); int flag=0;
	for(int i=1;i<n;i++)	flag|=(ch[i]==ch[i+1]);
	if(!flag)	return puts("1"),0;
	for(int i=1;i<=n;i++)	s[i]=s[i-1]+ch[i]-'a'+1;
	lst[1]=lst[2]=-1; int pt=-1;
	for(int i=1;i<=n;i++)
	{
		if(ch[i]==ch[i-1])	pt=i-2;
		r[i]=pt; l[i]=lst[s[i]%3]; lst[s[i]%3]=i;
	}
	f[0]=pre[0]=1;
	for(int i=1;i<=n;i++)
	{
		f[i]=f[i-1];
		if(l[i]<r[i]&&~r[i])	upd(f[i],query(l[i],r[i]));
		pre[i]=(pre[i-1]+f[i])%mdn;
	}
	int ans=0;
	for(int i=1;i<=n;i++)	if((s[n]-s[i])%3==0)	upd(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}


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

int main() {
    long long x, y;
    
    while (true) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        cout << min(x, y) <<" " << max(x, y) << endl;
    }
}


Measured memory_bytes: 3092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	sc.Scan()
	s := sc.Text()
	return strconv.Atoi(s)
}

func main() {
	sc.Split(bufio.ScanWords)

	a, _ := nextInt()
	b, _ := nextInt()
	c, _ := nextInt()

	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



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

int main() {
    int A, B;
    cin >> A >> B;
    if ((A + 12) % 14 > (B + 12) % 14) cout << "Alice" << endl;
    else if ((A + 12) % 14 < (B + 12) % 14) cout << "Bob" << endl;
    else cout << "Draw" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(a);
    int max = a[a.length - 1];
    boolean dp[] = new boolean[max + 1];
    for (int i = 0; i < n; i++) {
      dp[a[i]] = true;
    }
    for (int i = 0; i < n; i++) {
      int ai = a[i];
      if (i > 0 && a[i - 1] == a[i]) {
        dp[a[i]] = false;
      }
      for (int c = ai * 2; c <= max; c += ai) {
        dp[c] = false;
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (dp[a[i]]) {
        ans++;
      }
    }
    pw.println(
      ans
    );
  }
}


Measured memory_bytes: 60488
/**
 * @author yuichirw
 *
 */
import java.util.*;
import static java.util.Arrays.*;

public class Main {
	static int n;
	static int[] edges = new int[3];
	static Scanner sc = new Scanner(System.in);
	
	static void read() {
		for(int i = 0; i < 3; i++) {
			edges[i] = sc.nextInt();
		}
	}
	
	static String solve() {
		sort(edges);
		int a,b,c;
		a = edges[0]; b = edges[1]; c = edges[2];
		if((a * a + b * b) == (c * c)) {
			return "YES";
		} else {
			return "NO";
		}
	}
	
	public static void main(String[] args) {
		n = sc.nextInt();
		while(n-- > 0) {
			read();
			System.out.println(solve());
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,W;
    cin>>n>>W;
    int w[n],v[n];
    for(int i=1;i<=n;i++)
    cin>>w[i]>>v[i];
    long long int dp[n+1][W+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=W;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j>=w[i])
            dp[i][j]=max( dp[i][j] , dp[i-1][j-w[i]] + v[i]);
        }
    }
    cout<<dp[n][W]<<endl;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

const ll MAX_N = 2 * 1e5;
ll n;
ll a[MAX_N];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;
	rep(i, 0, n) cin >> a[i];

	ll s[n];
	memset(s, 0, sizeof(s));
	if(n % 2 != 0) {
		ll mid = n / 2;
		s[mid] = a[0];
		rep(i, 1, mid + 1) {
			s[mid + i] = a[2 * i - 1];
			s[mid - i] = a[2 * i];
		}

	} else {
		ll mid = n / 2;
		s[mid] = a[0];
		rep(i, 1, mid) {
			s[mid - i] = a[2 * i - 1];
			s[mid + i] = a[2 * i];
		}
		s[0] = a[n - 1];
	}

	rep(i, 0, n - 1) cout << s[i] << " ";
	cout << s[n - 1] << endl;

}


Measured memory_bytes: 5376
#include<stdio.h>
int main(){
	int p,q,r;
	scanf("%d%d%d",&p,&q,&r);
	int min = p+q;
	if(min>q+r&&p>q)
		min=q+r;
	if(min>r+p&&q>=p)
		min=r+p;
	
	printf("%d\n",min);
	
	return 0;
	
}
	


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define fo(i,a) for(ll i=0;i<a;i++)
#define Fo(i,a,n) for(ll i=a; i<n; i++)
#define u_m unordered_map
#define u_s unordered_set
#define ff first
#define ss second
#define mp make_pair
using namespace std;
ll __pow(ll x, ll y) {ll res = 1;while(y>0){if(y&1) res*=x; y>>=1; x*=x;}return res;}
ll gcd(ll a , ll b){if(b==0) return a;a%=b;return gcd(b,a);}
bool isprime(ll n){for(ll i=2; i*i<=n; i++){if(n%i==0) return 0;}return 1;}
ll n,m,x,y,z,k;
ll dp(ll n){
    if(n<10) return max((ll)1, n);
    else return max((n%10)*dp(n/10), 9*dp(n/10-1));
}
void solve(){
   cin>>n;
   cout<<n+n*n+n*n*n<<endl;
}
int main(){
    ll t=1;
    //cin >> t;
    for(ll i=1; i<=t; i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3592
#include <queue>
#include <iostream>
using namespace std;
int main() {
    int h, w, k; cin >> h >> w >> k;
    string s[h]; for (int i = 0; i < h; i++) cin >> s[i];
    int sx, sy;
    for (int x = 0, done = 0; x < h && !done; x++)
        for (int y = 0; y < w && !done; y++)
            if (s[x][y] == 'S') { sx = x; sy = y; done = 1; }
    priority_queue<pair<int, pair<int, int> > > pq;
    pq.push({0, {sx, sy}});
    int dist[h][w];
    for (int i = 0; i < h; i++) fill(dist[i], dist[i]+w, 1<<30);
    dist[sx][sy] = 0;
    int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
    for (;;) {
        int d = -pq.top().first,
            x = pq.top().second.first, y = pq.top().second.second;
        pq.pop();
        if (d > dist[x][y]) continue;
        if (x == 0 || x == h-1 || y == 0 || y == w-1) {
            cout << (d + k - 1) / k << endl;
            return 0;
        }
        for (int i = 0; i < 4; i++) {
            int x1 = x + dx[i], y1 = y + dy[i];
            int d1 = (s[x1][y1] == '#' && d < k ? k+1 : d+1);
            if (dist[x1][y1] <= d1) continue;
            dist[x1][y1] = d1;
            pq.push({-d1, {x1, y1}});
        }
    }
}


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

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

Measured memory_bytes: 3624
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a_list=list(map(int,input().split()))
S=sum(a_list)
import sys
i=1
while i**2<=S:
    if S%i==0:
        x=S//i
        temp=[]
        s=0
        for j in range(n):
            if (a_list[j]%x)!=0:
                s+=x-a_list[j]%x
                temp.append(a_list[j]%x)
        temp.sort()
        num=sum(temp[:s//x])
        if num<=k:
            print(x)
            sys.exit()
        temp=[]
        s=0
        for j in range(n):
            if (a_list[j]%i)!=0:
                s+=i-a_list[j]%i
                temp.append(a_list[j]%i)
        temp.sort()
        num=sum(temp[:s//i])
        if num<=k:
            ans=i
    i+=1
print(ans)


Measured memory_bytes: 42460
local n, t = io.read("*n", "*n", "*l")
local str = io.read()
local a = {}
for numstr in string.gmatch(str, "%d+") do
  table.insert(a, tonumber(numstr))
end
local totlen = a[#a] + t
for i = 2, n do
  totlen = totlen - math.max(0, a[i] - a[i - 1] - t)
end
print(totlen)


Measured memory_bytes: 11980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		long[] sum = new long[n + 1];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum[a[i]]++;
		}
		long ans = 0;
		for(int i = 1; i < n + 1; i++) {
			if(sum[i] >= 2) {
				ans += sum[i] * (sum[i] - 1) / 2;
			}
		}
		for(int i = 0; i < n; i++) {
			long tmp = ans;
			if(sum[a[i]] >= 2) {
				tmp -= sum[a[i]] * (sum[a[i]] - 1) / 2;
			}
			if(sum[a[i]] - 1 >= 2) {
				tmp += (sum[a[i]] - 1) * (sum[a[i]] - 2) / 2;
			}
			System.out.println(tmp);
		}
	}

}


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

using namespace std;

int a[100005];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int mx = 0, gc = 0;
    for (int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
        mx = max(mx, a[i]);
        gc = __gcd(gc, a[i]);
    }
    if (mx < k || k % gc)
        puts("IMPOSSIBLE");
    else
        puts("POSSIBLE");
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int l, r, d;
	cin >> l >> r >> d;
	cout << r / d - (l - 1) / d;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1LL<<61);

int n, u, v;
vl depth_u, depth_v;
vvl edges;
vector<bool> reachable;

void calcDepth(int x, int d, vl &depth) {
  if (depth[x] != INF) return;
  depth[x] = d;
  for (auto it : edges[x]) {
    calcDepth(it, d+1, depth);
  }
}

int main() {
  cin >> n >> u >> v;
  u--; v--;
  edges.resize(n);
  depth_u.assign(n,INF);
  depth_v.assign(n,INF);
  reachable.assign(n,false);
  rep(i,n-1) {
    int a, b; cin >> a >> b;
    a--; b--;
    edges[a].pb(b);
    edges[b].pb(a);
  }
  calcDepth(u, 0, depth_u);
  calcDepth(v, 0, depth_v);
  rep(i,n) {
    if (depth_u[i] <= depth_v[i]) {
      reachable[i] = true;
    }
  }
  // outa(reachable, n);
  ll ans = 0;
  rep(i,n) {
    if (edges[i].size() == 1 && reachable[i]) {
      int node = edges[i][0];
      if (reachable[node]) {
        ans = max(ans, depth_v[node]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int N = 1e+5 + 5;
long long int p[N], q[N], r[N];
int x, y, a, b, c;
vector<pair<long long int, int>> v;
bool comp(pair<long long int, int> p1, pair<long long int, int> p2)
{
    if (p1.first == p2.first)
        return p1.second < p2.second;
    return p1.first > p2.first;
}
int main()
{
    cin >> x >> y >> a >> b >> c;
    for (int i = 1; i <= a; i++)
    {
        cin >> p[i];
        v.push_back(make_pair(p[i], 1));
    }
    for (int i = 1; i <= b; i++)
    {
        cin >> q[i];
        v.push_back(make_pair(q[i], 2));
    }
    for (int i = 1; i <= c; i++)
    {
        cin >> r[i];
        v.push_back(make_pair(r[i], 3));
    }
    sort(p + 1, p + a + 1, greater<long long int>());
    sort(q + 1, q + b + 1, greater<long long int>());
    sort(r + 1, r + c + 1, greater<long long int>());
    vector<long long int> st;
    for (int i = 1; i <= x; i++)
        st.push_back(p[i]);
    for (int i = 1; i <= y; i++)
        st.push_back(q[i]);
    for (int i = 1; i <= c; i++)
        st.push_back(r[i]);
    int i = 0;
    sort(st.begin(), st.end(), greater<long long int>());
    long long int ans = 0;
    for (auto it : st)
    {
        // cout << it;
        ans += it;
        i++;
        if (i == x + y)
            break;
    }
    cout << ans;
}

Measured memory_bytes: 15848
#include <iostream>
#include <cstring>

using namespace std;

int main(){
	int N;
	bool prime[300000];
	prime[0] = prime[1] = false;
	for(int i=2;i<300000;i++) prime[i] = true;
	for(int i=2;i<300000;i++){
		if(!prime[i]) continue;
		for(int j=2*i;j<300000;j+=i) prime[j] = false;
	}
	while(cin >> N, N){
		int res = 0;
		for(int i=N+1;i<=2*N;i++) res += prime[i];
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int N, K;
	cin >> N >> K;
	
	ll ans = 0;
	FOR(i, K + 1, N + 1) {
		ans += (N / i) * (i - K) + max(N % i - K + 1, 0);
		if (K == 0) ans--;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){

int H, W;
cin >> H >> W;
vector<string>S(H);
for(int i = 0; i < H; i++){ 
     cin >> S.at(i);
}

int left[H][W];
for(int i = 0; i < H; i++){ 
     int cnt = 0;
     for(int j = 0; j < W; j++){ 
          if(S[i][j] == '#') cnt = 0;
          else cnt++;
          left[i][j] = cnt;
     }
}

int right[H][W];
for(int i = 0; i < H; i++){ 
     int cnt = 0;
     for(int j = W - 1; j >= 0; j--){ 
          if(S[i][j] == '#') cnt = 0;
          else cnt++;
          right[i][j] = cnt;
     }
}

int up[H][W];
for(int i = 0; i < W; i++){ 
     int cnt = 0;
     for(int j = 0; j < H; j++){ 
          if(S[j][i] == '#') cnt = 0;
          else cnt++;
          up[j][i] = cnt;
     }
}

int down[H][W];
for(int i = 0; i < W; i++){ 
     int cnt = 0;
     for(int j = H - 1; j >= 0; j--){ 
          if(S[j][i] == '#') cnt = 0;
          else cnt++;
          down[j][i] = cnt;
     }
}

int ans = 0;

for(int i = 0; i < H; i++){ 
     for(int j = 0; j < W; j++){ 
          if(S[i][j] == '#') continue;
          ans = max(ans, left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3);

     }
}

cout << ans << endl; 


}



Measured memory_bytes: 66816
#include<iostream> 
#include<vector>  
#include<string>
using namespace std;
int main()
{
	int a; 
	cin >> a;    
	int p = a / 100;  
	int ans = p * 111;
	
	 if (p*111<a)
	
	{
		 ans = (p + 1) * 111;
	} 
	 cout << ans << "\n";
	

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
typedef long long ll;
const int maxn = 1e7+5;
int c[10],cnt[10];
int main(){
	memset(c,-1,sizeof(c));
	int n,m;
	cin>>n>>m;
	int x,y;
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		cnt[x]++;
		if(x<1||x>n||y<0||y>9){
			cout<<-1<<endl;
			return 0;
		}
		if(cnt[x]>1){
			if(c[x]!=y){
				cout<<-1;
				return 0;	
			}
		}
		c[x]=y;
	}
	//for(int i=1;i<=n;i++) cout<<c[i]<<endl;
	if(n>3||n<1||m<0||m>5){
		cout<<-1<<endl;
		return 0;
	}
	if(n==1){
		if(c[1]>-1) cout<<c[1]<<endl;
		else cout<<0<<endl;
	}
	if(n>1){
		for(int i=1;i<=n;i++){
			if(i==1){
				if(c[i]>=1) cout<<c[i];
				else if(c[i]==0){
					cout<<-1;
					return 0;
				}
				else cout<<1;
			}
			else{
				if(c[i]>=0) cout<<c[i];
				else cout<<0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
void dfs(int n,int m);
char fg[111][111],fu;
int h,w;
int a[4]={-1,0,0,1};
int b[4]={0,-1,1,0};
int main(){
  while(1){
    cin >> h >> w;
    if(h==0 && w==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> fg[i][j];
      }
    }
    int cou=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(fg[i][j]!='.'){
	  fu = fg[i][j];
	  dfs(i,j);
	  cou++;
	}
      }
    }
    cout << cou << endl;
  }
}

void dfs(int n,int m){
  fg[n][m] = '.';
  for(int vh=0;vh<4;vh++){
    int nh=n+a[vh];
    int nw=m+b[vh];
    if(nh>=0 && nh<h && nw>=0 && nw<w && fg[nh][nw]==fu){
      dfs(nh,nw);
    }
  }
}

Measured memory_bytes: 1480
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n;
double a[3010],dp[3010][3010],ans=0;

int main()
{
  cin>>n;
  rep(i,n) cin>>a[i];
  dp[0][0]=1;
  rep(i,n)
  {
    rep(j,i+1)
    {
      if(dp[i][j]==0) continue;
      dp[i+1][j+1]+=dp[i][j]*a[i];
      dp[i+1][j]+=dp[i][j]*(1.0-a[i]);
    }
  }
  rep(j,n+1) if(j>n-j) ans+=dp[n][j];
  printf("%.10lf\n",ans);
  return 0;
}

Measured memory_bytes: 68992
#include <stdio.h>
#include <iostream>
using namespace std;

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

	int a = s.length();
	int b = (a - 1) / 2;
	int c = b + 1;

	string first_letter = s.substr(0, b);
	string last_letter = s.substr(c, b);

	if (first_letter == last_letter) {
		cout << "Yes" << endl;
		return 0;
	} else {
		cout << "No" << endl;
		return 0;
	}

}

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

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

    ll a,b;
    ll ans=0;
    bool flg=false;
    rep(i,n){
        cin>>a>>b;
        if(a==b)ans++;
        else ans=0;

        if(ans==3)flg=true;
    }

    if(flg==true)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 3628
using System;
using System.Linq;
namespace Myatcoder
{
    public class Program
    {
        public static void Main()
        {
            int[] A = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int maxValue = 0;
            if (A[0] != 1) {
                for (int i = 1; i <= A[1]; i++)
                {
                    if (A[0] * i > A[1]) break;
                    if (A[1] % i == 0) maxValue = i;
                }
                Console.WriteLine(maxValue);
            } else {
                Console.WriteLine(A[1]);
            }
        }
    }
}

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

int H,W;

int main(){
    
    while(1){
        cin>>H>>W;
        if(H==0 && W==0)break;
        for(int i=0;i<H;++i){
            for(int j=0;j<W;++j){
                if(i==0 || i==H-1 || j==0 || j==W-1){
                    cout<<"#";
                }
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3004
a, b = map(int, input().split())
s = list(str(input()))

flag = False
if(s[a] == '-'):
    flag = True

for i in range(a + b + 1):
    if(i != a and flag):
        if(not s[i].isdecimal()):
            flag = False

if(flag):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <chrono>
#include <cstring>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
inline bool chmax(T &a, T b) { return a < b && (a = b, true); }

int dp[5010][5010];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	auto start = chrono::system_clock::now();
	auto split = chrono::system_clock::now();

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int cut) {
		int res = 0;
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < cut; i++) {
			for (int j = cut; j < N; j++) {
				if (s[i] == s[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
				chmax(res, dp[i + 1][j + 1]);
			}
		}
		return res;
	};

	// 3分探索
	int lb = 0, ub = N, ans = 0;
	while (chrono::duration_cast<chrono::milliseconds>(split - start).count() < 1200) {

		int t1 = (2.5 * lb + ub) / 3.5;
		int t2 = (lb + 2.5 * ub) / 3.5;

		int c1 = check(t1);
		int c2 = check(t2);
		if (c1 < c2) lb = t1;
		else ub = t2;

		chmax(ans, max(c1, c2));
		split = chrono::system_clock::now();
	}

	DMP(ub, lb);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 98432
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
#define d_arr(arr, h, w) rep(i,(h) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define pr(x) printf("%d\n",x);

typedef pair<int ,int> P;

int grid[40][40] = {0};
vector< pair<int, int> > v;

int main()
{
    int a,b,n;
    while( cin >> a >> b )
    {
        if( a==0 && b==0 ) { break; }
        v.clear();
        rep(i,40) { rep(j,40) { grid[i][j] = 0; }}
        cin >> n;
        rep(i,n) 
        {
            int x[2];
            cin >> x[0] >> x[1];
            v.push_back( make_pair(x[0]-1, x[1]-1) );
        }

        grid[0][0] = 1;
        rep(i, a)
        {
            rep(j,b)
            {
                int w=0,s=0;
                if( 0<i && i<a && find(v.begin(), v.end(), make_pair(i-1,j)  ) == v.end() ) { 
                    w = grid[i-1][j];
                }

                if( 0<j && j<b && find(v.begin(), v.end(), make_pair(i,j-1)  ) == v.end()) { 
                    s = grid[i][j-1];
                }

                grid[i][j] += w; 
                grid[i][j] += s; 
            }
        }
        //d_arr(grid,a,b);
        cout << grid[a-1][b-1] << endl;
        //rep(i, a)
        //{
        //    rep(j,b){
        //    
        //        cout << grid[i][j] << "," ;
        //    }
        //    cout << endl;
        //}
        //cout <<endl;
    }
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int ans = 0;
        for (int a = 0 ; a <= A ; a++) {
            for (int b = 0 ; b <= B ; b++) {
                for (int c = 0 ; c <= C ; c++) {
                    if (500 * a + 100 * b + 50 * c == X) {
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }

}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	char C;
	cin >> C;
	string dic = "aeiou";
	string ans = "consonant";
	for (char c : dic) {
		if (c == C) {
			ans = "vowel";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (m, k) = readLine()!!.split(' ').map(String::toLong)
    val maxNum = Math.pow(2.0, m.toDouble()).toLong() - 1

    if(m == 1L){
        if(k>=1){
            println(-1)
        }else{
            println("0 0 1 1")
        }
        return
    }

    if (maxNum < k) {
        println(-1)
        return
    }

    for (i in 0..maxNum) {
        print((i + k + 1) % (maxNum + 1))
        print(" ")
    }
    for (i in 0 until maxNum) {
        print((k - i + maxNum) % (maxNum + 1))
        print(" ")
    }
    println(k)
}


Measured memory_bytes: 44856
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)

// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;

template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int N; cin >> N;
    bool flag=0;
    for(int i=0; i<=25; ++i){
        for(int j=0; j<=12; ++j){
            if(4*i+7*j==N) flag=1;
        }
    }
    if(flag) pr("Yes");
    else pr("No");
 
}



Measured memory_bytes: 256
from itertools import cycle

while True:
    n, p = map(int, input().split())
    s = [0] * n

    if n == p == 0:
        break

    for i in cycle(range(n)):
        if p:
            p -= 1
            s[i] += 1
            if not p and sum(s) == s[i]:
                break
        else:
            p = s[i]
            s[i] = 0

    print(i)
 


Measured memory_bytes: 5640
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <iomanip>
#include <math.h>
#include <mutex>
#include <algorithm>

//#include "test.h"

//#include "SandBox/StopRangeAccess/StopRangeAccess.h"

//#include "Data.h"


using namespace std;

typedef unsigned long ulong;
typedef unsigned long long ulolong;
typedef long long lolong;


int main()
{

	int n;
	cin >> n;

	std::map<int, int> map;

	for (int i = 2; i <= n; i++)
	{
		int a;
		cin >> a;
		++map[a];
	}

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

Measured memory_bytes: 13008
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String num = br.readLine();

        int x = Integer.parseInt(num);
        int ans = (int) Math.pow(x, 3);

        System.out.println(ans);

	}
}

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

using namespace std;


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

int len=str.length();
int cntA=0;
int cntB=0;
for(int i=0;i<len;i++){
   if(str[i]=='A') cntA++;
   if(str[i]=='B') cntB++;
}

if(cntA>0&&cntB>0) cout<<"Yes"<<endl;

else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ar = []
for i in range(n):
    ar.append(list(input()))

dx = [1, -1, 0, 0]
dy = [0, 0, -1, 1]
res  = 0


for i in range(n):
    for j in range(m):
        if ar[i][j] == '.':
            vis = [[-1] * m for k in range(n)]
            queue = [i, j]
            vis[i][j] = 0
            while len(queue):
                x = queue.pop(0)
                y = queue.pop(0)
                for k in range(4):
                    x1 = x + dx[k]
                    y1 = y + dy[k]
                    if 0 <= x1 < n and 0 <= y1 < m and ar[x1][y1] == '.' and vis[x1][y1] == -1:
                        vis[x1][y1] = vis[x][y] + 1
                        res = max(res, vis[x1][y1])
                        queue.append(x1)
                        queue.append(y1)

print(res)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int n,b[10],a[3][3];
bool ake[3][3];
int main(){
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)cin>>a[i][j];
  cin>>n;
  for(int i=0;i<n;i++)cin>>b[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      ake[i][j]=false;
      for(int k=0;k<n;k++)
        if(b[k]==a[i][j])
          ake[i][j]=true;
    }
  }
  string unko="No";
  for(int i=0;i<3;i++)
    if(ake[i][0] and ake[i][1] and ake[i][2])
      unko="Yes";
  for(int i=0;i<3;i++)
    if(ake[0][i] and ake[1][i] and ake[2][i])
      unko="Yes";
  if(ake[0][0] and ake[1][1] and ake[2][2])
    unko="Yes";
  if(ake[0][2] and ake[1][1] and ake[2][0])
    unko="Yes";
  cout<<unko<<endl;
  return 0;
}


Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    h,w = map(int,ipt().split())
    ch,cw = map(int,ipt().split())
    dh,dw = map(int,ipt().split())
    board = [input()+"##" for i in range(h)]
    board.append("#"*(w+2))
    board.append("#"*(w+2))
    t = [[10**18]*w for i in range(h)]
    q = [(ch-1,cw-1)]
    nt = 0
    t[ch-1][cw-1] = 0

    while q:
        wall = set()
        while q:
            qx,qy = q.pop()
            for dx,dy in dir:
                nx = qx+dx
                ny = qy+dy
                if board[nx][ny] == ".":
                    if t[nx][ny] == 10**18:
                        t[nx][ny] = nt
                        q.append((nx,ny))
                else:
                    wall.add((qx,qy))
        nt += 1
        for wx,wy in wall:
            for xs in range(-2,3):
                nx = wx+xs
                for ys in range(-2,3):
                    ny = wy+ys
                    if board[nx][ny] == "." and t[nx][ny] == 10**18:
                        q.append((nx,ny))
                        t[nx][ny] = nt

    if t[dh-1][dw-1] == 10**18:
        print(-1)
    else:
        print(t[dh-1][dw-1])


    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 98576
#include <stdio.h>
#define exchange(a,b) {typeof(a) __tmp=a;a=b;b=__tmp;}


char A[100001];
int B[100001];


int Partition(int A[], int p, int r) {
  int i,j;
  int x;
  x = A[r];
  i = p-1;
  for(j = p; j < r; ++j) {
    if(B[A[j]] <= B[x]) { // if(A[j] <= x) {
      i = i+1;
      exchange(A[i], A[j]);
    }
  }
  exchange(A[i+1], A[r]);
  return i+1;
}

void Quicksort(int A[], int p, int r) {
  int q;
  if(p < r) {
    q = Partition(A,p,r);
    Quicksort(A,p,q-1);
    Quicksort(A,q+1,r);
  }
}

int isStable(int A[], int n) {
  int i;
  for(i = 2; i <= n; ++i) {
    if(B[A[i-1]] == B[A[i]] && A[i-1] > A[i]) return 0;
  }
  return 1;
}

int main() {
  int i;
  int n;
  int C[100001];
  scanf("%d", &n);
  for(i = 1; i <= n; ++i) {
    scanf(" %c %d", A+i,B+i);
    C[i] = i;
  }
  Quicksort(C,1,n);
  if(isStable(C,n)) printf("Stable\n");
  else printf("Not stable\n");
  for(i = 1; i <= n; ++i) {
    printf("%c %d\n", A[C[i]], B[C[i]]);
  }
  return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N,A;cin>>N>>A;
    cout<<N*N-A<<endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string s;
   int n;
   cin >> n;
   cin >> s;
   int count = 0;
   for(int i = 0;i < s.size()-2;i++) {
       if(s[i]=='A') {
           if(s[i+1] == 'B') {
               if(s[i+2] == 'C') {
                   count++;
               }
           }
       }
   }
   cout << count << endl;
}

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

namespace _20170409_AOJ
{
    class ALDS1_2D
    {
        static long cnt;
        static void Main(string[] args)
        {
            for(;;)
            {
                string line = Console.ReadLine();
                if(string.IsNullOrEmpty(line))
                {
                    break;
                }

                cnt = 0;
                int n = int.Parse(line);
                int[] A = new int[n];
                for(int i=0;i<n;i++)
                {
                    A[i] = int.Parse(Console.ReadLine());
                }

                ShellSort(A, n);
                Console.WriteLine(cnt);
                foreach(var v in A)
                {
                    Console.WriteLine(v);
                }
            }
        }

        static void InsertionSort(int[] A, int n, int g)
        {
            for (int i = g; i < n; i++)
            {
                int v = A[i];
                int j = i - g;
                while (j >= 0 && A[j] > v)
                {
                    A[j + g] = A[j];
                    j = j - g;
                    cnt++;
                }

                A[j + g] = v;
            }
        }

        static void ShellSort(int[] A, int n)
        {
            cnt = 0;
            List<int> list = new List<int>();
            int t1 = 0;
            long t2 = (long)Math.Pow(3, t1);
            while(t2<=n)
            {
                list.Add((int)t2);
                t1++;
                t2 = list.Last() + (long)Math.Pow(3, t1);
            }
            int m = list.Count;
            Console.WriteLine(m);
            list.Reverse();
            int[] G = list.ToArray();
            WriteArray(" ", G);

            for (int i=0; i<m;i++)
            {
                InsertionSort(A, n, G[i]);
            }
        }

        static void WriteArray<T>(string separator, T[] arr)
        {
            int n = arr.Length;
            for(int i=0;i<n-1;i++)
            {
                Console.Write(arr[i]);
                Console.Write(separator);
            }
            Console.WriteLine(arr[n - 1]);
        }
    }
}



Measured memory_bytes: 17140
#include <iostream>
#include <cstdint>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

const int MAX = 3000;
double dp[MAX][MAX] = {0};
double p[MAX] = {0};

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

    for (int i = 0; i < n; i++)
        cin >> p[i];
    

    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (j == 0)
                dp[i][j] = (1.0 - p[i - 1]) * dp[i - 1][j];
            else 
                dp[i][j] = p[i - 1] * dp[i - 1][j - 1] + (1.0 - p[i - 1]) * dp[i - 1][j];
        }
    }

    double res = 0.0;

    for (int i = n/2 + 1; i < n + 1; i++) 
        res += dp[n][i];
    
    printf("%.10lf\n", res);

    return 0;
}



Measured memory_bytes: 70528