akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;
ll gcd(ll a,ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main(){
  int N,K,A[100000];
  cin>>N>>K;
  for (int i(0);i<N;i++) cin>>A[i];
  sort(A,A+N);
  if (A[N-1]<K) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  ll maxi=gcd(A[0],A[1]); 
  for (int i(2);i<N;i++){
    maxi=gcd(maxi,A[i]);    
  }
  if (K%maxi==0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}



Measured memory_bytes: 640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL f(LL n) {
	if (n % 4 == 0) return n;
	if (n % 4 == 1) return 1;
	if (n % 4 == 2) return n + 1;
	if (n % 4 == 3) return 0;
}


int main() {

	LL a, b; cin >> a >> b;

	LL ans = f(a - 1) ^ f(b);

	cout <<ans<< endl;

	return 0;
}

Measured memory_bytes: 256
#import"bits/stdc++.h"
main(){long long n,a,b,c,d,m;std::cin>>n>>a>>b;for(n;n>1;n--){std::cin>>c>>d;m=std::max((a-1)/c+1,(b-1)/d+1);a=c*m;b=d*m;}std::cout<<a+b;}

Measured memory_bytes: 256
#include <iostream>
#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 <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/dp/tasks/dp_k

int dp[100007];

int main() {
  int N, K; cin >> N >> K;
  int a[N]; REP(i, N) cin >> a[i];

  for (int i = 1; i <= K; i++) {
    for (int j = 0; j < N; j++) {
      if (a[j] <= i) {
        if (dp[i-a[j]] == 0) {
          dp[i] = 1;
        }
      }
    }
  }

  cout << (dp[K]?"First":"Second") << "\n";

  return 0;
}


Measured memory_bytes: 3460
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
vector<long long int> p;
int main() {
	int N,t = 0;
	cin >> N;
	p.resize(N);
	rep(i, N) cin >> p[i];
	if (N == 1)cout << "Yes" << "\n";
	else {
		for (int i = N-1; i >0; i--) {
			if (p[i-1] - p[i] > 1) {
				cout << "No" << "\n";
				return 0;
			}
			else if (p[i - 1] - p[i] == 1) {
				--p[i - 1];
			}
		}
		cout << "Yes" << "\n";
	}
	return 0;
}

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

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

    vector<string> S(N);
    int i;
    int ac=0;
    int wa=0;
    int tle=0;
    int re = 0;
    for(i=0;i<N;i++){
        cin >> S.at(i);
    }

    for(i=0;i<N;i++){
        if(S.at(i)=="AC")
            ac++;
        else if(S.at(i)=="WA")
            wa++;
        else if(S.at(i)=="TLE")
            tle++;
        else
            re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

}

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

int main(){
  int x;
  bool ret = false;
  cin >> x;
  if(x % 10 == 7) ret = true;
  x = x / 10;
  if(x % 10 == 7) ret = true;
  x = x / 10;
  if(x % 10 == 7) ret = true;
  if(ret) cout << "Yes";
  else cout << "No";
  cout << endl;
}


Measured memory_bytes: 3132
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
x,y=0,0
def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2
b=groupby(a)
l=len(b)
for i in range(l):
    if x==0:
        if b[i][1]>=4:
            x,y=b[i][0],b[i][0]
        elif b[i][1]>=2:
            x=b[i][0]
    elif y==0:
        if b[i][1]>=2:
            y=b[i][0]
    else:
        break
print(x*y)


Measured memory_bytes: 17680
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MAX_T = 51;
const int MAX_P = 11;
typedef pair<int,int> PP;
typedef pair<PP,int> P;

int main(){
  int m,t,p,r,team[MAX_T][MAX_P],judge[MAX_T][MAX_P];
  int mi,ti,pi,ji,accnt[MAX_T];

  while(cin >> m >> t >> p >> r , m + t + p + r){
    vector<P> v;
    fill(team[0],team[MAX_T],0);
    fill(judge[0],judge[MAX_T],0);
    fill(accnt,accnt+MAX_T,0);

    for(int i = 0 ; i < r ; i++){
      cin >> mi >> ti >> pi >> ji;
      if(ji == 0){
	team[ti][pi] += mi + judge[ti][pi];
	accnt[ti]--;
      }
      else{
	judge[ti][pi] += 20;
      }
    }
    int tt[MAX_T] = {0};
    for(int i = 1 ; i < MAX_T ; i++){
      for(int j = 1 ; j < MAX_P ; j++){
	tt[i] += team[i][j];
      } 
    }
    for(int i = 1 ; i <= t ; i++){
	v.push_back(P(PP(accnt[i],tt[i]),-i));
    }
    sort(v.begin(),v.end());
    for(int i = 1 ; i <= v.size() ; i++){
      if(v[i-1].first.first < v[i].first.first){
	cout << -v[i-1].second;
	if(i != v.size()) cout << ',';
      }
      else{
	if(v[i-1].first.second < v[i].first.second){
	  cout << -v[i-1].second;
	  if(i != v.size()) cout << ',';
	}
	else{
	  cout << -v[i-1].second;
	  if(i != v.size()) cout << '=';
	}
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll h,w;
    cin >>  h >> w;
    string s[h];
    for (ll i=0;i<h;i++)cin >> s[i];
    ll tate[h][w],yoko[h][w];
    memset(tate,0,sizeof(tate));
    memset(yoko,0,sizeof(yoko));
    for (ll i=0;i<h;i++){
        ll c=0;
        for (ll j=0;j<w;j++){
            if (s[i][j]=='#'){
                yoko[i][j]=0;
                if (c!=0){
                    ll x=j-1;
                    while(s[i][x]=='.' and x>=0){
                        yoko[i][x]=c;
                        x--;
                    }
                    c=0;
                }
            }else{
                c++;
            }
        }
        if (c){
            ll x=w-1;
            while(x>=0 and s[i][x]=='.'){
                yoko[i][x]=c;
                x--;
            }
        }
    }
    for (ll i=0;i<w;i++){
        ll c=0;
        for (ll j=0;j<h;j++){
            if (s[j][i]=='#'){
                tate[j][i]=0;
                if (c!=0){
                    ll x=j-1;
                    while(x>=0 and s[x][i]=='.'){
                        tate[x][i]=c;
                        x--;
                    }
                    c=0;
                }
            }else{
                c++;
            }
        }
        if (c){
            ll x=h-1;
            while(s[x][i]=='.' and x>=0){
                tate[x][i]=c;
                x--;
            }
        }
    }
    ll ans=0;
    for (ll i=0;i<h;i++){
        for (ll j=0;j<w;j++){
            ans=max(ans,tate[i][j]+yoko[i][j]);
        }
    }
    cout << ans-1 << endl;
    return 0;
}


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

int main(){
    int H, W;
    cin >> H >> W;
    map<char,int> mp;
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            char a; cin >> a;
            mp[a]++;
        }
    }

    int one = 0;
    int two = 0;
    int four = 0;
    if((H & 1) && (W & 1)) one = 1;
    if(H & 1) two += (W / 2);
    if(W & 1) two += (H / 2);
    four = (H / 2) * (W / 2);

    for(auto& p : mp){
        while(four && p.second >= 4){
            p.second -= 4;
            four--;
        }
    }
    for(auto& p : mp){
        while(two && p.second >= 2){
            p.second -= 2;
            two--;
        }
    }
    for(auto& p : mp){
        while(one && p.second >= 1){
            p.second--;
            one--;
        }
    }

    bool yes = true;
    for(auto& p : mp){
        yes &= (!p.second);
    }
    yes &= (!one & !two & !four);

    if(yes) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define N (ll)(1e9+7)
#define T int
#define P pair<T,T>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define rep(i,n) for(i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<< " "
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll d[n];
    int i;
    rep(i,n)
    cin>>d[i];
    int j;
    ll sum=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            sum+=(d[i]*d[j]);
        }
    }
    cout<<sum<<endl;

    return 0;
}


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

int main(){
    int n,m,a[1001] = {0};

    cin >> n >> m;
    long long int sum = 0;
    for( int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }

    int tmp = 0;
    for(int i = 0; i < n; i++){
        if( ( 4 * m * a[i] ) >= sum )tmp++;
    }

    if( tmp >= m ){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a;
  	ci(a);
  ch b;
  	ci(b);
  ll c;
  	ci(c);
  if(b=='+') co(a+c)
  else co(a-c)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define chmin(x,y) x = min(x,y)

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  ll a = in(), b = in();
  if (a >= 10 || b >= 10) cout << -1 << endl;
  else cout << a * b << endl;
  return 0;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 105, M = 1e5, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int n, s, w[N], v[N];

ll dp[N * M];

int main(){
    init();

    cin >> n >> s;
    for(int i = 0;i < n;i++)    cin >> w[i] >> v[i];

    memset(dp, -llOO, sizeof dp);

    dp[0] = 0;
    for(int i = 0;i < n;i++){
        for(int j = s;j >= w[i];j--){
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }

    cout << *max_element(dp, dp + N * M);
}

Measured memory_bytes: 82304
import java.util.*;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		// make new Scanner.
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		
		List<String> list = new ArrayList<String>();
		
		list = inStringList(sc,n);
		
		int a = list.stream().mapToInt(Integer::parseInt).sum();
		
		int sum = a - n;
		
		
		System.out.println(sum);
		

		// close Scanner
		sc.close();

	}

	
	/**
	 *  入力した数字を配列に格納するメソッド.
	 * @param sc
	 * @param n
	 * @return
	 */
	public static List<Integer> inList(Scanner sc, int n) {
		List<Integer> list = new ArrayList<Integer>();
		for (int a=0;a<n;a++) {
			list.add(sc.nextInt());
		}
		return list;
	}
	
	/**
	 *  入力した数字を配列に格納するメソッド.
	 * @param sc
	 * @param n
	 * @return
	 */
	public static List<Long> inLongList(Scanner sc, int n) {
		List<Long> list = new ArrayList<Long>();
		for (int a=0;a<n;a++) {
			list.add(sc.nextLong());
		}
		return list;
	}
	
	/**
	 *  入力した文字列を配列に格納するメソッド.
	 * @param sc
	 * @param n
	 * @return
	 */
	public static List<String> inStringList(Scanner sc, int n) {
		List<String> list = new ArrayList<String>();
		for (int a=0;a<n;a++) {
			list.add(sc.next());
		}
		return list;
	}
	
	
	/**
	 *   リストの数字の美しさを求める.
	 */
	public static int beautyList(List<Integer> list, int d) {
		int a=0;
		for (int b=0;b<= list.size(); b++) {
			if (Math.abs(list.get(b) - list.get(b+1)) ==d) {
				a++;
			}
		}
		return a;
	}
	
	public static String judge(List<Long> list) {
		Long a =list.get(0);
		Long b =list.get(1);
		Long c =list.get(2);
		Long d =list.get(3);
		
		if (a < b
				|| b > d)
				{
			return "No";
		}
		if (a-b < b) {
			if (a-b > c) {
				return "No";
			} else if (b ==d) {
				return "Yes";
			}
		}
		if (b % 2 == 0) {
			if (b*2 <= c+d) {
				return "Yes";
			} else {
				return "No";
			}
		} else {
			if (b*2 < c+d) {
				return "Yes";
			} else {
				return "No";
			}
		}
	}

}

Measured memory_bytes: 28448
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


ll p[110];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,1,n+1){
		ll temp=i;
		rep(j,2,100)if(temp%j==0){
			p[j]++;
			temp/=j;
			j--;
		}
	}
	ll ans=0;
	rep(i,0,100)if(p[i]>=74)ans++;
	rep(i,0,100)if(p[i]>=24)rep(j,0,100)if(i!=j&&p[j]>=2)ans++;
	rep(i,0,100)if(p[i]>=14)rep(j,0,100)if(i!=j&&p[j]>=4)ans++;
	rep(i,0,100)if(p[i]>=4)rep(j,i+1,100)if(p[j]>=4)rep(k,0,100)if(i!=k&&j!=k&&p[k]>=2)ans++;
	printf("%d",ans);
}

