akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, i;
  cin >> n >> i;
  cout << n - (i-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> L(N);
	long long ans = 0;
	for(int i=0;i<N;i++)cin >> L[i];
	sort(ALL(L));
	for(int a=0;a<N;a++)for(int b=a+1;b<N;b++){
		int ab = L[a] + L[b];
		int r = lower_bound(ALL(L),ab) - L.begin();
		int l = b+1;
		ans += max(0,r-l);
	}
	cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;
  bool judge = false;
  for (char x:s){
     if (x == '7'){
       judge = true;
       break;
     }
  }
  if (judge){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
      
}


Measured memory_bytes: 3624
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, K = list(map(int, input().split()))

S = list(input())

S[K - 1] = S[K - 1].lower()
print(''.join(S))


Measured memory_bytes: 23460
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for(int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for(int i = 0; i < N - 1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <stack>
#include <limits.h>
#include <cstdio>
#include <bitset>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
int Gcd(int a,int b){if (b == 0) return a; return Gcd(b , a%b);}
int Lcm(int a, int b){ return a/Gcd(a,b)*b;}
inline int read(){
	int f = 1, x = 0;char ch = getchar();
	while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
	while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
	return x * f;
}
const int maxn = 1e6 + 10;
struct node{
	double x,y;
}p[maxn];
double xx,yy;
int cmp(node a,node b){
    if (atan2(a.y - yy, a.x - xx) != atan2(b.y - yy, b.x - xx))
        return (atan2(a.y - yy, a.x - xx)) < (atan2(b.y - yy, b.x - xx));
    return a.x < b.x;
}
int main(){
	int n = read();
	for(int i=1; i<=n; i++){
		p[i].x = read();
		p[i].y = read();
	}
	sort(p+1,p+n+1,cmp);
	for(int i=1; i<=n; i++){
		p[i+n] = p[i]; 
	}
	double ans = 0;
	for(int i=1; i<=n; i++){
		xx = yy = 0;
		for(int j=i; j<i+n; j++){
			xx += p[j].x;
			yy += p[j].y;
			ans = max(ans,sqrt(xx*xx+yy*yy));
		}
	}
	printf("%.11f\n",ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
d, x = map(int, input().split())
day = []
choco = 0
for _ in range(n):
    day.append(int(input()))
for i in day:
    tmp = []
    day_calc = 1
    while day_calc <=d:
        tmp.append(day_calc)
        day_calc += i
    choco += len(tmp)
print(x+choco)

Measured memory_bytes: 3064
n,a,b,c,d=map(int,input().split())
s=input()
for i in range(a,max(c,d)-1):
  if s[i]==s[i+1]=='#':
    print('No')
    exit()
if c>d:
  for i in range(b-2,d-1):
    if s[i]==s[i+1]==s[i+2]=='.':
      print('Yes')
      exit()
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3572
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N, K;
    std::cin >> N >> K;

    std::vector<int> l(N);
    for (int i = 0; i < N; i++) {
        std::cin >> l[i];
    }

    std::sort(l.rbegin(), l.rend());

    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum += l[i];
    }

    std::cout << sum << std::endl;
    return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxn = 55;
const int maxk = maxn*maxn;
int dp[maxn][maxn][maxk];

int dfs(const int i, const int j, const int k, const int n)
{
    if (k < 0)
        return 0;
    if (i == n)
        return j == 0 && k == 0;
    int& ans = dp[i][j][k];
    if (-1 == ans) {
        ans = 0;
        ans += dfs(i+1,j,k-2*j,n);
        ans %= mod;
        ans += dfs(i+1,j+1,k-2*(j+1),n);
        ans %= mod;
        if (j) {
            ans += dfs(i+1,j,k-2*j,n) * (LL)j % mod;
            ans %= mod;
            ans += dfs(i+1,j,k-2*j,n) * (LL)j % mod;
            ans %= mod;
            ans += dfs(i+1,j-1,k-2*(j-1),n) * (LL)j*j % mod;
            ans %= mod;
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    while (cin >> n >> k) {
        memset(dp,-1,sizeof(dp));
        cout << dfs(0,0,k,n) << endl;
    }
    return 0;
}


Measured memory_bytes: 36096
using System;
//using System.Collections.Generic;
using System.Linq;

namespace _0094
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            double ans = a[0] * a[1] / 3.305785;
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {


	string s;
	cin>>s;

	if(s=="Sunny"){
		cout<<"Cloudy";
	}
	else if (s=="Rainy"){
		cout<<"Sunny";
	}
	else{
		cout<<"Rainy";
	}



	return 0;
}

Measured memory_bytes: 3544
import sys
def no():
    print("No")
    sys.exit()

a,b=map(int,input().split())
s=input()
num=[str(i) for i in range(10)]

if len(s)==a+b+1:
    for i in range(a):
        if s[i] not in num: no()
    if s[a]!="-": no()
    for i in range(a+1,a+b+1):
        if s[i] not in num: no()   

else: no()

print("Yes")

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  string s; cin >> s;
  int ans = 700;
  REP(i, s.size()) if (s[i] == 'o') ans += 100;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;

ll n;
ll x[22][22];
ll a[22];
ll b[22];
int main()
{
        cin >> n;
        for(ll i=1;i<=n;i++) cin >> a[i];
        for(ll i=1;i<=n;i++) cin >> b[i];
        for(ll i=1;i<n;i++) {
                cin >> x[i+1][i];
        }
        ll ans = b[a[1]];
        for(ll i=2;i<=n;i++){
                ans += b[a[i]] + x[a[i]][a[i-1]];
        }
        cout << ans << endl;
        return 0;
}


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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

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

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

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

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

const int  N = 2e5+5;
const int inf = INT_MAX;
const int MOD = 1e9+7;

ll a[N];
ll m[1000005];

void solve()
{
   ll n;
   cin >> n;
   for(ll i=1;i<=n;i++)
   {
      cin >> a[i];
      m[a[i]]++;
   }
   ll ans = 0;
   for(ll i=1;i<=n;i++)
   {
      bool ok = 0;
      ll x = a[i];
      if(x == 1)
      {
         if(m[x] == 1) ans++;
         continue;
      }
      for(ll j=1;j<=sqrt(x);j++)
      {
         if(x%j == 0)
         {
            if(m[j]>0)  ok = 1;
            ll v = x/j;
            if(m[v]>0)
            {
               if(v == x)
               {
                  if(m[v]>1) ok = 1;
               }
               else
               {
                  ok = 1;
               }
            }
         }
      }
      if(ok == 0) ans++;
   }
   cout << ans;
}

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


Measured memory_bytes: 12916
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){
    string s;
    cin >> s;
    int a,b;
    a=b=0;
    for(int i=0;i<s.size();i++){
        if(i%2 != (int)(s[i]-'0')){
            a++;
        }else{
            b++;
        }
    }
    cout << min(a,b) << endl;
    return 0;
}

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

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    string s,t;
    cin>>s>>t;
    rep(i,0,sz(s)){
    	if (s[i]!=t[i]){
    		cout<<"No"<<endl;
    		return;
    	}
    }
    cout<<"Yes"<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3652
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int N;
    while (cin >> N) {
        int be = 1 << 30;
        int s, t;
        for (int a = 1; a < N; ++a) {
            int b = N - a;
            int p = a;
            int q = b;
            int sm = 0;
            while (p || q) {
                sm += p % 10 + q % 10;
                p /= 10;
                q /= 10;
            }
            if (be > sm) {
                be = sm;
                s = a;
                t = b;
            }
        }
        cout << be << endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#define MAX 100000
typedef struct t{
  int p;
  int l;
  int r;
}tree;
int Depth(int);
void hantei(int,int,int);
tree T[MAX];
int cnt =0;
int main(){
  
  int n,k,i,j,id,c,l,num = 0;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  for(i = 0;i < n;i++){
    scanf("%d",&id);
    scanf("%d",&k);
    for(j = 0;j < k;j++){
      scanf("%d",&c);
      //左右にわける
      if(j == 0){
	T[id].l = c;
      }
      //rightを兄弟として実装
      else{
	T[l].r = c;
      }
      l = c;
      T[c].p = id;
    }
  }
  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,Depth(i));
    hantei(T[i].p,i,n);
    printf("\n");
  }
  return 0;
}
int Depth(int x){
  int d = 0;
  while(T[x].p != -1){
    x = T[x].p;
    d++;
  }
  return d;
}

void hantei(int p,int node,int n){
  int i,j,wr = 0,x;
  if(p == -1){
    printf("root, ");
    printf("[");
      for(x = T[node].l;x != -1;x = T[x].r){
	if(wr)printf(", ");
	wr++;
	printf("%d",x);
	/*if(T[i].p == node && T[i].num == cnt){
	  if(wr)printf(", ");
	  wr++;
	  printf("%d",i);
	  cnt++;
	}
	*/
      }
    printf("]");
    return;
  }
  if(T[node].l == -1){
    printf("leaf, ");
    printf("[]");
  }
  else{
    printf("internal node, ");
    
    printf("[");
    for(x = T[node].l;x != -1;x = T[x].r){
      if(wr)printf(", ");
      wr++;
	printf("%d",x);
	/*if(T[i].p == node && T[i].num == cnt){
	  if(wr)printf(", ");
	  wr++;
	  printf("%d",i);
	  cnt++;
	*/
	}
    printf("]");
  }
}



Measured memory_bytes: 3016
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define cl clear
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
int main()
{
	ll n;
	cin>>n;
	vector<ll> down(n),up(n);
	for(int i=0;i<n;i++)
	{
		cin>>down[i]>>up[i];
	}
	sort(all(down));
	sort(all(up));
	if(n%2 == 0)
	{
		ll pos = n/2;
		ll he1 = down[pos]+down[pos-1];
		ll he2 = up[pos]+up[pos-1];
		cout<<he2-he1+1<<endl;
	}
	else
	{
		ll pos = (n+1)/2-1;
		ll num1 = down[pos];
		ll num2 = up[pos];
		cout<<num2-num1+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 6424
/*
  AOJ 2185
  Title:Petting Cats
  @kankichi573
*/
#include <stdio.h>
int in_area(int cx,int cy,int x,int y,int w,int h) 
{
  if((cx>=x)&&(cx<=x+w)&&(cy>=y)&&(cy<=y+h))
    return(1);
  else
    return(0);
}
main()
{
  int x,y,w,h,cx,cy;
  int m,n,i,j,cats;
  scanf("%d",&m);
  for(i=0;i<m;i++)
    {
      scanf("%d %d %d %d",&x,&y,&w,&h);
      scanf("%d",&n);
      
      cats=0;
      for(j=0;j<n;j++)
	{
	  scanf("%d %d",&cx,&cy);
	  if(in_area(cx,cy,x,y,w,h))
	     cats++;
	}
      printf("%d\n",cats);
    }
  return(0);
}

Measured memory_bytes: 600
from itertools import accumulate
import sys
n=int(input())
A=list(map(int,input().split()))
S=sum(A)/2
B=list(accumulate(A))

for i in range(n):
    B[i]-=S
    if B[i]<0:
        continue
    elif B[i]==0:
        print(0)
        sys.exit()
    else:
        if i==0:
            print(A[0]-A[1:])
        elif i>0 and i<n-1:
            a=abs(sum(A[:i])-sum(A[i:]))
            b=abs(sum(A[:i+1])-sum(A[i+1:]))
            print(min(a,b))
        else:
            print(A[n-1]-sum(A[:n-1]))
        sys.exit()


Measured memory_bytes: 25772
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var c = 1;
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;

            var n21 = 2 * n - 1;
            var a = new List<int>[n21];
            var m = 0;
            var p = 1;
            for (int i = 0; i < n21; i++)
            {
                if (i < n) m++;
                else m--;
                a[i] = new List<int>();
                for (int j = 0; j < m; j++) a[i].Add(p++);
                if (i % 2 == 0) a[i].Reverse();
            }
            var pr = new int[n21];
            Console.WriteLine("Case {0}:",c++);
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    var tw = a[i + j][pr[i + j]++];
                    Console.Write("{0,3:d}", tw);
                }
                Console.WriteLine();
            }
        }
    }
}



Measured memory_bytes: 16008
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=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 D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    ll n; cin >> n;
    vector<ll> v;
    int tmp;

    bool asc = false;
    bool desc = false;
    ll prev = -1;
    ll res = 0;
    REP(i, n) {
        cin >> tmp;
        v.push_back(tmp);

        if (prev == -1) {
            res++;
        } else if (!asc && !desc) {
            if (tmp > prev) {
                asc = true;
            } else if (tmp < prev) {
                desc = true;
            }
        } else if (asc) {
            if (tmp < prev) {
                res++;
                asc = false;
            }
        } else if (desc) {
            if (tmp > prev) {
                res++;
                desc = false;
            }
        }
        prev = tmp;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4232
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {

            var n = int.Parse(Console.ReadLine());
            var x = new int[n];
            var y = new int[n];
            var h = new long[n];
            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
                x[i] = (int)input[0];
                y[i] = (int)input[1];
                h[i] = input[2];
            }

            int basex = 0;
            int basey = 0;
            long baseh = 0;

            for (int i = 0; i < n; i++)
            {
                if (h[i] > 0)
                {
                    basex = x[i];
                    basey = y[i];
                    baseh = h[i];
                    break;
                }
            }
            
            for (int i = 0; i < 101; i++)
            {
                for (int j = 0; j < 101; j++)
                {
                    var ok = true;
                    var ch = baseh + Math.Abs(basex - i) + Math.Abs(basey - j);
                    for (int k = 0; k < n; k++)
                    {
                        if (h[k] != Math.Max(ch - Math.Abs(x[k] - i) - Math.Abs(y[k] -j), 0))
                        {
                            ok = false;
                            break;
                        }
                    }
                    if (ok)
                    {
                        Console.WriteLine(i + " " + j + " " + ch);
                        return;
                    }
                }
            }
    }
}

