akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>
using namespace std;

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getchar(char ch){
    if(ch=='A')return 1;
    else if (ch=='C')return 2;
    else if (ch=='G')return 3;
    else if (ch=='T')return 4;
    else return 0;
}

long long getkey(char str[]){
    long long sum=0,p=1;
    for (int i=0; i<strlen(str); i++) {
        sum+=p*(getchar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
    long long key,h;
    key=getkey(str);
    for (int i=0; ; i++) {
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h], str)==0)return 1;
        else if (strlen(H[h])==0)return 0;
    }
    return 0;
}
int insert(char str[]){
    long long key,h;
    key=getkey(str);
    for (int i=0; ; i++) {
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h], str)==0)return 1;
        else if (strlen(H[h])==0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int n,h;
    char str[L],com[9];
    for(int i=0;i<M;i++)H[i][0]='\0';
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>com>>str;
        
        if(com[0]=='i'){
            insert(str);
        }else{
            if (find(str)) {
                cout<<"yes"<<endl;
            }else{
                cout<<"no"<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17416
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

string s;
bool solve() {
  for (int i=1; i<s.length(); i++) {
    if (s[i-1] == s[i]) {
      cout << i << " " << i+1 << "\n";
      return true;
    }
  }
  for (int i=2; i<s.length(); i++) {
    if (s[i-2] == s[i]) {
      cout << i-1 << " " << i+1 << "\n";
      return true;
    }
  }
  return false;
}

int main() {
  cin >> s;
  if (!solve()) cout << -1 << " " << -1 << "\n";
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */
 
signed main(){
   IOS;
   int n; cin >> n;
   int ans = 1, roof = (int)1e18;
   rep(i,0,n){
      int x; cin >> x;
      if(x == 0){
         cout << "0\n";
         return 0;
      }
      else if (x == 1) continue;
      else{
         int y = roof/ans;
         if(x <= y) ans*=x;
         else ans = roof + 1;
      }
   }
   if(ans > roof) cout << "-1\n";
   else cout << ans << "\n";
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <iterator>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cmath>
#include <cstdlib>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

#define ALL(v) (v).begin(), (v).end()
#define endl "\n"
typedef long long int ll;

template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

int SumDigitValues(int x)
{
	int sum = 0;
	while (x)
	{
		sum += x % 10;
		x = x / 10;
	}

	return sum;
}

int Factorial(int n)
{
	if (n < 0) return 0;
	if (n == 0) return 1;
	return n * Factorial(n - 1);
}

int factorial(int n)
{
	if (n > 1)
	{
		return n * factorial(n - 1);
	}
	else
	{
		return 1;
	}
}

int gcd(int x, int y)
{
	if (y == 0)
		return x;
	else 
		return gcd(y, x % y);
}

vector<int> Divisors(int x)
{
	vector<int> divisors;
	divisors.push_back(1);
	for (int a = 2; a <= x; a++)
	{
		if (x % a == 0) divisors.push_back(a);
	}
	return divisors;
}

vector<int> CommonDivisors(int a, int b)
{
	vector<int> divisorsA = Divisors(a);
	vector<int> divisorsB = Divisors(b);
	vector<int> commonDivisors;
	set_intersection(divisorsA.begin(), divisorsA.end(), divisorsB.begin(), divisorsB.end(), std::back_inserter(commonDivisors));
	return commonDivisors;
}

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

	int p, q, r;
	cin >> p >> q >> r;

	priority_queue<int> pq;
	pq.push(p+q);
	pq.push(q+r);
	pq.push(r+p);
	pq.pop();
	pq.pop();
	cout << pq.top() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int d;
  cin >>d;
  
    if(d==25) cout << "Christmas" << endl;
    else if(d==24) cout << "Christmas Eve" << endl;
    else if(d==23) cout << "Christmas Eve Eve" <<endl;
    else cout << "Christmas Eve Eve Eve" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

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

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

int main(){
  int h, w;
  while(1){
    cin >> h >> w;
    if(h == 0 && w == 0){break;}
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	cout << "#";
      } 
      cout << "\n";
    }
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin>>N>>A>>B;
  
  int count=0;
  for(int i=1;i<=N;i++){
    int tmp=i/10000+i%10000/1000+i%1000/100+i%100/10+i%10;
     if(A<=tmp&&tmp<=B)count+=i;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include <cstdlib>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define  INF 0x3f3f3f3f
//__builtin_popcount
using namespace std;
//priority_queue
const ll MAX=100000;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}

ll F[100003];
ll Find(ll a)
{
    return F[a]<0?a:F[a]=Find(F[a]);
}
ll same(ll a,ll b)
{
    if(Find(a)==Find(b))return 1;
    return 0;
}
void up(ll a,ll b)
{
    ll x,y;
    x=Find(a);
    y=Find(b);//cout<<F[x]<<" "<<F[y]<<endl;
    if(x!=y)
        F[y]+=F[x],F[x]=y;


}
int ant[200003];
int a[200003];
int sum[200003];
int main()
{
 int t;
 int sum1=0;
 cin>>t;
 for(int i=1;i<=t;i++)
    cin>>a[i];
 for(int i=t;i>=1;i--)
  { int zz=0;
      for(int j=i;j<=t;j+=i)
      {
          zz+=sum[j];
      }
      if(zz%2!=a[i])
      {
          ant[sum1++]=i;
          sum[i]=1;
      }
  }cout<<sum1<<endl;
  for(int i=0;i<sum1;i++)
    cout<<ant[i]<<endl;
}





Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
    int n;
    map<int, int> cnt;
    cin >> n;
    REP(i, n)
    {
        int a;
        cin >> a;
        if (cnt.count(a))
        {
            cout << "NO" << "\n";
            return 0;
        }
        else
        {
            cnt[a] = 0;
        }
    }
    cout << "YES" << "\n";
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s, g1, g2;
    while(cin >> n >> m >> s >> g1 >> g2, n or m)
    {
        s--, g1--, g2--;
        vector<vector<ll>> cost(n, vector<ll>(n, INF));
        for(int i = 0; i < n; i++) cost[i][i] = 0;
        for(int i = 0; i < m; i++)
        {
            int a, b; ll c; cin >> a >> b >> c;
            a--, b--;
            cost[a][b] = c;
        }
        for(int k = 0; k < n; k++)
            for(int i = 0; i < n; i++)
                for(int j = 0; j < n; j++)
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        ll ans = INF;
        for(int k = 0; k < n; k++)
        {
            ans = min(ans, cost[s][k] + cost[k][g1] + cost[k][g2]);
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=15;
char s[maxn];
bool pd(char c)
{
	if(c<='Z'&&c>='A')return 1;
	else return 0;
}
int main()
{
	scanf("%s",s);
	bool flag=0;
	if(s[0]!='A'){printf("WA");return 0;}
	if(pd(s[1])||pd(s[strlen(s)-1])){printf("WA");return 0;}
	for(int i=0;i<strlen(s);i++)
	{
		if(2<=i&&i<=strlen(s)-1)
		{
			if(s[i]=='C'&&flag==1)
			{
				printf("WA");
				return 0;
			}
			else if(s[i]=='C')
			{
				flag=1;
			}
			else if(pd(s[i]))
			{
				printf("WA");
				return 0;
			}
		}	
	}
	if(flag==1)printf("AC");
	else printf("WA");
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

   ll a[n];

   rep(i, n){
       cin >> a[i];
       a[i]--;
   }

   if(k < 2*n){
       ll cnt = 0;
       ll next = 0;
       while(cnt < k){
           next = a[next];
           cnt++;
       }

       cout << next + 1 << endl;

       return 0;
   }
   
   bool visited[n] = {};

   ll next = 0;
   while(!visited[next]){
       visited[next] = true;
       next = a[next];
   }

   //nextまでの回数を図る
   ll pos = 0;
   ll cnt = 0;
   while(pos != next){
       pos = a[pos];
       cnt++;
   }

   //巡回を
   vector<ll> loop;
   rep(i, n)visited[i] = false;

   while(!visited[next]){
       visited[next] = true;
       loop.push_back(next);
       next = a[next];
   }

   k -= cnt;

   cout << loop[k % loop.size()]+1 << endl;


}

Measured memory_bytes: 5920
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s];i;i=e[i].nxt)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl

using namespace std;
typedef long long ll;

const int N = 2e5 + 10;

int sons[N];
int n,s,f;

int main(){
	si(n);
	repi(i,1,n-1){
		si(f);
		sons[f]++;
	}
	repi(i,1,n){
		cout<<sons[i]<<endl;
	}
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (13 <= A) {
    cout << B << endl;
    return 0;
  }
  if (6 <= A ) {
    cout << B / 2 << endl;
    return 0;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int x=1,y=1,md=0,big=1,small=1;

int MD(int a,int b){
    int c=1;
    
    while((c=a%b)!=0){
        a=b;
        b=c;
    }
    md=b;
    return md;
}

int main(void){
    // Your code here!
    scanf("%d %d",&x,&y);
    
    if(x<y){
        big=y;
        small=x;
    }else{
        big=x;
        small=y;
    }
    md = MD(big,small);
    printf("%d\n",md);
    
}



Measured memory_bytes: 2100
import bisect
n = int(input())
a = []
for i in range(n):
    a.append(float(input()))
a2 = sorted(a)
for i in a:
    kati = bisect.bisect_left(a2, i)
    hiki = bisect.bisect_right(a2, i) - kati - 1
    print(kati*3 + hiki)



Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output3.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n,k,i;
    cin>>n>>k;
    ll a[n+1];
    for(i=1;i<=n;i++)
        cin>>a[i];
    ll moves=0;
    ll now=1;
    int vis[n+1]={0};
    //vis[now]=1;
    vector<ll> v;
    while(!vis[now])
    {   v.pb(now);
        vis[now]=1;
        now=a[now];
        moves++;
    }
    if(k<v.size())
        cout<<v[k];
    else
    {
        // now ka pos chahiye
        ll pos;
        for(i=0;i<v.size();i++)
        {
            if(v[i] == now)
            {
                pos=i;
                break;
            }
        }
        vector<ll> vv;
        for(i=pos;i<v.size();i++)
            vv.pb(v[i]);
        k-=pos;
        k%=vv.size();
        cout<<vv[k];
    }
    return 0;
}


Measured memory_bytes: 9812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m), d(m-1, 0);
    rep(i, 0, m) cin >> x[i];
    sort(x.begin(), x.end());

    rep(i, 0, m-1) d[i] = x[i+1] - x[i];
    sort(d.begin(), d.end());

    ll ans = 0;
    rep(i, 0, max(0LL, m-n)) ans += d[i];
    cout << ans << endl; 
    return 0; 
}

Measured memory_bytes: 4652
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val V = nextDoubleList().sorted()
    val ans = V.reduce { a, b -> (a + b) / 2.0 }
    println(ans)
}

Measured memory_bytes: 39248
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define M 1000333
char Dir[M][14];


int getChar(char ch)
{
	if (ch == 'A') return 1;
	else if (ch == 'T') return 2;
	else if (ch == 'C') return 3;
	else if (ch == 'G') return 4;
	else return 0;
}

long long getKey(char str[])
{
	long long sum = 0,p=1,i=0;
	for (i = 0; i < strlen(str); i++)
	{
		sum += p * getChar(str[i]);
		p *= 4;
	}
	return sum;
}

long long find(char *str)
{
	long long loc = getKey(str);
	while (1)
	{
		loc = (loc + 1) % M;
		if (strcmp(Dir[loc], str) == 0)
			return -1;
		else if (strlen(Dir[loc]) == 0)
			return loc;
	}
}

void insert(char* str)
{
	long long loc = find(str);
	if (loc != -1)
	{
		strcpy(Dir[loc], str);
	}
}






int main()
{
	long long n,i;
	scanf("%lld", &n);
	char com[7] = { 0 };
	char data[15] = { 0 };
	for (i = 0; i < n; i++)
	{
		scanf("%s", com);
		scanf("%s", data);
		if (com[0] == 'i')
			insert(data);
		else
		{
			int ret=find(data);
			if (ret == -1)
				printf("yes\n");
			else
				printf("no\n");
		}
	}
	return 0;
}



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

int main() {
    string b;
    
    cin >> b;
    
    if (b == "A") {
        cout << "T" << endl;
    }
    else if (b == "T") {
        cout << "A" << endl;
    }
    else if (b == "C") {
        cout << "G" << endl;
    }
    else if (b == "G") {
        cout << "C" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
#define EPS 1e-10
struct P{
	double x,y;
	P(){}
	P(double xx,double yy){
		x=xx;
		y=yy;
	}
};
double add(double a,double b){
	if(fabs(a+b)<EPS*(fabs(a)+fabs(b)))return 0.0;
	return a+b;
}

int n;
int x[51],y[51];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&x[i],&y[i]);
	}
	if(n%2==1){
		printf("NA\n");
	}else{
		P p=P((x[0]+x[n/2])/2.0,(y[0]+y[n/2])/2.0);
		bool flag=true;
		for(int i=1;i<n/2;i++){
			P p2=P((x[i]+x[i+n/2])/2.0,(y[i]+y[i+n/2])/2.0);
			if(add(p.x,-p2.x)!=0.0 || add(p.y,-p2.y)!=0.0)flag=false;
		}
		if(flag)printf("%.9f %.9f\n",p.x,p.y);
		else printf("NA\n");
	}
}

Measured memory_bytes: 1064
#include<cstdio>
int vis[1000005];
int have[1000005];

int sieve(int n){
    int ok = 1;
    vis[1] = 0;
    for(int i = 2; i <= n; i++){
        if(have[i]>1) ok = 0;
        if(vis[i]==0){
            int cnt = have[i];
            for(int j = 2*i; j <= n; j+=i){
                vis[j] = 1;
                cnt += have[j];
            }
            if(cnt>1) ok = 0; 
        }
    }
    return ok;
}

int gcd(int a,int b){ return b?gcd(b,a%b):a; }

int main(){
    int n;
    scanf("%d",&n);
    int allG = 0;
    for(int i = 1; i <= n; i++){
        int u;
        scanf("%d",&u);
        have[u]++;
        allG = gcd(allG,u);
    }
    if(sieve(1000000)) printf("pairwise coprime\n");
    else{
        if(allG==1) printf("setwise coprime\n");
        else printf("not coprime\n");
    }
    
    return 0;
}


Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000

int main()
{
    int H,W;cin >> H >> W;
    vector<vector<int>> magic(10,vector<int> (10,INF));
    for (int i=0;i<10;i++)
    {
        for (int j=0;j<10;j++)
        {
            cin >> magic[i][j];
        }
    }
    for (int k=0;k<10;k++)
    {
        for (int i=0;i<10;i++)
        {
            for (int j=0;j<10;j++)
            {
                magic[i][j]=min(magic[i][j],magic[i][k]+magic[k][j]);
            }
        }
    }
    int a,ans=0;
    for (int i=0;i<H;i++)
    {
        for (int j=0;j<W;j++)
        {
            cin >> a;
            if (a!=-1) ans+=magic[a][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;
vector<ll> adj[100009];
ll n,k,ans,x,y;
ll fact[100009],inv[100009],finv[100009];

  void f()
  {
      fact[0]=fact[1]=inv[0]=inv[1]=finv[0]=finv[1]=1;
     for(ll i=2;i<100009;i++)
    {
      fact[i]=fact[i-1]*i%mod;
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
      finv[i]=finv[i-1]*inv[i]%mod;
    }
  }

ll dfs(ll cur,ll par)
{ 
  if(k-1<adj[cur].size())
    return 0;
  else
  {
    ll x=fact[k-2]*finv[k-1-adj[cur].size()]%mod;
    for(auto i:adj[cur])
    {
      if(i!=par)
      x=x*dfs(i,cur)%mod;
    }
    return x;
  }
}
int main()
{ 
    fast;
   cin>>n>>k;
   ans=k;
   f();
    for(ll i=0;i<n-1;i++)
    {
      cin>>x>>y;
      x--,y--;
      adj[x].pb(y);
      adj[y].pb(x);
    }

   if(k-1<adj[0].size())
    ans=0;
  else
  {
    ans=ans*fact[k-1]%mod*finv[k-1-adj[0].size()]%mod;
    for(auto i:adj[0])
      ans=ans*dfs(i,0)%mod;
  }
  cout<<ans<<endl;      
  }

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

string A, B, C;
int dp[51][2];

int rec(int idx, bool up)
{
  if(idx == -1) return(!up);
  if(~dp[idx][up]) return(dp[idx][up]);
  int ret = 0;
  for(int i = idx == 0; i <= 9; i++) {
    if(A[idx] == i || A[idx] == '?') {
      for(int j = idx == 0; j <= 9; j++) {
        if(B[idx] == j || B[idx] == '?') {
          if((idx != 0 || (i + j + up) % 10 != 0) && (C[idx] == (i + j + up) % 10 || C[idx] == '?')) {
            (ret += rec(idx - 1, (i + j + up) >= 10)) %= mod;  
          }
        }
      }
    }
  }
  return(dp[idx][up] = ret);  
}

int main()
{
  while(cin >> A, A != "0") {
    cin >> B;
    cin >> C;
    for(int i = 0; i < A.size(); i++) if(isdigit(A[i])) A[i] -= '0';
    for(int i = 0; i < B.size(); i++) if(isdigit(B[i])) B[i] -= '0';
    for(int i = 0; i < C.size(); i++) if(isdigit(C[i])) C[i] -= '0';
    memset(dp, -1, sizeof(dp));
    cout << rec(A.size() - 1, 0) << endl;
  }
}

Measured memory_bytes: 1188
def read_input():
    n = int(input())
    dlist = list(map(int, input().split()))
    return n, dlist


def submit():
    n, dlist = read_input()
    dlist.sort()

    mid = n // 2  # 0 ~ mid-1までがABC, mid~n-1がARC
    min_arc_idx = mid
    max_abc_idx = mid - 1

    print(dlist[min_arc_idx] - dlist[max_abc_idx])
    return


if __name__ == '__main__':
    submit()


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            int k = upper_bound(a.begin(), a.end(), a[i] - a[j]) - a.begin();
            ans += max(j - k, 0);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {

  int num;
  cin >> num;
  
  int a=0, b=num;
  while(b>0){
    a += b % 10;
    b /= 10;
  }
  
  if(num % a == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;

}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

vector<ll> v;

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

  ll q, h, s, d, n;
  cin >> q >> h >> s >> d;
  cin >> n;
  /*
  ll mini = d;
  if(q*8 < d) mini = q;
  if(h*4 < mini) mini = h;
  if(s*2 < mini) mini = s;
  */
  cout << n/2 * min(min(q*8, d), min(4*h, 2*s)) + (n%2)*min(q*4, min(2*h, s)) << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main(){
    string s;
    ll k;
    cin >> s;
    cin >> k;
    string ans ="1";
    int cnt=1;
    int ite;
    for (auto i:s){
        if(i!='1'){
            ans = i;
            ite = cnt;
            break;
        }
        cnt++;
    }
    if(k>=ite) cout << ans << endl;
    else cout << '1' << endl;
    return 0;
}

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

int main(){
  int N;
  bool counter = false;
  scanf("%d",&N);
  for(int i = 0; i < 25; ++i){
    for (int j = 0; j < 25; ++j){
      if ((7*i + 4*j) == N) {
        counter = true;
        break;
      }
      if(counter) break;
    }
  }
  if (counter) printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <atcoder/convolution>

using namespace std;
using namespace atcoder;
 
int main() {
  int n, m;
  cin >> n >> m;

  vector<int> a(n), b(m);
  for(int& e: a) cin >> e;
  for(int& e: b) cin >> e;

  for(int& e: convolution(a, b)) cout << e << endl;

  return 0;
}


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

void solve(){
	long long x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	if(x >= 0) {
		long long y = x / d;
		if(y >= k){
			cout << x - d * k << '\n';
			return;
		}
		else{
			long long temp = x - y * d;
			long long rem = k - y;
			if(rem & 1) cout << abs(temp - d) << '\n';
			else cout << abs(temp) << '\n';
		}
	}
}

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

	int t = 1;
	while(t--) solve();
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string S, T; cin >> S >> T;
  
  string S_rot;
  S_rot = S + S;
  
  if ((int)S_rot.find(T) == -1)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

void solve()
{
	multiset<int> ms;
	int n;
	while(cin >> n)
	{
		ms.insert(n);
	}
	int max = 0;
	for(int i = 1; i < 101; ++i)
	{
		if(max < ms.count(i))
		{
			max = ms.count(i);
		}
	}
	for(int i = 1; i < 101; ++i)
	{
		if(max == ms.count(i))
		{
			cout << i << endl;
		}
	}
}

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n, a;
	cin >> n >> a;
	if (n % 500 <= a) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>
#include <bitset>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[110000][3];

int main(){
	long long int N, K, R, S, P;
	cin >> N >> K >> R >> S >> P;
	string T;
	cin >> T;
	for(int i = 0; i < N; i++){
		if(i < K){
			if(T[i] == 'r'){
				DP[i][2] += P;
			}
			if(T[i] == 's'){
				DP[i][0] += R;
			}
			if(T[i] == 'p'){
				DP[i][1] += S;
			}
		}else{
			DP[i][0] = max(DP[i - K][1], DP[i - K][2]);
			DP[i][1] = max(DP[i - K][0], DP[i - K][2]);
			DP[i][2] = max(DP[i - K][1], DP[i - K][0]);
			if(T[i] == 'r'){
				DP[i][2] += P;
			}
			if(T[i] == 's'){
				DP[i][0] += R;
			}
			if(T[i] == 'p'){
				DP[i][1] += S;
			}
		}
	}
	long long int ans = 0;
	for(int i = N - 1; i > N - K - 1; i--){
		ans += max(DP[i][0], max(DP[i][1], DP[i][2]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        string s;
        map<string, int> mp;
        for (int i = 0; i < n; ++i)
        {
            cin >> s;
            mp[s]++;
        }
        int ma = 0;
        for (auto &i : mp)
            ma = max(ma, i.second);
        for (auto &i : mp)
        {
            if (ma == i.second)
                cout << i.first << "\n";
        }
    }
}

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

int main(){
  string s;
  cin >>s;
  rep(i,s.size()){
    if(s[i]=='?') s[i]='D';
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 3756
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

// N, E, S, W
const int dx[4] = { 1, 0, -1, 0};
const int dy[4] = { 0, 1, 0, -1};

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;

//==============================================
int v, e, turn = 1;
vvi G;
vi visitTurn, parent, lowest;

vb color;

void dfs (int u, int prev) {
	visitTurn[u] = lowest[u] = turn++;

	color[u] = true;

	for (int next : G[u]) {

		if (!color[next]) {

			parent[next] = u;

			dfs(next, u);
			lowest[u] = min(lowest[u], lowest[next]);
		} else if (next != prev) {
			lowest[u] = min(lowest[u], visitTurn[next]);
		}
	}

}


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

	cin >> v >> e;

	G.resize(v);

	visitTurn.resize(v);
	parent.resize(v);
	lowest.resize(v);

	color.resize(v);

	REP(i, e) {
		int s, t;
		cin >> s >> t;

		G[s].push_back(t);
		G[t].push_back(s);
	}

	dfs(0, -1);

	set<int> st;
	int np = 0;
	REP2(i, 1, v) {
		int p = parent[i];
		if (p == 0) {
			np++;
		} else if (visitTurn[p] <= lowest[i]) {
			st.insert(p);
		}
	}

	if (np > 1) st.insert(0);

	for (int val : st) cout << val << "\n";
	return 0;
}

Measured memory_bytes: 4716
a,b=(int(x) for x in input().split())
a_1=int(a*12.5+0.999999)
a_2=int((a+1)*12.5)
list_a = []
for i in range(a_1,a_2):
	list_a.append(i)

b_1=int(b*10+0.999999)
b_2=int((b+1)*10)
list_b = []
for i in range(b_1,b_2):
	list_b.append(i)
li_a_b = set(list_a) & set(list_b)
if len(li_a_b) ==0:
	print(-1)
else:
	print(min(li_a_b))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n,a,b,c;
string s[100005];
char ans[100005];
signed main()
{
	cin>>n>>a>>b>>c;
	for(int i=1;i<=n;i++)
		cin>>s[i];
	s[n+1]+="AB";
	for(int i=1;i<=n;i++)
	{
		if(s[i]=="AB")
		{
			if(a<b)a++,b--,ans[i]='A';
			else if(a>b)b++,a--,ans[i]='B';
			else
			{
				if(!a)
				{
					cout<<"No";
					return 0;
				}
				if(s[i+1]==s[i]||s[i+1]=="AC")
				{
					a++,b--;
					ans[i]='A';
				}
				else
				{
					a--,b++;
					ans[i]='B';
				}
			}
		}
		else if(s[i]=="BC")
		{
			if(c<b)c++,b--,ans[i]='C';
			else if(c>b)b++,c--,ans[i]='B';
			else
			{
				if(!b)
				{
					cout<<"No";
					return 0;
				}
				if(s[i+1]==s[i]||s[i+1]=="AC")
				{
					c++,b--;
					ans[i]='C';
				}
				else
				{
					c--,b++;
					ans[i]='B';
				}
			}
		}
		else
		{
			if(a<c)a++,c--,ans[i]='A';
			else if(a>c)c++,a--,ans[i]='C';
			else
			{
				if(!a)
				{
					cout<<"No";
					return 0;
				}
				if(s[i+1]==s[i]||s[i+1]=="BC")
				{
					c++,a--;
					ans[i]='C';
				}
				else
				{
					c--,a++;
					ans[i]='A';
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
}

Measured memory_bytes: 6856
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a=0;cin>>n;
  if(n==10||n==100||n==1000||n==10000||n==100000)cout<<10<<endl;
  else{
    while(n>0){
      a+=n%10;
      n/=10;
    }
    cout<<a<<endl;
  }
}
      

Measured memory_bytes: 256
n= int(input())
s = str(input())

r = set()
g = set()
b = set()
for i in range(n):
    if s[i]=="R":
        r.add(i)
    elif s[i]=="G":
        g.add(i)
    else:
        b.add(i)

score = len(r)*len(g)*len(b)
for i in r:
    for j in g:
        dist=abs(j-i)
        if (i>j):
            bi = i+dist
            if bi in b:
                score -=1
            bi = j-dist
            if bi in b:
                score -=1
        else:
            bi = j+dist
            if bi in b:
                score-=1
            bi = i-dist
            if bi in b:
                score-=1
        if((i+j)%2==0 and (i+j)/2 in b):
            score-=1
# print(count_)
print(score)

Measured memory_bytes: 9520
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    ll ans = 0;
    bool used[100002]{0};
    for(int i = 0; i < n; i++){
        if(i >= k && t[i] == t[i - k] && used[i - k]) continue;
        used[i] = true;
        if(t[i] == 'r') ans += p;
        if(t[i] == 's') ans += r;
        if(t[i] == 'p') ans += s;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
h, n = map(int, input().split())

f_inf = float("inf")
dp = [f_inf] * (h + 1)
dp[0] = 0
for i in range(n):
    a, b = map(int, input().split())
    for j in range(h):
        next_j = min(j + a, h)
        dp[next_j] = min(dp[next_j], dp[j] + b)

print(dp[h])

Measured memory_bytes: 54364
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mkp make_pair
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 150005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll H, W, D;
ll a[400][400];
ll Q;
ll l[MAX], r[MAX];
ll cost[MAX];

int main(void) {
    ll i, j;
    cin >> H >> W >> D;
    P pos[MAX];
    for(i=0; i<H; i++) {
        for(j=0; j<W; j++) {
            cin >> a[i][j];
            pos[a[i][j]]=mkp(i, j);
        }
    }
    
    for(i=1; i<=D; i++) {
        for(j=i; j+D<=H*W; j+=D) {
            cost[j+D]=cost[j]+abs(pos[j].first-pos[j+D].first)+abs(pos[j].second-pos[j+D].second);
        }
    }
    
    
    cin >> Q;
    for(i=0; i<Q; i++) {
        cin >> l[i] >> r[i];
    }
    
    for(i=0; i<Q; i++) {
        pr(cost[r[i]]-cost[l[i]]);
    }
    
    
    
}




















Measured memory_bytes: 7424
from subprocess import*
call(('pypy3','-c',"""
n,a,*x=map(int,open(0).read().split())
x=[0]+x
dp=[[[0]*(50*n+1)for j in range(n+1)]for i in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  dp[i][0]=dp[i-1][0]
  for j in range(1,n+1):
    for k in range(1,50*n+1):
      dp[i][j][k]=dp[i-1][j][k]
      if k-x[i]>=0:
        dp[i][j][k]+=dp[i-1][j-1][k-x[i]]
ans=0
for i in range(1,n+1):
  j=i*a
  if j<50*n+2:
    ans+=dp[-1][i][j]
print(ans)
"""))

Measured memory_bytes: 97076
// https://atcoder.jp/contests/abc122/tasks/abc122_b

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <regex>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

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

#define EPS (1e-7)
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

vector<string> search(string const &text, regex const &re) {
    vector<string> result;

    auto iter = text.cbegin();
    auto end = text.cend();

    smatch m;

    while (regex_search(iter, end, m, re)) {
        result.push_back(m.str());
        iter = m[0].second;
    }

    return result;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int ans = 0;
    cin >> s;
    regex re("[ACGT]+");

    auto result = search(s, re);
    for (auto &elem : result) {
        // cout << elem << endl;
        int len = elem.length();
        if (len > ans) {
            ans = len;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int maxCoord (int a[], int n) {
    int max = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > max) max = a[i];
    }
    return max;
}

int minCoord (int a[], int n) {
    int min = 1000;
    for (int i = 0; i < n; i++) {
        if (a[i] < min) min = a[i];
    }
    return min;
}

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

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

    int max = maxCoord(a, n);
    int min = minCoord(a, n);

    cout << max - min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[10];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    int sum = 0;
    for (int i=1; i<3; i++) {
        sum += a[i] - a[i-1];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s_list = sorted([int(input()) for _ in range(n)])

    sum_s=sum(s_list)
    if sum_s % 10 != 0:
        print(sum_s)
    else:
        for s in s_list:
            if s % 10 != 0:
                print(sum_s - s)
                break
        else:
            print(0)


if __name__ == "__main__":
    main()


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

int main(){
  int N,K;
  cin >> N >> K;
  double sum=0;
  double P=1;
  for(int i=1;i<=N;i++){
    P=1;
    int m=1;//2jou sare te iku kazu dayo
    while(i*m < K){
      P = P/2;
      m = m*2;
    }
    sum = sum + P/N;
  }
  cout << fixed << setprecision(12);
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, 0, h) cin >> s[i];

    vllll dp(h + 1, vll(w + 1, INF));

    dp[1][1] = (s[0][0] == '#') ? 1 : 0;
    rep(i, 1, h + 1)
    {
        rep(j, 1, w + 1)
        {
            if (i == 1 && j == 1)
                continue;
            if (i - 2 >= 0 && s[i - 1][j - 1] == '#' && s[i - 2][j - 1] == '.')
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
            else
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            if (j - 2 >= 0 && s[i - 1][j - 1] == '#' && s[i - 1][j - 2] == '.')
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
            else
                dp[i][j] = min(dp[i][j], dp[i][j - 1]);
        }
    }
    cout << dp[h][w] << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int MOD = 1000000007;

	public static void main(String[] args) {
		int N = sc.nextInt();
		long[][][] dp = new long[N + 1][N + 1][N + 1];
		dp[0][0][0] = 1;
		int idx = 0;
		for (int i = 0; i < N; ++i) {
			char v = sc.next().charAt(0);
			if (v == '-') continue;
			++idx;
			if (v == 'D') {
				for (int j = 0; j < idx; ++j) {
					for (int k = 1; k < idx; ++k) {
						dp[idx][j][k] += dp[idx - 1][j][k] * j;
						if (j > 0) dp[idx][j - 1][k - 1] += dp[idx - 1][j][k] * j * k;
					}
				}
			} else {
				for (int j = 0; j < idx; ++j) {
					for (int k = 0; k < idx; ++k) {
						dp[idx][j + 1][k + 1] += dp[idx - 1][j][k];
						dp[idx][j][k] += dp[idx - 1][j][k] * j;
					}
				}
			}
			for (int j = 0; j < idx; ++j) {
				for (int k = 0; k < idx; ++k) {
					dp[idx][j][k] %= MOD;
				}
			}
		}
		System.out.println(dp[idx][0][0]);
	}
}

Measured memory_bytes: 134456
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();

		Long a[] = new Long[5];

		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		long btl = a[0];

		long r = N/btl;

		if (btl == 1) {
			System.out.println(r+4);
			return;
		}

		System.out.println(r+5);

	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int s,w;cin>>s>>w;
	if (w >= s){
		cout << "unsafe" << endl;
	}
	else{
		cout << "safe" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
class Node():
    def __init__(self, node_id, left, right):
        self.node_id    =   node_id
        self.left       =   left
        self.right      =   right

    def pre_order_search(self):
        l = self.left
        r = self.right
        print("",self.node_id, end="")
        if l != -1:
            tree[l].pre_order_search()
        if r != -1:
            tree[r].pre_order_search()

    def in_order_search(self):
        l = self.left
        r = self.right
        if l != -1:
            tree[l].in_order_search()
        print("",self.node_id, end="")
        if r != -1:
            tree[r].in_order_search()

    def post_order_search(self):
        l = self.left
        r = self.right
        if l != -1:
            tree[l].post_order_search()
        if r != -1:
            tree[r].post_order_search()
        print("",self.node_id, end="")

n = int(input())
tree = [None for i in range(n)]
root_set = set(range(n))

for i in range(n):
    node_id, left, right = map(int, input().split())
    tree[node_id] = Node(node_id, left, right)
    root_set -= set([left, right])
root = root_set.pop()

print("Preorder")
tree[root].pre_order_search()
print("")

print("Inorder")
tree[root].in_order_search()
print()

print("Postorder")
tree[root].post_order_search()
print()

Measured memory_bytes: 7848
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
INL=list(map(float, LS()))
DP=[0.0]*(N+1)
DP[0]=1.0

for p in INL:
    for i in reversed(range(N)):
        DP[i+1] = DP[i+1]*(1.0-p) + DP[i]*p

# print(DP)
print(DP[N//2+1])

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

using namespace std;

typedef long long ll;

int main()
{
    int n, k;

    cin >> n >> k;

    ///string money = to_str(n);
    deque<int> no(k);

    for(int i = 0; i < k; i++)
    {
        cin >> no[i];
    }

    for(int i = n; ; i++)
    {
        int temp = i;

        bool found = true;

        while(temp > 0)
        {
            int d = temp % 10;
            temp /= 10;

            for(int var : no)
            {
                if(d == var)
                {
                    found = false;
                    temp = 0;

                    break;
                }
            }
        }

        if(found == true)
        {
            cout << i << endl;

            break;
        }
    }

    return 0;
}



Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
int main(){
	ll n;cin>>n;
	ll ans=0;
	for(ll i=1;i*i<=n;i++){
		if(n%i!=0)continue;
		ll t=n/i; t--;
		if(i<t)ans+=t;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256