Measured memory_bytes: 128
from collections import deque
import sys
input = sys.stdin.readline

def C(i, j):
    p = [1, 0]
    q = deque([(i, j, ".")])
    while q:
        x, y, c = q.popleft()
        for u, v in d:
            dx, dy = x + u, y + v
            if 0 <= dx < h and 0 <= dy < w and s[dx][dy] != c and use[dx][dy]:
                use[dx][dy] = False
                p[s[dx][dy] == "#"] += 1
                q.append((dx, dy, s[dx][dy]))
    return p[0]*p[1]


h, w = map(int, input().split())
s = [input() for i in range(h)]
use = [[1] * w for i in range(h)]
d = [(0, 1), (1, 0), (0, -1), (-1, 0)]
ans = 0
for i in range(h):
    for j in range(w):
        if use[i][j] and s[i][j] == ".":
            use[i][j] = False
            ans += C(i, j)
print(ans)

Measured memory_bytes: 10748
import heapq

V, E, r = map(int, input().split())
G = [[] for i in range(V)]
for i in range(E):
    s, t, d = map(int, input().split())
    G[s].append([d, t])

INF = 1000000007
mn = [INF] * V
todo = [[0, r]]
fin = [0] * V
heapq.heapify(todo)
while(todo != []):
    v = heapq.heappop(todo)
    if not fin[v[1]]:
        mn[v[1]] = v[0]
        fin[v[1]] = 1
        for i in G[v[1]]:
            if mn[v[1]]+i[0] < mn[i[1]]:
                heapq.heappush(todo, [mn[v[1]]+i[0], i[1]])