Measured memory_bytes: 13396
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll l,r;
	cin >> l >> r;
	ll ans=inf;
	ll a,b;
	rep(i,l,min(l+3000,r+1)){
		rep(j,i+1,min(l+3000,r+1)){
			ll z=(i*j)%2019;
			if(z<ans){
				ans=z;
				a=i;
				b=j;
			}
		}
	}
	//trace2(a,b);
	cout << ans;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;


int main() {
    ll n, k; cin >> n >> k;
    vector<ll> a(n); rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    ll r = 1e18 + 1;
    ll l = -1e18 - 1;
    ll mid;
    while (r - l > 1) {
        mid = (l + r) / 2;
        ll cnt = 0;
        rep(i, n) {
            if (a[i] < 0) {
                cnt += a.begin()+i - partition_point(a.begin(), a.begin()+i, [&](const ll v) {return v * a[i] > mid;});
            } else if (a[i] == 0) {
                if (mid >= 0) cnt += i;
            } else {
                cnt += partition_point(a.begin(), a.begin()+i, [&](const ll v) {return a[i] * v <= mid;}) - a.begin();
            }
        }

        if (cnt < k) l = mid;
        else r = mid;
    }

    cout << r << endl;

    return 0;
}


    


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

int main() {
  int n, m; cin >> n >> m;
  bool ans = false;
  int x[n] = {};
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    if (a == 1 && ++x[b] == 2) ans = true;
    if (b == n && ++x[a] == 2) ans = true;
  }
  cout << (ans ? "" : "IM") << "POSSIBLE" << endl;
}

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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007



