akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {1,0,-1,0};

int main(){
	string train;
	int num;
	cin >> num;
	while(cin >> train){

		int c=0;
		map<string,bool> table;
		for(int len=1;len<=train.size();len++){
			string front = train.substr(0,len);
			string rear = train.substr(len,train.size()-len);

			string front_rev = front;
			reverse(front_rev.begin(),front_rev.end());

			string rear_rev = rear;
			reverse(rear_rev.begin(),rear_rev.end());
			
			vector<string> v_f;
			vector<string> v_r;
			v_f.push_back(front);
			v_f.push_back(front_rev);
			v_r.push_back(rear);
			v_r.push_back(rear_rev);

			for(int i=0;i<2;i++){
				for(int j=0;j<2;j++){
					string gen1 = v_f[i] + v_r[j];
					string gen2 = v_r[j] + v_f[i];

					if(table.find(gen1) == table.end()){
						c++;
						table[gen1] = true;
					}

					if(table.find(gen2) == table.end()){
						c++;
						table[gen2] = true;
					}
				}
			}
		}

		printf("%d\n",c);
	}
}

Measured memory_bytes: 1012
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n;
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

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

int main() {
    int k,x;
    cin>>k>>x;
    int lower=x-k+1;
    int upper=x+k-1;
    for(int i=lower;i<=upper;i++)
        cout<<i<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int main()
{
    char a[15];
    char b[15];
    char c[15];

    cin>>a;
    cin>>b;

    int na=0;
    int nb=0;
    cin>>na>>nb;

    cin>>c;
    if(strcmp(a,c)==0)
        na--;
    if(strcmp(b,c)==0)
        nb--;

    cout<<na<<' ' <<nb<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //cin>>t;
    t=1;
    while(t--){
        ll h,w;
        cin>>h>>w;
        if(h==1|| w==1)cout<<1;
        else {
            if(h%2==0)cout<<(h/2)*w;
            else cout<<(h/2)*w + (w+1)/2;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
  int H, W;
  while (true)
    {
      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 << endl;
      }
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	
	vector<string>store(n);
	vector<int>score(n);
	rep(i, n) {
		cin >> store[i] >> score[i];
	}

	rep(i, n) score[i] = score[i] * -1;

	tuple<string, int, int> s;
	vector<tuple<string, int, int>> a(n);
	rep(i, n) {
		//s = { store[i],score[i],i + 1 };
		get<0>(s) = store[i];
		get<1>(s) = score[i];
		get<2>(s) = 1 + i;
		a[i] = s;
	}

	sort(a.begin(),a.end());
	rep(i, n) {
		cout << get<2>(a[i]) << endl;
	}

}

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

int main() {
    int n;
    cin >> n;
    int i = 1;
    while (++i <= n) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
            continue;
        }
        while (x) {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3084
#include <cmath>
#include <climits> /* LLONG_MAX */

#include <string>
#include <vector>
#include <numeric> /* gcd, lcm, partial_sum, reduce*/
#include <iomanip> /* setprecision */
#include <iostream>
#include <algorithm>

using ll = long long; // c++11

const std::string ans[2] = { "No\n", "Yes\n" };

int main() {
    using namespace std;
    int a, b;
    cin >> a >> b;
    if(a<b){
        for (int i = 0; i < b; i++)
            cout << a;
        cout << endl;
    } else {
        for (int i = 0; i < a;i++)
            cout << b;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;


int match(const string &sub, const string &str, int offset) {
  int n = str.size();
  int k = sub.size();
  if ((offset + k) > n) {
    return -1;
  } else {
    int cnt = 0;
    for (int i = offset; i < offset + k; ++i) {
      if (str[i] == sub[i - offset]) ++cnt;
    }
    return cnt;
  }
}
      

typedef  int64_t llong;
int main() {
  string str, sub;
  cin >> str >> sub;
  int n = str.size();
  int k = sub.size();
  vector<int> matches {};
  for (int offset = 0; offset <= n - k; ++offset) {
    matches.push_back(match(sub, str, offset));
  }

  int m = *max_element(matches.begin(), matches.end());

  cout << k - m << endl;
  
}


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

using namespace std;
int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> A(N, 0);
	vector<int> subsum(N, 0);
	long long sum = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}

	struct Elem
	{
		int b;
		int c;
		Elem(int m = 0, int n = 0) :b(m), c(n) {}
	};
	vector<Elem> opr(M, Elem());
	auto cmp = [](const Elem& a, const Elem& b) {
		return a.c > b.c;
	};

	for (int i = 0; i < M; ++i)
	{
		int b, c;
		cin >> b >> c;
		opr[i].b = b;
		opr[i].c = c;
	}

	sort(A.begin(), A.end());
	sort(opr.begin(), opr.end(), cmp);

	for (int i = 0; i < M; ++i)
	{
		auto iter = lower_bound(A.begin(), A.end(), opr[i].c);
		int len = iter - A.begin();
		if (len > 0)
		{
			int ct = len < opr[i].b ? len : opr[i].b;
			int n = 0;
			copy(A.begin() + ct, iter, A.begin());
			while (n < ct)
			{
				A[len - 1 - n] = opr[i].c;
				++n;
			}
		}
	}
	for (int i = 0; i < N; ++i)
		sum += A[i];
	cout << sum << endl;
	return 0;
}

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

int main(){
    int N,f=0,temp;
    cin >> N;
    temp=N;
    for(int i=100000000;i>=1;i=i/10){
        if(N/i!=0){
            f+=N/i;
            N=N-N/i*i;
        }
    }
    if(temp%f==0){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}

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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var うんこ = Console.ReadLine().Split(' ')
				.Select(ぶりぶり => int.Parse(ぶりぶり))
				.OrderBy(ブリリリリリリ => ブリリリリリリ)
				.ToArray();
			int ぜんぶのうんこ = 0;
			for (int i = 1; i < うんこ.Count(); i++)
			{
				ぜんぶのうんこ += うんこ[i] - うんこ[i - 1];
			}

			Console.WriteLine(ぜんぶのうんこ);
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  
  long long h, n, w;
  bool fin = false;
  for (h = 1; h <= 3500; h++)
  {
    for (n = 1; n <= 3500; n++)
    {
      if (4 * h * n > N * (h + n) &&
          N * h * n % (4 * h * n - N * (h + n)) == 0)
      {
        w = N * h * n / (4 * h * n - N * (h + n));
        if (w > 0)
        {
          cout << h << " " << n << " " << w << endl;
          fin = true;
          break;
        }
      }
    }
    if (fin) break;
  }
}

Measured memory_bytes: 256
n=int(input())
if n<=111:
    print(111)
elif n<=222:
    print(222)
elif n<=333:
    print(333)
elif n<=444:
    print(444)
elif n<=555:
    print(555)
elif n<=666:
    print(666)
elif n<=777:
    print(777)
elif n<=888:
    print(888)
elif n<=999:
    print(999)

Measured memory_bytes: 3060
#include<stdio.h>
void swap(int *a,int *b); 

int main()  {
  int i,j,A[100],N,count=0,minj;
  while(1) {
    scanf("%d",&N);
    if(1<=N && N<=100) break;
  }

  for(i=0;i<N;i++)  {
    scanf("%d",&A[i]);
  }

  for(i = 0;i <=N-1;i++) {
    minj = i;
    for (j = i; j <= N-1; j++) {
      if (A[j] < A[minj]) {
	minj = j; 
      }
    }
	swap(&A[i],&A[minj]);
	if(minj != i) count++;
  }


  for(i=0;i<N-1;i++) 
    printf("%d ",A[i]);
  
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  return 0;
}

void swap(int *a,int *b)
{ 
  int t; 
  t =*a; 
  *a = *b;
  *b=t;
}

Measured memory_bytes: 600
<?php
  $input = explode(' ', fgets(STDIN));

  $N = (int)$input[0];
  $A = (int)$input[1];
  $B = (int)$input[2];

  
  if($A === 0) return print("0\n");
  
  $AB = $A + $B;
  $ans = intval($N / $AB) * $A;

  $bb = intval($N % $AB);

  if($A < $bb) {
    $ans += $A;
  } else {
    $ans += $bb;
  }

  printf("%s\n", $ans);
?>


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

ll a[60],p[60];
ll finder(ll x,ll n){
  if(x==0)return 0;
  if(n==0)return 1;
  if(x==1)return 0;
  if(x==a[n])return p[n];
  if(x<=a[n]/2)return finder(x-1,n-1);
  if(x==a[n]/2+1)return p[n]/2+1;
  else return p[n]/2+1+finder(x-a[n-1]-2,n-1);
}

int main(){
  ll n,x;cin>>n>>x;
  a[0]=1;p[0]=1;
  rep(i,60-1){
    a[i+1]=a[i]+4ll*(1ll<<i);
    p[i+1]=p[i]+(1ll<<(i+1));
  }
  cout<<finder(x,n)<<endl;
}


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

#define pi acos(-1.0)
#define ms(x,n) memset(x,n,sizeof(x));

typedef long long ll;//string::npos
typedef long long iint;

ll gcd(ll a,ll b) {
	return a%b==0?b:gcd(b,a%b);
}
ll lcm(ll x,ll y) {
	ll z=gcd(x,y);
	return x*y/z;
}

const int MAXX=3e5+5;
const int INF=1e7+5;
const int mod=998244353;

vector<int> vt;
map<int,int> m1;

int main() {
	ios::sync_with_stdio(false);
	int serve,t,n,add,pos;bool zheng=true;
	string s;char a;
	cin>>s;
	deque<char> q;
	int len = s.length();
	for(int i=0;i<len;i++){
		q.push_back(s[i]);
	}
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>serve;/*翻转 还是 添加*/ 
		if(serve==1){
			if(zheng) zheng=false;
			else zheng=true;
		}else{
			cin>>pos>>a;/*添加在头还是尾*/
			if(pos==1){
				if(zheng){
					q.push_front(a);
				}else{
					q.push_back(a);
				}
			}else{
				if(zheng){
					q.push_back(a);
				}else{
					q.push_front(a);
				}
			}
		}
	}
//	deque<char>::iterator *pos=q.begin();
	if(zheng){
		while(!q.empty()){
			cout<<q.front(); q.pop_front();
			/*cout<<q.back(); q.pop_back();*/
		}
//		for(pos=q.begin();pos!=q.end();pos++){
//			printf("%c",*pos);
//		}
	}else{
		while(!q.empty()){
			/*cout<<q.front(); q.pop_front();*/
			cout<<q.back(); q.pop_back();
		}
//		for(pos=q.end();pos!=q.begin();pos--){
//			printf("%c",*pos);
//		}
	}
	
	return 0;
}




//	getline(cin,a);
//	scanf("%[^\n]",a);getchar();
//	cin.getline(a,sizeof(a));

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

using namespace std;

int main() {
    int n, m;
    string str;
    cin >> str;
    n = str.size();
    if (str[0] == str[n - 1]) m = n - 3;
    else m = n - 2;
    if (m % 2 == 0) cout << "Second";
    else cout << "First";
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int t[20][20];
int tn[20];
int tb[20];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int s=0;
	bool flag;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>tn[i];
		for(j=0;j<tn[i];j++){
			cin>>t[i][j];
			t[i][j]--;
		}
	}
	for(i=0;i<m;i++)cin>>tb[i];
	for(i=0;i<(1<<n);i++){
		flag=true;
		for(j=0;j<m;j++){
			a=0;
			for(k=0;k<tn[j];k++){
				if(i&(1<<t[j][k]))a++;
			}
			if(a%2!=tb[j]){
				flag=false;
				break;
			}
		}
		if(flag)s++;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
int main()
{
    int M, D;
    cin >> M >> D;
    int cou = 0;
    for (int i = 22; i < D + 1; i++)
    {
        int d10 = i / 10;
        int d1 = i - (d10 * 10);
        int sum = d10 * d1;
        if (sum <= M && d10 >= 2 && d1 >= 2)
        {
            cou++;
        }
    }
    cout << cou << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef long double D;
typedef vector<D> P;
const D EPS = 1e-8;

int n,m,r;
P s[2010], t[20], e;
D sr[2010], b[20];

inline D dis2(P a, P b){
  D res = 0;
  rep(i,3)res += (a[i]-b[i])*(a[i]-b[i]);
  return res;
}

inline P mul(D k, P a){
  rep(i,a.size())a[i] *= k;
  return a;
}

inline P add(P a, P b){
  rep(i,a.size())a[i] += b[i];
  return a;
}

vector<int> check(int x){
  vector<int> res;

  rep(i,n){
    bool f1 = dis2(e, s[i])+EPS<sr[i]*sr[i];
    bool f2 = dis2(t[x], s[i])+EPS<sr[i]*sr[i];
    if(f1!=f2){
      res.push_back(i);
    }else if(!f1 && !f2){
      P left = e, right = t[x];
      rep(hoge,30){
	P m1 = mul(1.0/3,add(mul(2.0,left),right));
	P m2 = mul(1.0/3,add(left,mul(2.0,right)));
	
	D d1 = dis2(s[i],m1), d2 = dis2(s[i],m2);
	if(d1 < d2)right = m2;
	else left = m1;
      }
      //cout << i << " " << dis2(left,s[i]) << endl;
      if(dis2(left, s[i]) +EPS < sr[i]*sr[i])res.push_back(i);
    }
  }

  //rep(i,res.size()) cout << res[i] << " ";cout << endl;
  return res;
}

int main(){
  while(cin >> n >> m >> r, n){
    rep(i,n){
      s[i].resize(3);
      rep(j,3)cin >> s[i][j];
      cin >> sr[i];
    }
    
    rep(i,m){
      t[i].resize(3);
      rep(j,3)cin >> t[i][j];
      cin >> b[i];
    }

    e.resize(3);
    rep(i,3)cin >> e[i];

    vector<int> obj[20];
    rep(i,m){
      obj[i] = check(i);
    }
    
    D res = 0;
    rep(i,(1<<m)){
      vector<int> use(n);
      D sum = 0;
      rep(j,m){
	if( (i>>j)&1 ){
	  rep(k,obj[j].size()){
	    use[obj[j][k]] = 1;
	  }
	  sum += b[j] / dis2(e, t[j]);
	}
      }
      if(accumulate(use.begin(),use.end(),0) <= r){
	res = max(res, sum);
      }
    }
    cout << fixed << setprecision(10) << res << endl;
  }
}
  

Measured memory_bytes: 1572
#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	unsigned long long debt = 100000;
	for(int i = 0; i < n; ++i)
	{
		debt *= 1.05;
		int less_than_thousand = debt % 1000;
		if(less_than_thousand > 0)
		{
			debt += 1000 - less_than_thousand;
		}
	}
	cout << debt << endl;
}

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

Measured memory_bytes: 1152
object Main {

    def main(args: Array[String]): Unit = {
        val sc = new java.util.Scanner(System.in)

        val n = sc.nextInt
        val tenants = Array.ofDim[Int](4, 3, 10)

        for( i <- 0 until n ) {
            val b, f, r, v = sc.nextInt
            tenants(b-1)(f-1)(r-1) += v
        }

        for( i <- 0 until 4 ) {
            for( j <- 0 until 3 ) {
                println(" " +tenants(i)(j).mkString(" "))
            }
            if( i < 3 ) println("#"*20)
        }
    }
}



Measured memory_bytes: 47472
#!/usr/bin/env python3
import math

N = int(input().split()[0])
a_list = list(map(int, input().split()))

total = sum(a_list)
work_list = []
sunuke = 0

for i in range(N - 1):
    sunuke += a_list[i]
    arai = total - sunuke
    work_list.append(abs(sunuke - arai))

ans = min(work_list)
print(ans)


Measured memory_bytes: 23800
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a%b==0){
         cout<<c*(a/b)<<endl;
         return 0;
    }
    else{
        cout<<c*(a/b+1)<<endl;
    }
   
    // Your code here!
    
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>

using namespace std;


int main()
{

  int N;
  cin >> N;

  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);

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

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

  for(int i = 0; i < N-1; i++){
    cin >> C[i];
  }

  int score = B[A[0]-1];

  for(int i = 1; i < N; i++){
    score += B[A[i]-1];
    if((A[i] - A[i-1]) == 1){
      score += C[A[i-1]-1];
    }
  }

  cout << score << endl;

  return 0;
}


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

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

    long long int sum = 0;
    stack<long long int> sa;

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

    vector<long long int> b(m);
    for(int i=0; i<m; i++){
        cin >> b[i];
    }

    while(sum > k){
        long long int sub = sa.top(); sa.pop();
        sum -= sub;
    }

    int l = sa.size(), x = 0;
    int ans = l, current = l;

    while(sum + b[x] <= k && x < m){
        sum += b[x];
        x += 1;
        current += 1;
        ans = max(ans, current);
        //cout << sum << " ";
    }

    for(int i=0; i<l; i++){
        long long int sub = sa.top(); sa.pop();
        sum -= sub;
        current -= 1;

        while(sum + b[x] <= k && x < m){
            sum += b[x];
            x += 1;
            current += 1;
            ans = max(ans, current);
            //cout << sum << " ";
        }
        //cout << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7932
#include<iostream>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
using namespace std;
const double INF =0x3f3f3f3f;
int f[1005];
int main()
{
   f[1]=1;
   for(int i=2;i<=1000;i++)
   {
      for(int k=i*i;k<=1000;k*=i)
         f[k]=1;
   }
   int x;cin>>x;
   while(1)
   {
      if(!f[x])
         x--;
      else
         break;
   }
   cout<<x;
}


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

int main() {
  int N; cin >> N;
  string s; cin >> s;
  int ans = 1;
  for(int i = 1; i < s.size(); i++) {
    if(s[i] != s[i-1]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int m ;
    if(b < a) m = a-1;
    else m = a;
    cout << m << endl;

    return 0;
}


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

typedef long long ll;

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void)
{
	int N, T;
	cin >> N >> T;

	ll ans = 0;
	ll last = -T;
	Rep(i, N){
		int t;
		cin >> t;
		ans += (t > last + T) ? T : (t - last);
		last = t;
	}
	PrintLn(ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  string s,t;cin>>s>>t;
  vector<char> a,b;
    
  rep(i,s.size()){
    a.pb(s[i]);
  }
  rep(i,t.size()){
    b.pb(t[i]);
  }

  sort(all(a));
  sort(all(b),greater<char>());

  string s2="",t2="";
  rep(i,s.size()){
    s2+=a[i];
  }
  rep(i,t.size()){
    t2+=b[i];
  } 


  if(s2<t2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;

namespace abc122_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var q = CIn.ReadInt();
      var s = CIn.Read().ToCharArray();

      var sum = new int[n + 1];

      for (var i = 1; i < n; i++)
      {
        sum[i + 1] = sum[i];
        
        if (s[i - 1] == 'A' && s[i] == 'C')
        {
          sum[i + 1]++;
        }
      }

      Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

      for (var i = 0; i < q; i++)
      {
        var l = CIn.ReadInt();
        var r = CIn.ReadInt();

        Console.Out.WriteLine(sum[r] - sum[l]);
      }

      Console.Out.Flush();
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

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

using namespace std;

typedef long long ll;

long long test_cases;
ll freq[100123];

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

    /* cin >> test_cases; */
    test_cases = 1;

    ll n;
    ll a[100123];
    ll q, ansi = 0;
    while (test_cases > 0)
    {
        cin >> n;
        for (ll i = 0; i < n; i++)
        {
            cin >> a[i];
            ansi += a[i];
            freq[a[i]]++;
        }

        cin >> q;
        ll b, c;
        while (q > 0)
        {
            cin >> b >> c;
            if (c > b)
            {
                ansi += (c - b)*freq[b]; 
            }
            if (c < b)
            {
                ansi -= (b - c)*freq[b];
            }
            freq[c] += freq[b];
            freq[b] = 0;

                
            cout << ansi << endl;
            q--;
        }

        test_cases--;
    }

    
    return 0;
}

Measured memory_bytes: 5140
#include <bits/stdc++.h>
#define MAX 100007

#define REP(i, N) for(int (i)=0; (i) < (N); (i)++)
#define PER(i, N) for(int (i)=(N)-1; (i) >= 0; (i)--)

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

int a[MAX];

int main(){
    ll n, m; cin >> n >> m;
    n %= m;
	
    cout << min(n, abs(n-m)) << endl;
    return 0;
}

Measured memory_bytes: 384
import math
import itertools
N = int(input())
array = [list(map(int, input().split())) for i in range(N)]

length_list = []
for i in range(N-1):
    for j in range(i+1, N):
        l = math.sqrt((array[i][0] - array[j][0])**2 + (array[i][1] - array[j][1])**2)
        length_list.append(l)

print((sum(length_list) * 2 * math.factorial(N-1)) / math.factorial(N))


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

int main() {
  int a,s,f =1000000, g = -1000000;
  long long d = 0;
  cin >> a;
  for(int i = 0; i < a;i++){
      cin >> s;
      if (s < f) f = s;
      if (s > g) g = s;
      d += s;
  }
  cout << f << " " << g << " " << d << endl;
}


Measured memory_bytes: 3100
using System;

namespace AtCoderSnippet
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(" ");
            var cnt = 0;

            for (int i = 0; i < N; i += 2)
            {
                if (int.Parse(a[i]) % 2 != 0) cnt++;
                
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 27332
open Str

let read_list () =
  split (regexp " +") (read_line ())

let split_eo ls =
  let rec iter os es = function
      [] -> (os, es)
    | [x] -> (x::os, es)
    | x::y::ys -> iter (x::os) (y::es) ys
  in iter [] [] ls
          
let () =
  let n = read_int () in
  let xs = read_list () in
  let (os, es) = split_eo xs in
  (if n mod 2 = 0 then es @ (List.rev os) else os @ (List.rev es)) |> String.concat " " |> print_endline


Measured memory_bytes: 29824
S = input()
T = input()
n = len(S)
s = []
t = []
for i in S:
  s.append(i)
for i in T:
  t.append(i)
  
for i in range(n):
  res = s[0] 
  for j in range(1, n):
    s[j-1] = s[j]
  s[n-1] = res
  if s == t:
    print('Yes')
    exit()
    
print('No')

Measured memory_bytes: 9024
import java.util.Scanner;

//Enclose Pins with a Rubber Band
public class Main{

	static double ex(double x1, double y1, double x2, double y2, double x3, double y3){
		double dx1 = x2-x1;
		double dy1 = y2-y1;
		double dx2 = x3-x1;
		double dy2 = y3-y1;
		return dx1*dy2-dx2*dy1;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			double[][] p = new double[n][2];
			for(int i=0;i<n;i++){
				String[] s = sc.next().split(",");
				p[i][0] = Double.parseDouble(s[0]);
				p[i][1] = Double.parseDouble(s[1]);
			}
			boolean[] used = new boolean[n];
			int left = 0;
			for(int i=1;i<n;i++)if(p[i][0]<p[left][0])left=i;
			used[left]=true;
			int end = left;
			int pre = left;
			while(true){
				int k;
				for(k=0;k<n;k++){
					if(pre==k)continue;
					boolean f = true;
					for(int j=0;j<n;j++){
						if(j==pre||j==k)continue;
						if(ex(p[pre][0], p[pre][1], p[k][0], p[k][1], p[j][0], p[j][1]) <= 0){
							f = false;
							break;
						}
					}
					if(f){
						used[k] = true;
						pre = k;
						break;
					}
				}
				if(pre==end)break;
			}
			int c = 0;
			for(int i=0;i<n;i++)if(!used[i])c++;
			System.out.println(c);
		}
	}
}

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

int main() {
  ll l,r;
  cin >> l >> r;
  ll mod = 2019;
  if (l % mod == 0) {
    cout << 0 << endl;
  } else {
    if ((l/mod) * mod + mod <= r) {
      cout << 0 << endl;
    } else {
      ll ans = 1000000000000;
      rep(i,l,r) rep(j,i+1,r+1) {
        ans = min(ans, i*j % mod);
      }
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n);
    FOR(i, 1, n) {
        int in; cin >> in;
        ++a[in - 1];
    }
    each(i, a)cout << i << "\n";
}

Measured memory_bytes: 3992
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main() {
    long N;
    cin>>N;
    vector<long> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
        a.at(i)--;
    }
    
    
    set<long> s;
    
    
    long p=0,count=0;
    while(s.count(p)==0){
        s.insert(p);
        p=a.at(p);
        count++;
        if(p==1){
            cout<<count<<endl;
            return 0;
        }
    }
    
    cout<<-1<<endl;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

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

    int N;
    cin >> N;

    vi a(N), b(N), sums(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
        sums[i] = a[i] + b[i];
    }
    sort(all(sums), greater<int>());

    ll as = 0, bs = 0;
    for (int v : a) as += v;
    for (int v : b) bs += v;

    ll ans = -bs;
    for (int i = 0; i < N; i += 2)
        ans += sums[i];
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#define ll long long
ll l,r,ans,one[60];
ll pw[60];
int main()
{
	pw[0]=1;
	scanf("%lld%lld",&l,&r);
//	if(l==r)
	//{
		//printf("%lld\n",l);return 0;
//	}
	for(int i=1;i<=50;i++)pw[i]=pw[i-1]<<1ll;
	ll rtmp=r,ltmp=l-1;
	int rk=0,lk=0;
	while(rtmp>0){rk++;rtmp>>=1;}
	while(ltmp>0){lk++;ltmp>>=1;}
	for(int i=40;~i;i--)
	{
		if((1ll<<i)>r)continue;
		for(int j=rk-1;j>i;j--)
			if((r>>j)&1)
				one[i]+=pw[j-i-1]*pw[i];
		if((r>>i)&1)
		{
			for(int j=i-1;~j;j--)
				if((r>>j)&1){one[i]+=pw[j];}
			one[i]++;
		}
	}
	for(int i=40;~i;i--)
	{
		if((1ll<<i)>(l-1))continue;
		for(int j=lk-1;j>i;j--)
			if(((l-1)>>j)&1)
				one[i]-=pw[j-i-1]*pw[i];
		if(((l-1)>>i)&1)
		{
			for(int j=i-1;~j;j--)
				if(((l-1)>>j)&1){one[i]-=pw[j];}
			one[i]--;
		}
	}
	for(int i=40;~i;i--)
		if(one[i]&1)ans|=(1ll<<i);
	printf("%lld\n",ans);
	return 0;
}

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

#define MOD 1000000007
using namespace std;
int main(void){
    int N,M; //Nが階段数,Mが壊れた階段数
    cin >> N >> M;
    
    int a[M];
    for(int i = 0; i < M; i++) cin >> a[i];
    
    
    int c[N+2];
    memset(c,0,sizeof(c));
    c[0] = 1; //最初の段にいる場合の数
    for(int k = 0, i = 0; k < N; k++){
        if(k == a[i]){ //壊れた段数から到達する場合を考えない処理
            c[k] = 0; i++;
        }
        c[k+1] += c[k];
        c[k+2] += c[k];
        
        
        c[k+1] %= MOD;
        c[k+2] %= MOD;
    }
    cout << c[N] << endl;
    return 0;
}

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

using namespace std;

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> as(101010);

    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        as[a].push_back(b);
    }

    for (int i = 0; i < 101010; i++) {
        sort(as[i].rbegin(), as[i].rend());
    }

    priority_queue<int> que;

    vector<int> dp(m + 1);
    for (int i = 1; i <= m; i++) {
        for (int a : as[i]) {
            que.push(a);
        }
        if (!que.empty()) {
            dp[i] = dp[i - 1] + que.top();
            que.pop();
        } else {
            dp[i] = dp[i - 1];
        }
    }

    cout << dp[m] << endl;
}

Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100001][2];
ll mod = 1e9+7;
class graph
{
public:
	ll v;
	list<ll> *adj;
	bool *visited;
	
	graph(ll v)
	{
		this->v = v;
		adj = new list<ll>[v];
		visited = new bool[v];
		for (ll i = 0; i < v; ++i)
		{
			visited[i] = false;
		}
	}

	void add(ll a, ll b)
	{
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	void dfs(ll v);
};

void graph::dfs(ll i)
{
	visited[i] = true;
	ll white = 1;
	ll black = 1;
	for(auto t: adj[i])
	{
		if(!visited[t])
		{
			dfs(t);
			white = (white*(dp[t][0]+dp[t][1]))%mod;
			black = (black*dp[t][1])%mod;
		}
	}
	dp[i][1] = white;
	dp[i][0] = black;
}

void solve()
{
	ll n;
	cin>>n;
	graph g(n);
	for (ll i = 0; i < n-1; ++i)
	{
		/* code */
		ll u,v;
		cin>>u>>v;
		g.add(u-1,v-1);
	}
	g.dfs(0);
	cout<<(dp[0][1]+dp[0][0])%mod<<endl;
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 20736
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
int main() {
  uint64_t N;
  string S;
  cin >> N >> S;

  string T(S, 0, N / 2), T2(S, N / 2, N);

  if (T == T2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			for (int i = n; i <= 999; i++) {
				if (check(i)) {
					out.println(i);
					return;
				}
			}

		}

		boolean check(int n) {
			char[] s = String.valueOf(n).toCharArray();
			return s[0] == s[1] && s[1] == s[2];
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
const int INF = 1145141919;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int T;

void dfs(int u, int t0, ll x, vector<vector<i_i> >& chs, vector<int>& sz, vector<ll>& ans) {
	for (i_i p: chs[u]) {
		int v = p.first, t = p.second;
		ans[u] = x + (ll)(t - t0) * sz[u];
		dfs(v, t, ans[u], chs, sz, ans);
	}
	ans[u] = x + (ll)(T - 1 - t0) * sz[u];
}

int main() {
	int N, M; cin >> N >> M >> T;
	vector<int> a(M), b(M), t(M);
	rep(i, M) {
		scanf("%d%d%d", &a[i], &b[i], &t[i]);
		a[i]--; b[i]--; t[i]--;
	}
	vector<vector<i_i> > G(N);
	rep(i, M) {
		G[a[i]].pb(i_i(b[i], t[i]));
		G[b[i]].pb(i_i(a[i], t[i]));
	}
	vector<int> d(N, INF); d[0] = 0;
	queue<int> q; q.push(0);
	while (q.size()) {
		int u = q.front(); q.pop();
		for (i_i p: G[u]) {
			int v = p.first, t = p.second;
			if (d[u] <= t && d[u] + 1 < d[v]) {
				d[v] = d[u] + 1;
				q.push(v);
			}
		}
	}
	vector<vector<int> > unko(T);
	rep(i, M) unko[t[i]].pb(i);
	union_find uf(N);
	int K = N;
	vector<int> index(N);
	rep(u, N) index[u] = u;
	vector<vector<i_i> > chs(N * 2 - 1);
	vector<int> sz(N * 2 - 1);
	rep(u, N) sz[u] = 1;
	for (int t = T - 1; t >= 0; t--)
		for (int i: unko[t]) {
			if (uf.same(a[i], b[i])) continue;
			int x = index[uf.find(a[i])], y = index[uf.find(b[i])];
			uf.unite(a[i], b[i]);
			int z = (index[uf.find(a[i])] = K++);
			chs[z].pb(i_i(x, t)); chs[z].pb(i_i(y, t));
			sz[z] = uf.size(a[i]);
		}
	vector<ll> ans(N * 2 - 1);
	dfs(N * 2 - 2, -1, 0, chs, sz, ans);
	ll ma = 0;
	rep(u, N) if (d[u] < INF) ma = max(ma, ans[u]);
	cout << ma << endl;
	// rep(u, N) cout << ans[u] << ' ';
	// cout << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int minimum = 1000000;
  int maximum = -1000000;
  long long sum = 0;;
  for (int i = 0; i < n; i++) {
    minimum = min(minimum, a.at(i));
    maximum = max(maximum, a.at(i));
    sum += a.at(i);
  }
  cout << minimum << " " << maximum << " " << sum << endl;
}



Measured memory_bytes: 3144
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    H, W = map(int, input().split())
    field = []
    for i in range(H):
        field.append(input())

    for y in range(H):
        for x in range(W):
            if field[y][x] == "#":
                ok = False
                for i in range(4):
                    ny = y + dy4[i]
                    nx = x + dx4[i]

                    if inside(ny, nx, H, W) and field[ny][nx] == "#":
                        ok = True

                if not ok:
                    print(No)
                    return
    print(Yes)

if __name__ == '__main__':
    main()


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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    char a; std::cin >> a;
    char b = a-'a';
    if (b >= 0 && b < 27) {
        std::cout << 'a' << "\n";
    } else {{
        std::cout << 'A' << "\n";
    }}
}


Measured memory_bytes: 3620