for i in range(V):
    print(mn[i] if mn[i] != INF else 'INF')


Measured memory_bytes: 106932
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a+100*b+50*c==X:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define LL long long
 
const int maxn=5e5+10;
 
int n,L,H,T;
 
struct Point{
	LL x;
	double y;
	Point() {}
	Point(LL x,double y):x(x),y(y) {}
	Point operator + (const Point &p) const {return Point(x+p.x,y+p.y);}
	Point operator - (const Point &p) const {return Point(x-p.x,y-p.y);}
};
 
double Cross(Point A,Point B) {return A.x*B.y-A.y*B.x;}
 
Point P[maxn];
 
Point GetPoint(Point A,Point B,LL x)
{
	double t=((double)x-A.x)/(B.x-A.x);
	return Point(x,A.y+t*(B.y-A.y));
}
 
int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	scanf("%d%d",&n,&L);
	H=T=1;
	P[1]=Point(0,0);
	while (n--)
	{
		Point p;
		scanf("%lf%lld",&p.y,&p.x);
		p.y*=p.x;
		T++;
		P[T]=P[T-1]-p;
		while (H!=T&&P[H+1].x-P[T].x>=L) H++;
		if (P[H].x-P[T].x>L)
		{
			P[H]=GetPoint(P[H],P[H+1],P[T].x+L);
		while (H+1<T&&Cross(P[T-1]-P[T],P[T-2]-P[T])>=0) P[T-1]=P[T],T--;
		}
		printf("%.10lf\n",((double)P[H].y-P[T].y)/L);
	}
}