int main() {
    string S, T; cin >> S >> T;
    int ans = 0;
    rep(i, 3) {
        if (S[i] == T[i]) ans++;
    }
    cout << ans << endl;
}







Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <list>
#include <map>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
#define rep(i,n) for(register int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
//const int MOD=998244353;
//const int N=2e5+10;

inline int read(){
	int ww=1,xx=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') ww=-ww;ch=getchar();}
	while(isdigit(ch)){xx=(xx<<1)+(xx<<3)+(ch^48);ch=getchar();}
	return ww*xx;
}

int n;
int a[1010][1010];
int p[1010];
int now[1010];
int tmp;
bool used[1010];

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++) for(int j=1;j<n;j++) a[i][j]=read();
	for(int i=1;i<=n;i++) p[i]=1,now[i]=a[i][p[i]];
	while(true){
		tmp++;
		if(tmp>n*(n-1)/2) {
			tmp=-1;
			break;
		}
		for(int i=1;i<=n;i++)
			if(p[i]<n&&i==now[now[i]]&&!used[i]&&!used[now[i]]) {
//				printf("%d %d\n",i,now[i]);
				p[now[i]]++;
				now[now[i]]=a[now[i]][p[now[i]]];
				p[i]++;
				used[now[i]]=true;
				now[i]=a[i][p[i]];
				used[i]=true;
			}
//		for(int i=1;i<=n;i++) printf("%d:%d\n",p[i],now[i]);
//		puts("");
		for(int i=1;i<=n;i++) used[i]=false;
		bool f=true;
		for(int i=1;i<=n;i++) if(p[i]!=n) {f=false;break;}
		if(f) break;
	}
	printf("%d\n",tmp);
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	string a[3];

	cin >> a[0];
	cin >> a[1];
	cin >> a[2];

	if (a[0].back() == a[1].front() && a[1].back() == a[2].front())
	{
		cout << "YES";
		return 0;
	}

	cout << "NO";

	return 0;
}


