akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC084C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            
            int[] C = new int[N];
            int[] S = new int[N];
            int[] F = new int[N];
            for (int i = 0; i < N - 1; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                C[i] = line[0];
                S[i] = line[1];
                F[i] = line[2];
            }

            for(int j = 0; j < N - 1; j++)
            {
                int ans = 0;
                for (int i = j; i < N - 1; i++)
                {
                    if (ans <= S[i]) ans = S[i];
                    else
                    {
                        int n = (ans - S[i] - 1) / F[i] + 1;
                        ans = S[i] + n * F[i];
                    }
                    ans += C[i];
                }
                Console.WriteLine(ans);
            }
            Console.WriteLine(0);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13396
import math

n, q = map(int, input().split(" "))
s = input()

lrL = [list(map(int, input().split(" "))) for _ in range(q)]

li = [0] * n
mx = 0
for i in range(n - 1):
    if s[i] == "A" and s[i + 1] == "C":
        mx += 1
    li[i + 1] = mx

for l, r in lrL:
    print(li[r - 1] - li[l - 1])


Measured memory_bytes: 29780
a_500 = int(input().split()[0])
b_100 = int(input().split()[0])
c_50 = int(input().split()[0])
x = int(input().split()[0])

all_coins = []
count = 0

for a_n in range(a_500+1):
    for b_n in range(b_100+1):
        for c_n in range(c_50+1):
            total = 500*a_n + 100*b_n + 50*c_n
            if total == x:
                count += 1

print(count)

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n;
    cin >> n;
    ld res = 0;
    for(int i=1; i<=n; i++){
        ld x;
        cin >> x;
        res += 1/x;
    }
    cout << 1/res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N = in();
  int i = in();
  out(N-i+1);
}


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

int W,H,N;
int fid[20][20];

int main()
{
    while(scanf("%d%d",&W,&H),H + W)
    {
        //?????????
        for(int i = 0; i <= H; i++)
        {
            for(int j = 0; j <= W; j++)
            {
                fid[i][j] = 0;
            }
        }
        scanf("%d",&N);
        for(int i = 0; i < N; i++)
        {
            int x,y;
            scanf("%d%d",&x,&y);
            fid[y][x] = -1;
        }
        for(int i = 1; i <= H; i++)
        {
            for(int j = 1; j <= W; j++)
            {
                if(i == 1 && j == 1)fid[i][j] = 1;
                else
                {
                    if(fid[i][j] == -1)continue;
                    fid[i][j] = (fid[i - 1][j] != -1) * fid[i - 1][j] +
                                (fid[i][j - 1] != -1) * fid[i][j - 1];
                }
            }
        }
        printf("%d\n",fid[H][W]);
    }

}

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

int main()
{
     long double n,a[200005],i,j,k,sum=0,l,r,pre[200005]={0};
     cin>>n>>k>>i>>j;
     cout<<fixed<<setprecision(10)<<((n*k)/2);
     if(i==(n/2)&&j==(k/2))
        cout<<" 1";
    else
        cout<<" 0";
}


Measured memory_bytes: 256
A, B, C = list(map(int, input().split()))
K = int(input())
seisuu_list = [A, B, C]
seisuu_list.sort(reverse=True)
for _ in range(K):
    seisuu_list[0] *= 2

sum = seisuu_list[0]+seisuu_list[1]+seisuu_list[2]
print(sum)