Measured memory_bytes: 18304
from statistics import mean
import math
n = int(input())
citizen = list(map(int,input().split()))
hostF = math.floor(mean(citizen))
hostC = math.ceil(mean(citizen))
ansF = 0
ansC = 0
for i in citizen:
    ansF += (hostF-i)**2
    ansC += (hostC-i)**2
ans = ansF if ansF<ansC else ansC
print(int(ans))
   

Measured memory_bytes: 5404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

ll N, M, Q;
vll a, b, c, d;
ll ans = 0;

void dfs(vll A) {
    if (A.size() == N+1) {
        ll now = 0;
        rep(i, Q) if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        chmax(ans, now);
        return;
    }

    A.push_back(A.back());
    while(A.back() <= M) {
        dfs(A);
        A.back()++;
    }
}


int main() {
    cin >> N >> M >> Q;
    a = b = c = d = vll(Q);
    rep(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(vll(1, 1));
    cout << ans << endl;
}


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



struct node{
  int lc;
  int rc;
  int key;
  void init(int a){
    lc=rc=-1;
    key=a;
  }
};

#define bstN 600000
struct bst{

  int size;
  node t[bstN];

  void init(){
    size=0;
  }
  
  void insert(int v){
    int i=0;
    while(i<size){
      int& child=(v<t[i].key?t[i].lc:t[i].rc);
      if(child==-1)child=size;
      i=child; 
    }
    t[size++].init(v);
  }

  void preord(int pos){
    if(pos==-1||pos==size)return;
    preord(t[pos].lc);
    printf(" %d",t[pos].key);
    preord(t[pos].rc);
  }
  
  void inord(int pos){
    if(pos==-1||pos==size)return;
    printf(" %d",t[pos].key);
    inord(t[pos].lc);
    inord(t[pos].rc);
  }
};


bst T;

int main(){
  T.init();
  int n,a;
  char str[100];
  scanf("%d",&n);
  
  while(n--){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&a);
      T.insert(a);
    }else{
      T.preord(0);
      printf("\n");
      T.inord(0);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 7332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int N;
  N = S.size();
  if(S.at(N-1)=='s'){
    cout << S << "es" <<endl;
  }
  else {
    cout << S << "s" <<endl;
  }
}

Measured memory_bytes: 3624
#include <stdio.h>

int main (void) {
    int i,N,b1 = 0, b2 = 0, b4 = 0;
    int a[100010];

    scanf("%d", &N);
    
    for(i = 0 ; i < N ; i ++) {
        scanf("%d", &a[i]);
        if (a[i] % 4 == 0) b4 ++;
        else if (a[i] % 2 == 0) b2++;
        else b1++;

     }

    if (b2 == 0) {
        if (b1 <= b4 + 1) printf("Yes\n");
        else printf("No\n");
    }else {
        if (b1 <= b4) printf("Yes\n");
        else printf("No\n");
    }
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;
int main()
{
 int n,l[102],ans=0;
 scanf("%d",&n);
 for(int i=0;i<n;i++)
 {
	scanf("%d",&l[i]);
 }
 for(int i=0;i<n;i++)
 {
	for(int j=i+1;j<n;j++)
	{
		for(int k=j+1;k<n;k++)
		{
		 if(l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[j]+l[k]>l[i]&&l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]){ans++;}
		}
	}
 }
 printf("%d",ans);
}



Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



int main(){
  ll n,m;
  cin >> n >> m;
  ll p[100010],y[100010];
  vector<pair<pair<ll,ll>,ll>> v;
  FOR(i,m){
    cin >> p[i] >> y[i];
    v.push_back(make_pair(make_pair(p[i],y[i]),i));
  }
  sort(v.begin(),v.end());
  pair<ll,ll> ans[100010];
  ll cnt=0,c=0;
  FOR(i,m){
    if(c!=v[i].first.first)cnt=1;
    else cnt++;
    ans[v[i].second]=make_pair(v[i].first.first,cnt);
    c=v[i].first.first;
  }

  FOR(i,m){
    printf("%012lld\n",ans[i].first*1000000+ans[i].second);
  }

  
  
}


Measured memory_bytes: 7792
// AtCoder ABC112: D - Partition
// 2020.1.29 bal4u

#include <stdio.h>
#include <math.h>

int main()
{
	int i, b, N, M, ans;
	
	scanf("%d%d", &N, &M);
	ans = 1, b = (int)sqrt((double)M);
	for (i = 1; i <= b; ++i) {
		if (M%i == 0) {
			if (M/i >= N && i > ans) ans = i;
			if (i >= N && M/i > ans) ans = M/i;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	int ret=0;
	FOR(i,N-2) if(S.substr(i,3)=="ABC") ret++;
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
from collections import deque

def solve2():
    N = int(raw_input())
    to = [ [] for i in range(N) ]
    cost= [ [] for i in range(N) ]
    for i in range(N - 1):
        ui,vi,wi = [int(_) for _ in raw_input().split()]
        ui -= 1
        vi -= 1
        to[ui].append(vi)
        cost[ui].append(wi)
        to[vi].append(ui)
        cost[vi].append(wi)
    # BFS
    ret = [-1] * N
    que = deque()
    ret[0] = 0
    que.append(0)
    while len(que) > 0:
        visit = que.popleft()
        for i in range(len(to[visit])):
            u = to[visit][i]
            w = cost[visit][i]
            if ret[u] != -1:
                continue
            ret[u] = (ret[visit] + w) % 2
            que.append(u)
    for i in range(N):
        print ret[i]

if __name__ == '__main__':
    solve2()


Measured memory_bytes: 57244
#include <bits/stdc++.h>
using namespace std;
int count(int n,int x){
    int count=0;
    for(int i=3;i<=n;i++){
        for(int j=2;j<i;j++){
            for(int k=1;k<j;k++){
                if(i+j+k==x) count++;
            }
        }
    }
    return count;
}

int main(){
    while(1){
        int n,x;
        cin>>n>>x;
        if(n==0 &&x==0) break;
        else{
            cout<<count(n,x)<<endl;
        }
    }
}


Measured memory_bytes: 3116
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.141592653589793238
void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld x,lld mod){return (x%mod+mod)%mod;}
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<int> v[maxi];
// long long a[maxi];
// void dfs(int x,int y){
//     a[x]+=a[y];
//     for(int i:v[x]){
//         if(i!=y){
//             dfs(i,x);
//         }
//     }
// }

// void dfs(int arr[][],int i,int j){
//     if(i<0 || j<0){
//         return;
//     }
//     else{
//         if()
//     }
// }
void test_case(){
    int n,k;
    cin>>n>>k;
    vector<lld> v(n);
    lld prod=1;
    fors(i,n){
        cin>>v[i];
    }
    // stack<lld> st;
    // for(int i=0;i<k;++i){
    //     prod*=v[i];
    // }
    // st.push(prod);
    for(int i=k;i<n;++i){
        // prod*=v[i];
        // prod/=v[i-k];
        if(v[i]>v[i-k]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
        // st.push(prod);
    }
}

int main(){
    fastio;
    file();
    // pre();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}

Measured memory_bytes: 4764
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t H,W;
char MAP[55][55];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> H>>W;
	for (int32_t i = 0; i < H; i++)
	{
		in >> &MAP[i + 1][1];
	}
	for (int32_t i = 1; i <= H; i++)
		for (int32_t j = 1; j <= W; j++)
	{
		if (MAP[i][j] == '#') { continue; }
		int ans = 0;
		for (auto dh : { -1,0,1 })for (auto dw : { -1,0,1 }) {
			if (MAP[i+dh][j+dw] == '#') { ++ans; }
		}
		MAP[i][j] = '0' + ans;
	}
	for (int32_t i = 1; i <= H; i++)
	{
		out <<  &MAP[i][1]<<'\n';
	}

	return 0;
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<ll>().max();

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> v(n+1, 0);
	ll soma = 0;
	for(ll i=1; i<=n; i++) {
		cin >> v[i];
		soma += v[i];
	}

	vector<ll> w;
	for(ll i=1; i<=n; i++) {
		ll x = v[i];
		ll k = 0;
		while (k < m and pow(2,k) <= v[i]) {
			w.push_back((ll)(x/pow(2,k)) - (ll)(x/pow(2,k+1)));		
			k++;
		}
	}
	sort(w.begin(), w.end());
	ll k = 1;
	for(ll i=w.size()-1; i>=0; i--) {
		if (k <= m) soma -= w[i]; 
		k++;
	}
	cout << soma << endl;

}


Measured memory_bytes: 35812
#include<stdio.h>

int main(){
  int x,y;
  int i = 1;
  while(1){
    scanf("%d %d",&x,&y);
    if(i <= 3000){
      if(x == 0&&y == 0){
        break;
      }else if(0 <= x&&10000 >= y){
        if(x > y){
          printf("%d %d\n",y,x);
          i++;
        }else{
          printf("%d %d\n",x,y);
          i++;
        }
    } 
  }else break;
}
  return 0;
}

Measured memory_bytes: 1852
// ref: https://img.atcoder.jp/arc093/editorial.pdf

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int K=50;
    int A, B; cin >> A >> B; --A; --B;
    vector<string> vS(100);
    for(int i=0; i<K;   ++i){ vS[i] = string(100, '#'); }
    for(int i=K; i<2*K; ++i){ vS[i] = string(100, '.'); }
    
    int cnt=0;
    for(int i=0; i<K-1; i+=2){
        if(cnt >= A){ break; }
        for(int si=0; si<2*K; si+=2){
            if(cnt >= A){ break; }
            
            vS[i][si] = '.'; ++cnt;
        }
    }
    cnt=0;
    for(int i=K+1; i<2*K; i+=2){
        if(cnt >= B){ break; }
        for(int si=0; si<2*K; si+=2){
            if(cnt >= B){ break; }
            
            vS[i][si] = '#'; ++cnt;
        }
    }
    
    cout << 2*K << ' ' << 2*K << endl;
    for(int i=0; i<2*K; ++i){
        cout << vS[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N; cin >> N;
    string S;
    map<string, int> mp;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        vector<char> tmp;
        cin >> S;
        for (auto s : S) tmp.push_back(s);
        sort(tmp.begin(), tmp.end());
        S = "";
        for (auto t : tmp) S += t;
        ans += (mp[S]++);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 12800
import math
import sys
import numpy as np

def int_input():
    return map(int, input().split())

n, k = int_input()

ans = 0
for i in range(1, n + 1):
    tmp = 0
    while i * 2 ** tmp < k: tmp += 1
    ans += (1 / n) * 0.5 ** tmp
print(ans)



Measured memory_bytes: 12504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		int y[] = new int[n];
		//double ans = 0.0;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			y[i] = sc.nextInt();
		}

		double sum = 0.0;
		//p=1のとき
		for(int i = 0; i < n; i++) {
			sum += Math.abs(x[i] - y[i]);
		}
		System.out.println(sum);

		sum = 0.0;
		//p=2のとき
		for(int i = 0; i < n; i++) {
			sum += Math.pow(Math.abs(x[i] - y[i]), 2);
		}
		System.out.println(Math.pow(sum, 1.0 / 2.0));

		sum = 0.0;
		//p=3のとき
		for(int i = 0; i < n; i++) {
			sum += Math.pow(Math.abs(x[i] - y[i]), 3);
		}
		System.out.println(Math.pow(sum, 1.0 / 3.0));

		sum = 0.0;
		//p=∞のとき
		for(int i = 0; i < n; i++) {
			sum = Math.max(sum, Math.abs(x[i] - y[i]));
		}
		System.out.println(sum);
	}
}



Measured memory_bytes: 26544
#include <bits/stdc++.h>
#define foi(i,k,n) for (int i = (int)k; i < (int)n; ++i)

using namespace std;
using ll = long long;
using ii = pair<int,int>;

constexpr int MOD = 7 + 1000000000;
constexpr int MAXN = 5 + 200000;

int f[MAXN];

int mul(int a, int b) {
  return (int)((1LL*a*b) % MOD);
}

int add(int a, int b) {
  int ans = a + b;
  if (ans >= MOD) ans -= MOD;
  return ans;
}

ll sum(ll n) {
  if (n <= 0) return 0LL;
  return (n*(1+n)) >> 1;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int n,k; cin >> n >> k;
  int ans = 0;
  for (; k <= 1+n; ++k) {
    ll l = sum(k-1), r = sum(n) - sum(n-k);
    assert(l <= r);
    ans = add(ans, (1 + r - l)%MOD);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3636
fun main(args: Array<String>) {
    while(true)
    {
        var cnt = 0
        var list = readLine()!!.split(" ").map(String::toInt)
        for (i in list[0]..list[1])
        {
           if ( list[2] % i == 0) cnt+=1
        }
        println("%d".format(cnt))
        return
    }
}


Measured memory_bytes: 33604
N,K = map(int,input().split())
S = input()


if N < 2**K:
    S_young = sorted(list(S))[0]
    print(S_young*N)
    
else:
    word=S
    S=S+S[::-1]
    for i in range(K):
        for j in range(N-1):
            if word > S[1+j:1+j+N]:
                word = S[1+j:1+j+N]
        S = word[::-1]+word
    print(word)

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

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


		  try{


			  while(true){
				  //????????\???
			     String ab = input.readLine();
		         String []strAry = ab.split(" ");
		         int  a=Integer.parseInt(strAry[0]);
	             int b=Integer.parseInt(strAry[1]);
	             int count=0;
	             int countb=0;
	              if(a==0&&b==0){
	        	      break;
	               }
	                  //a?????°?????????
	                  for(int i=0; i<a; i++){
	                	  //count??§?\???°?????¶??°??????????????????
	                	  count++;
	                	  //count????\???°??????
	                	  if(count%2!=0){
	        	             for(int j=0; j<b; j++){
	        	            	 //countb??§?????????????´?????\???°?????¶??°???????????????
	        	        	      countb++;
	        	        	      //countb????\???°??????
	        	        	      if(countb%2!=0){
	        	        		      System.out.print('#');
	        	        		  //countb?????¶??°??????
	        	        	      }else{
	        	        		      System.out.print('.');
	        	        	      }

	        	               }
	        	             //count?????¶??°??????
	                        }else{
	                        	 for(int j=0; j<b; j++){
	        	        	      countb++;
	        	        	      if(countb%2!=0){
	        	        		      System.out.print('.');
	        	        	      }else{
	        	        		      System.out.print('#');
	        	        	      }

	                        	 }

	                         }


                      countb=0;
	                  System.out.println("");
	              }
	                  System.out.println("");
			  }

		    }catch(IOException e) {   System.out.println("Exception : " + e);
		    }

	}//60
}

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

using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	ll res = 0;
	ll keep = 0;
	for(int i=0; i<n; i++)
	{
		ll a;
		cin >> a;
		if(keep==1 && a>0)
		{
			res++;
			a--;
		}
		res+= a / 2;
		keep = a % 2;
	}
	cout << res << endl;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n)	 for(int i = 0; i < (n); i++)
#define all(a)		 begin(a), end(a)

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll n, ll m) {
	printf("%d", (m - 1) * (n - 1));
}

int main() {
	ll m;
	ll n;
	scanf("%lld", &n);
	scanf("%lld", &m);
	solve(n, m);
	return 0;
}


Measured memory_bytes: 128
/*
20:29 - 20:48
 */

#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cassert>
#include<climits>
#include<sstream>
#include<cstdlib>

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

using namespace std;

typedef long long ll;

long long extgcd(long long a,long long b,long long& x,long long& y)
{
  long long d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }
  else
    x = 1,y = 0;
  return d;
}