Measured memory_bytes: 764
def main():
    s = input().split()
    
    s1=list(s[0])
    s2=list(s[1])
    s3=list(s[2])
    a=len(s1)
    b=len(s2)
    c=len(s3)
    if(s1[a-1]==s2[0] and s2[b-1]==s3[0]):
        print("YES")
    else:
        print("NO")
    
main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n; cin >> n;
    vint a(n+1);
    rep(i,n+1) cin >> a[i];
    if (n == 0) {
        if (a[0] == 1) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }
    vll y(n+1);
    y[n] = a[n];
    for (int i = n-1; i >= 0; i--) {
        y[i] = y[i+1]+a[i];
    }
    ll ans = 1;
    ll now = 1;
    int id;
    rep(i,n+1) {
        now = (now-a[i])*2;
        if (now <= 0) {cout << -1 << endl; return 0;}
        if (now >= y[i+1]) {id = i+1; break;}
        ans += now;
    }
    for (int i = id; i < n+1; i++) ans += y[i];
    cout << ans << endl;
}

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

using namespace std;

using Int = long long;
using P = pair<int, int>;

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

int main() {
  string S;
  cin >> S;
  vector<string> op = {
    "dream",
    "dreamer",
    "erase",
    "eraser"
  };
  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) reverse(op[i].begin(), op[i].end());
  bool ok = true;
  int pos = 0;
  while (pos < (int)S.size()) {
    bool flag = false;
    for (int j = 0; j < 4; ++j) {
      if (S.substr(pos, op[j].size()) == op[j]) {
        pos += op[j].size();
        flag = true;
        break;
      }
    }
    if (!flag) {
      ok = false;
      break;
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
k = 72
kk = k // 4
K = 1<<k
nu = lambda L: int("".join([hex(K+a)[3:] for a in L[::-1]]), 16)
st = lambda n: hex(n)[2:]
li = lambda s, l, r: [int(a, 16) % P if len(a) else 0 for a in [s[-(i+1)*kk:-i*kk] for i in range(l, r)]]

def grow(d, v, h):
    h += [0] * d
    f = [(-1 if (i+d) % 2 else 1) * fainv[i] * fainv[d-i] % P * h[i] % P for i in range(d+1)]
    nuf = nu(f)
    a = d * inv[v] % P
    t = [1] * (3*d+3)
    for i in range(1, 3*d+3): t[i] = t[i-1] * (a - d + i - 1) % P
    ti = [1] * (3*d+3)
    ti[-1] = pow(t[-1], P-2, P)
    for i in range(1, 3*d+3)[::-1]: ti[i-1] = ti[i] * (a - d + i - 1) % P
    iv = [1] * (3*d+3)
    for i in range(1, 3*d+3):
        iv[i] = ti[i] * t[i-1] % P

    ###
    g = [inv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = fg[i] * fa[d+i+1] % P * fainv[i] % P

    ###
    g = [iv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d+1):
        h[i] = h[i] * (fg[i] * t[d+i+1] % P * ti[i] % P) % P

    ###
    g = [iv[i] for i in range(d+2, 3*d+3)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = h[i+d+1] * (fg[i] * t[2*d+i+2] % P * ti[d+i+1] % P) % P

    return h

# Create a table of the factorial of the first v+2 multiples of v, i.e., [0!, v!, 2v!, ..., (v(v+1))!]
def create_table(v):
    s = 1
    X = [1, v+1]
    while s < v:
        X = grow(s, v, X)
        s *= 2

    table = [1]
    for x in X:
        table.append(table[-1] * x % P)
    return table

def fact(i, table):
    a = table[i//v]
    for j in range(i//v*v+1, i+1):
        a = a * j % P
    return a

N, A, B = map(int, input().split())
P = 10**9+7

v = 1 << (N.bit_length() + 1) // 2
fa = [1] * (2*v+2)
fainv = [1] * (2*v+2)
for i in range(2*v+1):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(2*v+1)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P
inv = [0] * (2*v+2)
for i in range(1, 2*v+2):
    inv[i] = fainv[i] * fa[i-1] % P

T = create_table(v)
C = lambda n, k: fact(n, T) * pow(fact(k, T) * fact(n-k, T), P-2, P) % P
 
print((pow(2, N, P) - 1 - C(N, A) - C(N, B)) % P)

Measured memory_bytes: 153960
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scanf("%d", &n)
	fmt.Scanf("%d", &k)

	prices := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &prices[i])
	}

	sort.Ints(prices)

	var answer int
	for i := 0; i < k; i++ {
		answer += prices[i]
	}

	fmt.Println(answer)
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> V(N);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    while (A--) {
      int x, y;
      cin >> x >> y;
      V.at(i).push_back({--x, y});
    }
  }

  int ans = 0;
  for (int bit = 0; bit < 1 << N; bit++) {
    vector<int> tmp(N, -1);
    for (int i = 0; i < N; i++) {
      if (bit >> i & 1) {
        for (auto [x, y] : V.at(i)) {
          if ((bit >> x & 1) ^ y) goto NG;
        }
      }
    }
    ans = max(ans, __builtin_popcount(bit));
    NG:;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3612
/**
 *      ABC 50 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-07 20:39:30
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int INF = 1000000000 + 7;

    int N; cin >> N;
    int A[N] = {};
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    int count[N] = {};

    for (int i = 0; i < N; ++i) {
        ++count[A[i]]; 
    }

    if (N % 2 == 0){
        for (int i = 0; i < N / 2; ++i) {
            if (count[2 * i + 1] != 2){
                cout << 0 << endl; return 0;
            }
        }
    }
    else if (N % 2 == 1){
        if (count[0] != 1){
            cout << 0 << endl; return 0;
        }
        for (int i = 0; i < N / 2; ++i) {
            if (count[2 * i + 2] != 2){
                cout << 0 << endl; return 0;
            } 
        }
    }
    int answer = 1;

    int power = N / 2;

    for (int i = 0; i < power; ++i) {
        answer = (answer % INF) * 2;        
    }

    cout << answer % INF << endl;

    return 0;

}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll x,a; cin >> x >> a;
  if(x % 500 <= a) cout <<"Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
bool isPrime(int a);

int main()
{
	int q;
	cin >> q;
	vector<int> l(q), r(q);
	rep(i, q)cin >> l[i] >> r[i];
	vector<int> cms(100000, 0);
	for (int i = 3; i < 100000; i+=2)
	{
		if (isPrime(i) && isPrime((i+1)/2))
		{
			cms[i] = cms[i - 2] + 1;
		}
		else
		{
			cms[i] = cms[i - 2];
		}
	}
	rep(i, q)
	{
		if (l[i]==1)
		{
			co(cms[r[i]]);
		}
		else
		{
			co(cms[r[i]] - cms[l[i] - 2]);
		}
	}
	return 0;
}

bool isPrime(int a)
{
	for (int i = 2; i*i <= a; i++)
	{
		if (a%i==0)
		{
			return false;
		}
	}
	return true;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const MOD = 1e9 + 7;
ll const oo = 8e18;
int const N = 2e5 + 100;
int const M = 1e6 + 100;

int main(){
#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}


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

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

  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(a.begin(), a.end());

  int max_num = a.at(n - 1);
  vector<bool> no_div(max_num + 1, false);
  for (auto num : a) {
    no_div.at(num) = true;
  }
  for (auto num : a) {
    if (no_div.at(num)) {
      int pnum = num + num;
      while (pnum <= max_num) {
        no_div.at(pnum) = false;
        pnum += num;
      }
    }
  }

  vector<int> count(max_num + 1);
  rep(i, n) {
    count.at(a.at(i))++;
  }

  rep(i, n) {
    if (count.at(a.at(i)) >= 2) {
      no_div.at(a.at(i)) = false;
    }
  }

  int ans = 0;
  rep(i, no_div.size()) {
    if (no_div.at(i)) {
      ans++;
    }
  }

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

Measured memory_bytes: 7948
from collections import Counter
N=int(input())
S=input()
l=list(S)
c=Counter(l)
l=c.most_common()
count=1
least=0
bin=[]
for i in range(len(l)):
    if l[i][1]>1:
        #most+=l[i][1]
        bin.append(1)
        count=count*(l[i][1]+1)
#        print("count",count)
    else:
        least+=1
count=count*2**least
ans=count-1
ans=ans%(10**9+7)
print(ans)


Measured memory_bytes: 4332
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int n,m,p;
  while(cin >> n >> m >> p, n || m || p){
	vector<int> x(n);
	int total = 0;
	
	for(int i = 0;i < n; i++){
	  cin >> x[i];
	  total += x[i];
	}
	
	total = total * (100 - p);
	if(x[m-1] == 0){
	  cout << 0 << endl;
	}else{
	  double tmp = total/x[m-1];
	  cout << (int)tmp << endl;
	}
  }

  return 0;
}



Measured memory_bytes: 2996
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int sum[1001];
int main()
{
    /*for(int i=1;i<=1000;i++)
        sum[i]=i+sum[i-1];*/
    int a,b;
    scanf("%d%d",&a,&b);
    int t=b-a;
    /*while(sum[t]<=b)
        t++;*/
    printf("%d\n",((1+t)*t)/2-b);
    return 0;
}


Measured memory_bytes: 256
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
void solve(){
	ll k,cur,i;
	cin>>k;
	cur=7;
	for(i=0;i<=(k+17);i++){
		if(cur%k == 0){
			cout<<i+1;
			return;
		}
//		cout<<cur<<endl;
		cur*=10;
		cur+=7;
		cur%=k;
	}
	cout<<-1;
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    cout<<(n+m)%24ll<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;cin >> a >> b;
    int ans=0;
    FOR(i,a,b+1){
        if(i/10000==i%10&&i/1000%10==i/10%10){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define int long long 
using ldb = long double;
using pa = pair < int, int >;
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 2e5 + 10;
const int LINF = LLONG_MAX;
int modpow(int x, int y){
    int ans=1;
    if(y==1){
        return x%MOD;
    }
    x=x % MOD;
    y=y % (MOD-1);
    while(y>0){
        if(y & 1){
            ans = (ans*x) %MOD;
        }
        x *= x;
        x = x % MOD;
        y >>= 1;
    }
    return ans;
}

int modinv(int x){
    return modpow(x,MOD-2);
}
int sub(int x, int y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}
int add(int x, int y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
int multiply(int a,int b){
    return (a*b)%MOD;
}
int ans[N];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    int final = 0;
    for(int i = k;i >=1;i--){
        int ways = k/i;
        ans[i] = modpow(ways,n);
        for(int j = 2;j*i <=k;j++){
            ans[i] = sub(ans[i],ans[i*j]);
        }
        final = add(final,multiply(ans[i],i));
    }
    cout << final << endl;
    
    return 0;
}
 

Measured memory_bytes: 4392
#include <iostream>
#include <math.h>

using namespace std;

static const int N = 1000000;
bool P[N+1];

void prime()
{
	int limit;

	for(int i=2; i<=N; i++)
	{
		P[i] = true;
	}

	limit = sqrt((double)N);
	for(int i=2; i<limit; i++)
	{
		if(P[i])
		{
			for(int j=(i<<1); j<=N; j+=i)
			{
				if(P[j])
				{
					P[j] = false;
				}
			}
		}
	}
}

int main(int argc, char** argv)
{
	int n, c;
	prime();
	
	while(cin >> n, n)
	{
		c = 0;
		if(P[n-2]) c++;

		for(int i=3; i<=n/2; i+=2)
		{
			if(P[i] && P[n-i])
			{
				c++;
			}
		}

		cout << c << endl;
	}

	return 0;
}

Measured memory_bytes: 0
def abc107_b():
    import numpy as np

    h, w = map(int, input().split())
    a = []
    for i in range(h):
        tmp = list(input())
        if not tmp == ["."] * w:
            a = np.append(a, tmp)
    a = a.reshape((-1, w))

    return a[:, np.any(a != np.array(["."] * w), axis=0)]

for row in abc107_b():
    print("".join(row))

Measured memory_bytes: 12504
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int main()
{
	int n, k, dp[N], A[N];
	cin >> n >> k;
	memset(dp, 0, sizeof(dp));
	dp[0] = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
		dp[A[i]] = 1;
	}
	for (int i = 2; i <= k; ++i)
	{
		if(dp[i] == 1)
			continue;
		int val = 1;
		for (int j = 0; j < n; ++j)
		{
			if(A[j] <= i)
			{
				val = (val & dp[i - A[j]]); 
			}
		}
		dp[i] = 1 - val;
	}
	if(dp[k] == 1)
		cout << "First";
	else
		cout << "Second";
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
n = int(input().strip())
an = [int(input().strip()) for i in range(n)]
san = sorted(an)
m_a = san[-1]
m_b = san[-2]

for i in range(n):
  if an[i] == m_a:
    print(m_b)
  else:
    print(m_a)

Measured memory_bytes: 14112
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n,m = m()

print(pow(n,m,10**9+7))


Measured memory_bytes: 6012
import java.util.*;
public class Main{
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[] A=new int[N];
		for(int i=0;i<N;i++){
		A[i]=sc.nextInt();
		}
		Arrays.sort(A);
		long[] maxSize=new long[N];
		maxSize[0]=A[0];
		int limit=1000000000;
		for(int i=1;i<N;i++){
			maxSize[i]=maxSize[i-1]+A[i];
			limit=i+1;
			if(maxSize[i]>1000000000){
				break;
			}
		}
		int can=0;
		for(int i=0;i<limit-1;i++){
			if(A[i+1]-maxSize[i]>maxSize[i]){
				can=i+1;
			}
		}
		
		System.out.println(N-can);

	}
 
}


Measured memory_bytes: 50700