Measured memory_bytes: 3060
def show (nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else :
            print(nums[i])
 
n=int(input())
nums=list(map(int,input().split()))
show(nums)
for i in range(1,n):
    v=nums[i]
    j=i-1
    while (j>=0 and nums[j]>v):
        nums[j+1]=nums[j]
        j-=1
    nums[j+1]=v
    show(nums)
 
    


Measured memory_bytes: 5984
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

// struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
// constexpr double PI  = acos(-1.0);
// constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
// inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i, 0, n) cin >> a[i];
    sort(all(a));
    VLL c;
    REP(i, 0, n - 1) {
        if (a[i] != a[i + 1])
            continue;
        c.push_back(a[i]);
        ++i;
    }
    reverse(all(c));
    if (c.size() >= 2)
        cout << c[0] * c[1] << endl;
    else
        cout << 0 << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,ans=2;//初始值包括n和n-1两种. 
	cin>>n;
	if(n==2) ans=1;//特判 
	for(ll k=2,i=n;k*k<=n;k++,i=n){ 
		while(i>=k) i%k?i%=k:i/=k;//这里是计算[2,sqrt[n]的情况. 
		if(i==1) {ans++;} 
		if((n-1)%k==0&&k*k!=(n-1)){ans++;} //这里是计算 [sqrt(n),n]n-1的因数情况，这里k*k!=(n-1)是去重 
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
e=input
a=''
for _ in[0]*int(e()):
 X,z=e(),[]
 for y in e():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=f'\n{len(z)}'
print(a[1:])


Measured memory_bytes: 5632
/*
    In the name of
        "ALLAH"
    And say "AL-HAMD-U-LILLAH"
*/

#include<bits/stdc++.h>
#define   ll   long long
#define   llu  unsigned long long
#define   _    printf("\n")
int      take() {
    int n;
    scanf("%d",&n);
    return n;

}
double  ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll     takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define  Int            take()
#define  Dnt            ttake()
#define  LL             takes()
#define  done           {return 0;}
#define  fr(i,x,n,a)    for(int i=x;i<=n;i+=a)
#define  FR(a,b,x)      for(int i=(a);i<=(b);i+=(x))
#define  rfr(i,x,n,a)   for(int i=x;i>=n;i--)
int      cas;
#define  print          printf("Case %d:",++cas)
#define  vi             vector<int>
#define  vl              vector<ll>
#define  pb              push_back
#define  pii             pair<int,int>
#define  vii             vector<pii>
#define  pll             pair<ll,ll>
#define  pil             pair<int,ll>
#define  pli             pair<ll,int>
#define  mk              make_pair
#define  fill(x,v)       memset(x,v,sizeof x)

using    namespace      std;

bool     approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define  STR            {struct info}
#define  dbg(x)         {cout<<"ekhane"<<x<<endl;}
#define  SS             second
#define  FF             first
#define  PQ             priority_queue
#define  great          greatest
#define  less           lesser
#define  mii            map<int,int>
#define  mil            map<int,ll>
#define  mll            map<ll,ll>
#define  msb            map<string,bool>
#define  V              vector
#define  M              100005
#define  pf             printf
//////////////////////////////////////////


int main(){

    int n = Int , m = Int , x = Int ;
    int arr[ n + 1 ] ;fill( arr , 0 ) ;
    fr( i , 1 , m , 1 ) arr[ Int ]++ ;
    int ans = 0 ;
    fr( i , x , n , 1 ){
        ans += arr[ i ] ;
    }
    int ans2 = 0 ;
    rfr( i , x , 1 , 1 ) ans2 += arr[ i ] ;
    pf("%d\n",min( ans , ans2 )) ;
    done;
}




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

int main()
{
    int n;

    cin >> n;

    for (int i = 1; i <= n; i++) {
        int x = i;

        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            do {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            } while (x);
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 1160
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int l[252521],r[252521],sl[252521],sr[252521],out[252521];
bool aru[252521];
int main()
{
	memset(l,0,sizeof(l));
	memset(r,0,sizeof(r));
	memset(sl,0,sizeof(sl));
	memset(sr,0,sizeof(sr));
	memset(aru,false,sizeof(aru));
	memset(out,-1,sizeof(out));
	
	int n,a;
	cin>>n;
	rep(i,n){
		cin>>a;a--;
		l[a]=i;r[a]=n-i-1;
		aru[a]=true;
		out[a]=i;
	}
	rep(i,n*n){
		if(i>0){
			sl[i]=sl[i-1];
			if(aru[i-1]) sl[i]++;
		}
		sl[i]+=l[i];
		if(sl[i]>i){
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=n*n-1;i>=0;i--){
		if(i<n*n-1){
			sr[i]=sr[i+1];
			if(aru[i+1]) sr[i]++;
		}
		sr[i]+=r[i];
		if(sr[i]>n*n-i-1){
			cout<<"No"<<endl;
			return 0;
		}
	}
	//rep(i,n) cout<<l[i]<<' '<<r[i]<<endl;
	int il=0,ir=n*n-1;
	rep(i,n*n){
		if(l[i]<1) continue;
		rep(j,out[i]){
			while(out[il]>=0) il++;
			//cout<<out[i]<<' '<<il<<endl;
			out[il]=out[i];il++;
		}
	}
	for(int i=n*n-1;i>=0;i--){
		if(r[i]<1) continue;
		rep(j,n-out[i]-1){
			while(out[ir]>=0) ir--;
			out[ir]=out[i];ir--;
		}
	}
	cout<<"Yes"<<endl;
	rep(i,n*n){
		printf("%d",out[i]+1);
		if(i<n*n-1) printf(" ");else printf("\n");
	}
}


Measured memory_bytes: 6400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 1000010;
const int inf = 0x0fffffff;
#define LL long long
const long long mod = 1000000007;

LL dp[maxn];
int main()
{
	int n, i, k;
	LL sum, ans;
	cin >> n;
	dp[1] = n;
	dp[2] = (1LL * n * n) % mod;
	//dp[2] = (1LL * (n - 1) * (n - 1)) % mod;
	sum = dp[1] + dp[2];
	sum %= mod;
	for (k = 3; k <= n; k ++)
	{
		dp[k] = (sum + mod - dp[k - 2] + 1LL * (n - 1)* (n - 1) + (n - k + 2) )% mod;
		sum = (sum + dp[k]) % mod; 
		//for (i = k - 3; i > 0; i --)
		//	dp[k] = (dp[k] + dp[i]) % mod;
	}
	//ans = 0;
	//for (k = 1; k <= n; k ++)
	//	ans = (ans + dp[k]) % mod;
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) cin>>v[i];
    sort(all(v));
    double s=v[0];
    for(ll i=1;i<n;i++) s=(s+v[i])/2;
    printf("%.5lf\n",s);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String[] s=new String[7];
		s[0]="thu";
		s[1]="fri";
		s[2]="sat";
		s[3]="sun";
		s[4]="mon";
		s[5]="tue";
		s[6]="wed";
		
		System.out.println(s[scan.nextInt()%7]);
	}
}



Measured memory_bytes: 26368
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1;i <= n;i++){
		if(i < 10){
			ans++;
		}else if(100 <= i && i < 1000){
			ans++;
		}else if(10000 <= i && i < 100000){
			ans++;
		}else{
		}
	}
	cout << ans;
	return 0;
}


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

#define INF 99999
#define N 10

//int graph[N][N] = {
//    {0, 2, 3, 0},
//    {2, 0, 1, 3},
//    {3, 1, 0, 1},
//    {0, 3, 1, 0}
//};
int minDistance(int dist[], int checkFlag[]) {
    int min = INF, min_index=-1;
    for (int v = 0; v < N; v++)
        if (checkFlag[v] == 0 && dist[v] <= min){
            min = dist[v];
            min_index = v;
        }
    return min_index;
}

void dijkstra(int graph[N][N], int s, int dist[N]) {
    int checkFlag[N];
    for (int i = 0; i < N; i++){
        dist[i] = INF;
        checkFlag[i] = 0;
    }
    dist[s] = 0;
    for (int i = 0; i < N-1; i++) {
        int u = minDistance(dist, checkFlag);
        checkFlag[u] = 1;
        for (int v = 0; v < N; v++)
            if (!checkFlag[v] && graph[u][v]
                && dist[u] != INF
                && dist[u]+graph[u][v] < dist[v])
                dist[v] = dist[u] + graph[u][v];
//        for (int i = 0; i < N; i++)
//            printf("%d -> %d\n", i, dist[i]);
    }
    
    
}

int main(){
    int H,W;
    cin >> H;
    cin >> W;
    
    int graph[10][10];
    int A[H][W];
    for(int i=0; i < 10; i++){
        for(int j=0; j<10; j++){
            cin >> graph[j][i];
        }
    }
    
    for(int i=0; i < H; i++){
        for(int j=0; j<W; j++){
            cin >> A[i][j];
        }
    }
    int dist[N];
    //calc all node min cost changing to 1
    dijkstra(graph, 1, dist);
    
    int cost = 0;
    for(int i=0; i < H; i++){
        for(int j=0; j<W; j++){
            if(A[i][j] == -1 || A[i][j] == 1)continue;
            
            cost += dist[(A[i][j])];
        }
    }
    cout << cost << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int, int> Point;

int main() {
    
    vector<Point> v(3);
    for(int i = 0; i < 3; ++i)
        cin >> v[i].x >> v[i].y;

    auto getDist = [] (Point A, Point B) {
        return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y));
    };

    double per = 0, area = 0, maxDist = 0;

    for(int i = 0; i < 3; ++i) {
        double d = getDist(v[i], v[(i + 1) % 3]);
        per += d;
        maxDist = max(maxDist, d);
    }

    for(int i = 0; i < 3; ++i) {
        area += v[i].x * v[(i + 1) % 3].y;
        area -= v[i].y * v[(i + 1) % 3].x;
    }

    area = fabs(area);
    area /= 2.0;

    double r = area / (per / 2);
    double ans = 0;
    
    ans = (r * maxDist) / (maxDist + 2 * r);

    cout.precision(15);
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <climits>
#include <deque>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;

#define pb push_back
#define fast_io {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define PI 3.141592653589793
#define mp make_pair

typedef long long ll;

const int MAXSIZE = 1e5+5;
const int MOD = 1e9+9;
const int INF = 1e9;

int a,b,c,d,e,f,w,s,m,de,as,am;
double x, mx;

int main(){
	fast_io;
	cin>>a>>b>>c>>d>>e>>f;
	for(int i=0; i<=f; i+=100*a){
		for(int j=0; j<=f; j+=100*b){
			for(int k=0; k<=f; k+=c){
				for(int l=0; l<=f; l+=d){
					w=i+j;
					s=k+l;
					m=w+s;
					if(m>f) continue;
					de=w/100;
					if(s>e*de) continue;
					if(m) x=100*(double)s/(double)m;
					else x=0;
					if(x>=mx){
						mx=x;
						am=m;
						as=s;
					}
				}
			}
		}
	}
	cout<<am<<' '<<as<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int N; 
string str[] = {"A", "C", "G", "T"};

bool ok(string s){
  if(s.substr(0, 3) == "AGC" || s.substr(1) == "AGC") return false;
  REP(i, 3){
    swap(s[i], s[i+1]);
    if(s.substr(0, 3) == "AGC" || s.substr(1) == "AGC") return false;
    swap(s[i], s[i+1]);
  }
  return true;
}

map<pair<int, string>, int> memo;
int dfs(int n, string s){
  if(n == N) return 1;
  if(memo[make_pair(n, s)] != 0) return memo[make_pair(n, s)];

  int ret = 0;
  REP(i, 4){
    if(ok(s+str[i])){
      (ret += dfs(n+1, (s+str[i]).substr(1))) %= MOD;
    }
  }
  return memo[make_pair(n, s)] = ret%MOD;
}

signed main() {
  cin >> N;

  cout << dfs(0, "TTT") << "\n";

  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <utility>
#include <cstdio>

using namespace std;

int main(void) {

    while (true) {
        int H, W;
        cin >> H >> W;

        if (H == 0 || W == 0) { break; }

        for (int w = 0; w < W; ++w) { putchar('#'); }
        putchar('\n');

        for (int h = 1; h < H - 1; ++h) {
            putchar('#');
            for (int w = 1; w < W - 1; ++w) {
                putchar('.');
            }
            putchar('#');
            putchar('\n');
        }

        for (int w = 0; w < W; ++w) { putchar('#'); }
        putchar('\n');
        putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 1108
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
const ll inf = 1001001001001001001;
int main(){
  ll N,K,i;scanf("%lld%lld",&N,&K);
  ll A[N],F[N];
  for(i=0;i<N;i++) scanf("%lld",&A[i]);
  for(i=0;i<N;i++) scanf("%lld",&F[i]);
  sort(A,A+N);
  ll l = -1,r = inf,mid,cnt;//(left,right]
  while(r - l > 1){
    mid = (l+r)/2;
    ll need[N];
    for(i=0;i<N;i++) need[i] = mid/F[i];
    sort(need,need+N);
    cnt = 0;
    for(i=0;i<N;i++) cnt += max(0LL,A[i]-need[i]);
    if(cnt <= K) r = mid;
    else l = mid;
  }
  printf("%lld\n",r);
}


Measured memory_bytes: 8512
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int D, N;
    cin >> D >> N;
  	if(N<100){
    if (D == 0)
    {
        cout << N << endl;
    }
    else if (D == 1)
    {
        cout << 100 * N << endl;
    }
    else
    {
        cout << 10000 * N << endl;
    }
    }else{
    if (D == 0)
    {
        cout << 101 << endl;
    }
    else if (D == 1)
    {
        cout << 100 * 101 << endl;
    }
    else
    {
        cout << 10000 * 101 << endl;
    }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,x;
	while(scanf("%d",&a),a!=-1){
		x = 1;
		while(a>=4*x){
			x*=4;
		}
		while(x){
			printf("%d",a/x);
			a-=x*(a/x);
			x/=4;
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 604
n = int(input())
a = [int(input()) for _ in range(n)]

count = 0
next_num = 0
flag = False
# print(a)


while count < n + 10:
    next_num = a[next_num]
    # print("next_num, count", next_num, count)
    if next_num != 2:
        next_num = next_num - 1
        count += 1
    else:
        count += 1
        flag = True
        break

print(count if flag else "-1")

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

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

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



    ll ans = n-k+1;
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=(n);i++)
#define Endl endl
/*
long long int gcd(long long int a,long long int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
*/



int main(){
	int n,a,b,ans=0,sum=0;
	char s[10000]={'\0'};
	cin>>n>>a>>b;
	//cin>>n>>a>>b;
	DEB(n)DEB(sum)END
	for(int i=1;i<=n;i++){
		sum=0;
		sprintf(s,"%d",i);
		for(int j=0;s[j]!='\0';j++){
			sum+=int(s[j]-'0');
		}
		if(a<=sum&&sum<=b){
			ans+=atoi(s);
		}
		DEB(ans)DEB(sum)DEB(s)END
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define gcj "Case #"
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

ll pow1(ll a, ll b, ll m = mod)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2, m);
		x *= x;
		x %= m;
		if (b%2)
		{
			x *= a;
			x %= m;
		}
		return x;
	}
}

template <class avgType>
avgType avg(avgType a, avgType b) {
	return (a + b)/2;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

int randInt() {
	return rng() % INT_MAX;
}

ll randLL() {
	return rng64() % LLONG_MAX;
}

vector< int > hashmods = {1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093};

ll n, ans[1100000], sum[1100000];

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

	ans[n] = n;
	sum[n] = n;
	for (int i = n-1; i >= 1; i--) {
		ans[i] = ans[i+1];

		ans[i] += ((n-1) * (n-1));
		int lef = min(n-1, n - (n - i - 1));

		ans[i] += sum[i+3];

		ans[i] += lef;

		ans[i] %= mod;
		sum[i] = (sum[i+1] + ans[i])%mod;
	}

	cout<<ans[1]<<endl;

	return 0;
}

Measured memory_bytes: 16640
// A - Libra
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	int L = a + b, R = c + d;
	if(L > R) puts("Left");
	else if(L < R) puts("Right");
	else puts("Balanced");
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi l(n);
  REP(i, n) cin >> l[i];

  ll cnt = 0;
  REP(i, n) {
    FOR(j, i+1, n) {
      FOR(k, j+1, n) {
        if(l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
        if(l[i] < l[j] + l[k] && l[j] < l[k] + l[i] && l[k] < l[i] + l[j]) cnt++;
      }
    }
  }
  cout << cnt << endl;

}








Measured memory_bytes: 3648
def point(A, B, C, K):
    S = 0
    if K <= A:
        S = K
        return S

    S = A
    K = K - A
    if K <= B:
        return S

    K = K - B
    return S - K


A, B, C, K = map(int, input().split())
print(point(A, B, C, K))


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int n; cin >> n;
	vector<char> s;
	char first; cin >> first;
	s.push_back(first);
	int j = 1;
	for (int i = 1; i < n; i++)
	{
		char in; cin >> in;
		if (in != s[j - 1])
		{
			s.push_back(in);
			j++;
		}
	}
	cout << j << '\n';
}


Measured memory_bytes: 512
using System;
using System.Text;

namespace ITP1_4_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();

            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                var op = input[1];
                if (op == "?")
                    break;
                var a = int.Parse(input[0]);
                var b = int.Parse(input[2]);
                switch (op)
                {
                    case "+":
                        sb.AppendLine((a + b).ToString());
                        break;
                    case "-":
                        sb.AppendLine((a - b).ToString());
                        break;
                    case "*":
                        sb.AppendLine((a * b).ToString());
                        break;
                    case "/":
                        sb.AppendLine((a / b).ToString());
                        break;
                }
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    ll n, m, x;
    cin >> n >> m >> x;
    vll c(n), ri(m, 0);
    vector<vll> a(n, vll(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
            ri[j] += a[i][j];
        }
    }

    rep(i,m)if(ri[i] < x){
        cout << -1 << endl;
        return 0;
    }
    
    ll res = 1e9;
    rep(i, 1 << n){
        ll tmp = 0;
        vll le(m, 0);
        rep(j,n)if(i >> j & 1){
            tmp += c[j];
            rep(k,m)le[k] += a[j][k];
        }
        bool ok = 1;
        rep(j,m)if(le[j] < x){
            ok = 0;
            break;
        }
        if(ok)res = min(res, tmp);
    }

    cout << res << endl;
    return 0;
}  

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cctype>

using namespace std;

vector<string> leaf;

vector<string> solve(string s){
  vector<string> a, b;
  if(s.size() == 5){
    a = vector<string>(1, leaf[s[1]-'0']);
    b = vector<string>(1, leaf[s[3]-'0']);
  }else if(isdigit(s[1])){
    a = vector<string>(1, leaf[s[1]-'0']);
    b = solve(string(s.begin()+3, s.end()-1));
  }else if(isdigit(s[s.size()-2])){
    a = solve(string(s.begin()+1, s.end()-3));
    b = vector<string>(1, leaf[s[s.size()-2]-'0']);
  }else{
    int x=0, k;
    for(int i=1; i<s.size(); ++i){
      if(s[i] == '(') ++x;
      if(s[i] == ')') --x;
      if(x == 0){ k=i+1; break; }
    }
    a = solve(string(s.begin()+1, s.begin()+k));
    b = solve(string(s.begin()+k+1, s.end()-1));
  }
  vector<string> data;
  for(int i=0; i<a.size(); ++i){
    for(int j=0; j<b.size(); ++j){
      string A(4,'0'), O(4,'0'), X(4,'0');
      for(int k=0; k<4; ++k){
	if(a[i][k]=='1' && b[j][k]=='1') A[k]='1';
	if(a[i][k]=='1' || b[j][k]=='1') O[k]='1';
	if(a[i][k] != b[j][k]) X[k]='1';
      }
      data.push_back(A);
      data.push_back(O);
      data.push_back(X);
    }
  }
  return data;
}

int main(){
  int n, x;
  string s;
  while(1){
    s.clear();
    leaf.clear();
    while(s.empty()) getline(cin, s);
    if(s == "END") break;
    cin >> n;
    leaf = vector<string>(n+1);
    for(int i=1; i<=n; ++i){
      string t(4,'0');
      for(int j=0; j<4; ++j){
	cin >> x;
	if(x == 1) t[j] = '1';
      }
      leaf[i] = t;
    }
    vector<string> data = solve(s);
    int ans=0;
    for(int i=0; i<data.size(); ++i){
      if(data[i] == "1111") ++ans;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1464
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=1000000007;
int n,m;
int main()
{
	cin>>n>>m;
	if(n>=m*2-1)cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd


def lcm(x, y):
    return (x * y) // gcd(x, y)


def solve():
    N = int(input())
    ans = int(input())
    for _ in range(N - 1):
        ans = lcm(ans, int(input()))
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 5048
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
	using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	double R; cin >> R;
	cout << 2 * PI * R << endl;
}

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


long long solve(vector<int>&a, int n, int m){

    priority_queue<int>Q;
    for(int i = 0; i < n; i++){
        Q.push(a[i]);
    }
    
    while(m > 0){
        int top_element = Q.top();
        Q.pop();
        top_element = top_element/2;
        Q.push(top_element);
        
        m -= 1;
    }
    long long solution = 0;
    while(!Q.empty()){
        
        solution += Q.top();
        Q.pop();
    }
    
    
    return solution;
    
    
}





int main(){
    
    int n, m;
    cin >> n >> m;
    vector<int>a(n);
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    cout << solve(a, n, m) << endl;
    
    
    return 0;
    
}

Measured memory_bytes: 4252
A,B,C,D=io.read("*n","*n","*n","*n")
flag=true

while flag do
  if C>B then C=C-B
  else
    print("Yes")
    flag=false
    break
  end
  if A>D then A=A-D
  else
    print("No")
    flag=false
  end
end

Measured memory_bytes: 2636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n&&n){
        int y;
        cin>>y;
        int idx,maxv=-1;
        for(int i=0,b,r,t;i<n;i++){
            cin>>b>>r>>t;
            double m=10000;
            if(t==1)m=m*(1+y*(r/100.0));
            else m=m*pow((1+(r/100.0)),y);
            if(maxv<m){
                maxv=m;
                idx=b;
            }
        }
        cout<<idx<<endl;
    }
}


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

int main(){
  int n, s; cin >> n;
  vector<int> S;
  for ( int i = 0; i < n; i++ ){
    cin >> s;
    S.push_back(s);
  }
  sort(S.begin(), S.end());
  reverse(S.begin(), S.end());
  int ans = 0;
  for ( int i = 0; i < S.size(); i++ ){
    if ( S[i] >= i+1 ) ans = i+1;
  }

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




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

int main() {
  int N = 3;
  vector<vector<int>> C(N, vector<int>(N));
  for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> C.at(i).at(j);

  string ans = "Yes";

  for (int i = 1; i < N; i++) {
    int tmp = C.at(i).at(0) - C.at(i - 1).at(0);
    for (int j = 1; j < N; j++) {
      if (C.at(i).at(j) - C.at(i - 1).at(j) != tmp) ans = "No";
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  cin >> N;

  vector<int> color(9);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    int b = a / 400;
    if (8 <= b) {
      color[8]++;
    } else {
      color[b]++;
    }
  }

  int min = 0;
  int max = 0;

  for (int i = 0; i < 8; i++) {
    if (color[i] != 0) {
      min++;
    }
  }

  max = min + color[8];

  if (min == 0) {
    min = 1;
  }

  cout << min << " " << max << endl;

}

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

int main() {
    long long n, p; scanf("%lld%lld", &n, &p);
    long long ans = 1;
    for (long long i = 2; i * i <= p; ++i) {
        int cnt = 0;
        while (p % i == 0) {
            cnt++;
            p /= i;
        }
        for (int j = 0; j < cnt / n; ++j) ans *= i;
    }
    if (p > 1) {
        for (int j = 0; j < 1 / n; ++j) ans *= p;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    char a;
    cin>>a;
    if(a>='a' && a<='z')
        cout<<"a";
    else
        cout<<"A";
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vii vector<ii>
#define vs vector<string>
#define si set<ll>
#define endl "\n"
#define pb push_back
#define x first
#define y second
//g++ -std=c++11 -Wall -Wextra -pedantic-errors main.cpp -o main
const int ms = 1e5 + 5, base = 31, mod = 1e5 + 7;
using namespace std;

int n, m;
vector<vi > adj;

int dp[ms];

int solve(int pos){
	//cout << pos << endl;
	if (dp[pos] != -1) return dp[pos];
	
	int best = 0;
	
	for (auto v : adj[pos])
		best = max(best, solve(v)+1);
	
	return dp[pos] = max(dp[pos], best);
}

int main(){
	//ios::sync_with_stdio(false), cin.tie(0);
	
	cin >> n >> m;
	adj.resize(n, vi());
	memset(dp, -1, sizeof(dp));
	
	for (int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		u--; v--;
		adj[u].pb(v);
	}
	int best = solve(0);
	
	
	for (int i = 0; i < n; i++){
		/*
		for (auto v : adj[i])
			cout << v+1 << " \n"[v == adj[i][adj[i].size()-1]];
		*/
		best = max(best, solve(i));
	}
	
	cout << best << endl;
	
	return 0;
}

/*
string str1, str2;
string dp[3001][3001];

int LCS(int i, int j){
	if (dp[i][j] != -1) return dp[i][j];

	if (i >= str1.size() || j >= str2.size())
		return dp[i][j] = 0;
	else if (str1[i] == str2[j])
		return dp[i][j] =  1 + LCS(i+1, j+1);
	else
		return dp[i][j] = max(LCS(i+1,j), LCS(i,j+1));
}

string LCS(int i, int j){
	if (dp[i][j] != "") return dp[i][j];

	if (i >= str1.size() || j >= str2.size())
		return dp[i][j] = "";
	else if (str1[i] == str2[j])
		return dp[i][j] =  str1[i] + LCS(i+1, j+1);
	else{
		string one = LCS(i+1,j), two = LCS(i,j+1);
		if (one.size() > two.size())
			return dp[i][j] = one;
		return dp[i][j] = two;
	}
}
*/

Measured memory_bytes: 8192
#include <cstdio>
#include <algorithm>
using namespace std;
long long n, ans, d, l[100005], r[1000005];
int main() {
	int i;
	scanf("%lld", &n);
	for(i=1; i<=n; i++) scanf("%lld%lld", l+i, r+i);
	sort(l, l+n+1);
	sort(r, r+n+1);
	for(i=0; ; i++) {
		d = l[n-i] - r[i];
		if(d>0) ans += d; else break;
	}
	printf("%lld", ans*2);
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>

using namespace std;

int main(void){
    long long N;
    long long D;
    long long count = 0;

    cin >> N >> D;

    for(int i = 0; i < N; i++){
        long long x, y;
        cin >> x >> y;
        long long dis = x*x + y*y;
        if(dis <= D*D){
            count++;
        }
    }

    cout << count << endl;

}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> ans(n);
    
    for(int rep = 0; rep < n-1; rep++) {
        int x;
        cin >> x;
        ans[--x]++;
    }
    
    for(int i = 0; i < n; i++) {
        cout << ans[i] << '\n';
    }
    
}


Measured memory_bytes: 3996
/*
 * Since g++10 is released, some characters is not valid inside #if 0 :(
 * So, why not using clang++? :D

 * Date:
  echo -n '  ' && date +%Y.%m.%d # Just Run this (Type !!sh in Vim).

 * Solution:
  To be updated after "Accept".

 * Digression:

 * CopyRight:
          ▁▃▄▄▄▃▃▃▃▄▶
        ▗▇▀▔    ▔▔▔▔
       ▄▛   ▃▅━━■▄▂
      ▟▊   ▐▘     ▀▙
     ▟▜▌   ▐▖   ▋  ▐▍
    ▟▘ ▜   ▝▀▇▆●▘  ▐▌
  ▗▟▘   ▜▃       ▁▅▛
  ▔▀▼▅▄▃▃██▅▄▄▄▅■▀▔
        ▔▔▔▔▔▔
 */

#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

int main () {
	putchar(getchar());
	putchar(getchar());
	putchar(getchar());
	puts("");
}


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

int main()
{
  int N, a;
  vector<int> x(100001, 0);

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    if (a == 0)
    {
      x[0]++;
      x[1]++;
    }
    else
    {
      x[a - 1]++;
      x[a]++;
      x[a + 1]++;
    }
  }
  a = 0;
  for (int i = 0; i < 100001; i++)
    a = max(a, x[i]);
  cout << a << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define li long ll
#define pp pair<ll, ll>
#define lb lower_bound
#define ub upper_bound
#define mk make_pair
#define pb push_back
#define llp(i, x, n) for (ll i = x; i < n; i++)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define fr first
#define ss second
#define mod 1000000007
using namespace std;
int main()
{
	fast;
    ll h,w,m;
    cin>>h>>w>>m;
    unordered_map<ll,ll> um1,um2;
    unordered_map<string,bool> res;
    while(m--)
    {
    	ll a,b;
    	cin>>a>>b;
    	string s;
    	s+=to_string(a);
    	s+=to_string(b);
    	res[s]=true;
    	um1[a]++,um2[b]++;
    }
    ll m1=-1,m2=-1;
    vector<int> v1,v2;
    for(auto it:um1)
    {
    	m1=max(m1,it.ss);
    }
    for(auto it:um2)
    {
    	m2=max(m2,it.ss);
    }
    for(auto it:um1)
    {
    	if(it.ss==m1)
    	v1.pb(it.fr);
    }
    for(auto it:um2)
    {
    	if(it.ss==m2)
    	v2.pb(it.fr);
    }
    int f=0;
    for(int i=0;i<v1.size();i++)
    {
    	string str;
    	for(int j=0;j<v2.size();j++)
    	{
    		str+=to_string(v1[i]);
    		str+=to_string(v2[j]);
    		if(res[str]==false)
    		{
    			f=1;
    			break;
    		}
    		str="";
    	}
    	if(f==1)
    	break;
    }
    if(f==1)
    cout<<m1+m2<<endl;
    else
    cout<<m1+m2-1<<endl;
}

Measured memory_bytes: 57412
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    int x = Integer.parseInt(data[0]);
    int y = Integer.parseInt(data[1]);
    int z = Integer.parseInt(data[2]);
    
    x -= z;
    int result = x/(y+z);
    System.out.println(result);
  }
}


Measured memory_bytes: 21204
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, k;
  readf("%s %s\n", &n, &k);
  auto i = readln.chomp.split.to!(int[]);
  i.sort!((x,y)=>x > y);
  i[0..k].sum.writeln;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu Jan  2 16:11:53 2020

@author: student2
"""
n, k = map(int,input().split())

prijatelji = map(int, input().split())

x=0

for i in prijatelji:
    if i >= k:
        x = x+1
print (x)        

    

Measured memory_bytes: 9992