long long mod_inv(long long a,long long m)
{
  long long x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

ll expression();
string text;
int pos;
ll MOD;
bool out;

ll fact(){
  if(out)return 0;
  ll res = 0;
  if(text[pos] == '('){
    ++pos;
    res = expression();
    ++pos;
  } else {
    while( '0' <= text[pos] && text[pos] <= '9' ){
      res *= 10LL;
      res += (text[pos] - '0');
      pos++;
    }
  }
  return res%MOD;
}

ll term(){
  if(out)return 0;
  ll b = fact();
  while(text[pos] == '*' || text[pos] == '/'){
    if(text[pos] == '*'){
      ++pos;
      b = ( (b%MOD) * (fact()%MOD) ) % MOD;
    } else {
      ++pos;
      ll tmp = fact();
      if(tmp == 0){
	out = true;
	return b;
      }
      b = ( (b%MOD) * (mod_inv(tmp,MOD))%MOD ) % MOD;
    }
  }
  return b;
}

ll expression(){
  if(out)return 0;
  ll a = term();
  while(text[pos] == '+' || text[pos] == '-'){
    if(text[pos] == '+'){
      ++pos;
      a = ( a + term() ) % MOD;
    } else {
      ++pos;
      a = ( a - term() + MOD) % MOD;
    }
  }
  return a;
}

int main(){
  string tmp;
  while(getline(cin,tmp)){
    if(tmp[0] == '0')break;
    rep(i,tmp.size())if(tmp[i] == ':'){
      tmp[i] = ' ';
      break;
   } 
    pos = 0;
    text.clear();
    stringstream ss;
    ss << tmp;
    ss >> tmp;
    MOD = (atol)(tmp.c_str());
    while(!(ss >> tmp).fail()){
      text += tmp;
    }

    out = false;
    ll ans = expression();
    if(out) cout << "NG" << endl;
    else    cout << text << " = " << ans << " (mod " << MOD << ")" << endl;

  }

  return 0;
}

Measured memory_bytes: 1560
# coding:utf8
from collections import  Counter

n=int(input())

ans=10**12+1

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(table)
    table.sort()
    return table

t=divisor(n)
for i in range(0,len(t)//2):
    tmp=t[i]+(n//t[i])-2
    ans=min(ans,tmp)

print(ans)

Measured memory_bytes: 3572