akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

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

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   int a,b,sum=0,i=0;
   double tmp=0,ave=0;
   char c;
   
   while(cin >> a >> c >> b){
      sum+=a*b;
      tmp+=b;
      i++;
   }
   ave=tmp/i;
   if(ave>=(int)ave+0.5) ave++;
   //double j=i;
   //if(tmp%i>j/2) ave++;
   cout << sum << endl;
   cout << (int)ave << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>x>>a;
    if(x<a)Cout(0);
    else Cout(10);
    return 0;
}


Measured memory_bytes: 256
// Author: H. Gakhar
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a1[n], a2[n], a3[n];
	for(int i=0; i<n; i++) cin>>a1[i]>>a2[i]>>a3[i];
	int dp[3][n];
	for(int i=0; i<3; i++)
		for(int j=0; j<n; j++) dp[i][j]=0;
	dp[0][0]=a1[0];
	dp[1][0]=a2[0];
	dp[2][0]=a3[0];
	for(int i=1; i<n; i++)
	{
		dp[0][i]=max(dp[1][i-1], dp[2][i-1])+a1[i];
		dp[1][i]=max(dp[0][i-1], dp[2][i-1])+a2[i];
		dp[2][i]=max(dp[0][i-1], dp[1][i-1])+a3[i];
	}
	cout<<max(max(dp[0][n-1], dp[1][n-1]),dp[2][n-1] )<<endl;
	/*for(int i=0; i<n; i++)
	{
		for(int j=0; j<3; j++) cout<<dp[j][i]<<" ";
		cout<<endl;
	}
	*/
	return 0;
}
 

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back

constexpr auto inf = numeric_limits<int>().max();
constexpr auto llinf = numeric_limits<ll>().max();

template<typename ForwardIterator>
void dump(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << *it << " ";
	}
	cout << endl;
}

template<typename ForwardIterator>
void dump_map(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << (*it).first << ":" << (*it).second << " ";
	}
	cout << endl;
}

template<typename T>
void debug(initializer_list<T> list) {
  for (auto el : list) {
    cout << el << " ";
  }
  cout << endl;
}

ll N, M;
constexpr ll mod = ll(1e9 + 7);
vector<ll> facts;

ll mult(ll a, ll b) {
	return ((a % mod) * (b % mod)) % mod;
}

ll power(ll a, ll b) {
	ll result = 1LL;
	while (b) {
		if (b % 2LL) result = mult(result, a);
		a = mult(a, a);
		b /= 2LL;
	}
	return result;
}

ll divide(ll a, ll b) {
	return mult(a, power(b, mod - 2));
}

ll perm(ll n, ll r) {
	return divide(facts[n], facts[n - r]);
}

ll comp(ll n, ll r) {
	return divide(facts[n], mult(facts[r], facts[n - r]));
}

ll add(ll a, ll b) {
	return ((a % mod) + (b % mod)) % mod;
}

ll subtract(ll a, ll b) {
	return ((a - b) % mod + mod) % mod;
}

void solve() {
	cin >> N >> M;
	facts.resize(M + 10);
	facts[0] = 1LL;
	facts[1] = 1LL;
	repa(i, 2LL, M + 5LL) {
		facts[i] = mult(facts[i - 1], i);
	}
	ll tot = 0LL;
	bool toadd = true;
	repa(k, 0LL, N) {
		auto val = mult(comp(N, k), perm(M - k, N - k));
		if (toadd) {
			tot = add(tot, val);
		} else {
			tot = subtract(tot, val);
		}
		toadd = !toadd;
	}
	tot = mult(perm(M, N), tot);
	cout << tot;
	cout << "\n";
}

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


Measured memory_bytes: 7032
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int ac=0,bc=0,cc=0,dc=0,ec=0,fc=0,gc=0,hc=0,ic=0,jc=0,kc=0,lc=0,mc=0,nc=0,oc=0,pc=0,qc=0,rc=0,sc=0,tc=0,uc=0,vc=0,wc=0,xc=0,yc=0,zc=0;
	int len,i=0,count;
	char str[1200],a;
	
	while(1){
		
		
		if(fgets(str,sizeof str,stdin)==NULL){
			break;
		}
		
		len=strlen(str);
		
		for(i=0;i<len;i++){
			if(str[i]=='a' || str[i]=='A'){
				ac++;
			}
			if(str[i]=='b' || str[i]=='B'){
				bc++;
			}
			if(str[i]=='c' || str[i]=='C'){
				cc++;
			}
			if(str[i]=='d' || str[i]=='D'){
				dc++;
			}
			if(str[i]=='e' || str[i]=='E'){
				ec++;
			}
			if(str[i]=='f' || str[i]=='F'){
				fc++;
			}
			if(str[i]=='g' || str[i]=='G'){
				gc++;
			}
			if(str[i]=='h' || str[i]=='H'){
				hc++;
			}
			if(str[i]=='i' || str[i]=='I'){
				ic++;
			}
			if(str[i]=='j' || str[i]=='J'){
				jc++;
			}
			if(str[i]=='k' || str[i]=='K'){
				kc++;
			}
			if(str[i]=='l' || str[i]=='L'){
				lc++;
			}
			if(str[i]=='m' || str[i]=='M'){
				mc++;
			}
			if(str[i]=='n' || str[i]=='N'){
				nc++;
			}
			if(str[i]=='o' || str[i]=='O'){
				oc++;
			}
			if(str[i]=='p' || str[i]=='P'){
				pc++;
			}
			if(str[i]=='q' || str[i]=='Q'){
				qc++;
			}
			if(str[i]=='r' || str[i]=='R'){
				rc++;
			}
			if(str[i]=='s' || str[i]=='S'){
				sc++;
			}
			if(str[i]=='t' || str[i]=='T'){
				tc++;
			}
			if(str[i]=='u' || str[i]=='U'){
				uc++;
			}
			if(str[i]=='v' || str[i]=='V'){
				vc++;
			}
			if(str[i]=='w' || str[i]=='W'){
				wc++;
			}
			if(str[i]=='x' || str[i]=='X'){
				xc++;
			}
			if(str[i]=='y' || str[i]=='Y'){
				yc++;
			}
			if(str[i]=='z' || str[i]=='Z'){
				zc++;
			}
		}
		
	}
	printf("a : %d\n",ac);
	printf("b : %d\n",bc);
	printf("c : %d\n",cc);
	printf("d : %d\n",dc);
	printf("e : %d\n",ec);
	printf("f : %d\n",fc);
	printf("g : %d\n",gc);
	printf("h : %d\n",hc);
	printf("i : %d\n",ic);
	printf("j : %d\n",jc);
	printf("k : %d\n",kc);
	printf("l : %d\n",lc);
	printf("m : %d\n",mc);
	printf("n : %d\n",nc);
	printf("o : %d\n",oc);
	printf("p : %d\n",pc);
	printf("q : %d\n",qc);
	printf("r : %d\n",rc);
	printf("s : %d\n",sc);
	printf("t : %d\n",tc);
	printf("u : %d\n",uc);
	printf("v : %d\n",vc);
	printf("w : %d\n",wc);
	printf("x : %d\n",xc);
	printf("y : %d\n",yc);
	printf("z : %d\n",zc);
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int m = 100000;
    for (int i = 0; i < n; i++){
	m *= 1.05;
	if ((int)m % 1000 != 0)
	    m = m - (int)m % 1000 + 1000;
    }
    cout << m << endl;
}

Measured memory_bytes: 0
n = input()
ans = 0
if len(n)%2 == 1:
    ans += int(n)-10**(len(n)-1)+1
    for i in range(len(n)//2):
        ans += 9*(100**i)
    print(ans)
else:
    for i in range(len(n)//2):
        ans += 9*(100**i)
    print(ans)

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

long long lcm(long long a,long long b) {
	long long c;
	if (a<b) { c=a; a=b; b=c;}
	while(a % b!=0) {c=a; a=b; b=c % b;}
	return b;
}

int main() {
	long long d[10],v[10],a,c,e,f;
	int i,n;
	while(cin >> n && n>0) {
		for (i=0;i<n;i++) cin >> d[i] >> v[i];
		e=d[0]; f=v[0];
		for (i=1;i<n;i++) {
			c=lcm(f*d[i],e*v[i]);
			a=e*v[i]/c;
			e=a*d[i]; f=v[i];
			};
		for (i=0;i<n;i++) cout << (e*v[i])/(f*d[i]) << endl;
	} 
	return 0;
}

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

int main() {
int w,h,n,s=0;
cin>>w>>h>>n;
int l=0,r=w,d=0,u=h;
for(int i=0;i<n;i++){
    int a,x,y;
    cin>>x>>y>>a;
    switch(a){
        case 1:
        if(l<x)l=x;
        break;
        case 2:
        if(r>x)r=x;
        break;
        case 3:
        if(d<y)d=y;
        break;
        case 4:
        if(u>y)u=y;
        break;
    }
}

if(r>l&&u>d){
    s=(r-l)*(u-d);
}
cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
	if(m==0){return 1;}
	if(i>=n){return 0;}
	int res = solve(i+1,m) || solve(i+1,m-A[i]);
	return res;
}

int main(){
	int q,M,i;
	
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i=0; i<q; i++){
		scanf("%d",&M);
	if(solve(0,M)){printf("yes\n");}
	else{
		printf("no\n");
	}
	}
	return 0;
}
	


Measured memory_bytes: 2144
#include "bits/stdc++.h"
using namespace std;
int N, W, dp[100002], MV=100000, ans;
int main(){
    scanf("%d %d", &N, &W);
    memset(dp, 0x3f, sizeof(dp)); dp[0] = 0;
    for(int i=1, w, v; i<=N; i++){
        scanf("%d %d", &w, &v);
        for(int j=MV; j>=v; j--){
            if(dp[j-v] + w <= W) dp[j] = min(dp[j], dp[j-v] + w);
        }
    }
    for(int i=MV; i>=0; i--)
        if(dp[i] <= W) { printf("%d\n", i); break; }
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() { 
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    if (s.size() != a + b + 1) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < s.size(); i++ ) {
        if (i == a) {
            if (s[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] < '0' || s[i] > '9') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}




Measured memory_bytes: 3624
// Grid 1
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define times(t) int t; cin >> t; while(t--)
#define mod 1000000007

void solve() {
	int h, w;
	cin >> h >> w;
	char arr[h][w];
	for(int i=0; i<h; i++) {
		for(int j=0; j<w; j++) {
			cin >> arr[i][j];
		}
	}
	vector<vector<int>> dp(h, vector<int>(w));
	dp[0][0] = 1;
	for(int i=0; i<h; i++) {
		for(int j=0; j<w; j++) {
			for(int r : {i, i+1}) {
				int c = j;
				if(r == i) {
					c = j+1;
				}
				if(r<h and c<w and arr[r][c] == '.') {
					dp[r][c] = (dp[r][c] + dp[i][j])%mod;
				}
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
	return;
}

int main() {
	IOS;
	// #ifndef ONLINE_JUDGE
	// freopen("C:/Gen code/CompProg/input.txt", "r", stdin);
	// freopen("C:/Gen code/CompProg/output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}

Measured memory_bytes: 8196
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=2e5+10;
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;x=x*x%mod;y>>=1;}return res;}
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
inline ll lcm(ll a,ll b){return a * b / __gcd(a, b);}
int t,n,m,k;
int main() {
    int n;
    cin >> n;
    vector<tuple<bool, int, int, int>> v(n);
    for (auto &e : v) {
    string s;
    cin >> s;
    int l = 0, r = 0;
    for (auto c : s) {
      if (c == '(') {
        l++;
      } else if (l > 0) {
        l--;
      } else {
        r++;
      }
    }
    e = {l <= r, l <= r ? (l==0?inf:r-l) : r, l, r};
    }
    sort(v.begin(), v.end());

    bool valid = true;
    int h = 0;
    //for (auto [a, b, l, r] : v)  cerr << a << ' ' << b << ' ' << l << ' ' << r << endl;
    for (auto [a, b, l, r] : v) {
     //cerr << a << ' ' << b << ' ' << r << ' ' << l << endl;
    if (h < r) {
      valid = false;
      break;
    }
    h -= r;
    h += l;
    }
    if (h != 0) valid = false;
    cout << (valid ? "Yes" : "No") << endl;
}


Measured memory_bytes: 18712
#include <bits/stdc++.h>
using namespace std;
string xx[]={"7","5","3"};
int n,ans;
int main(){
	cin >> n;
	vector<string> t;
	t.push_back("");
	while(t.size()){
		vector<string> p;
		for (auto y:t){
			if(y.size()>=9)continue;
			for(auto s:xx){
				string k = y+s;
				if(k.find('7')!=k.find('0'))
				if(k.find('5')!=k.find('0'))
				if(k.find('3')!=k.find('0'))
				if(stoi(k)<=n)ans++;
				p.push_back(y+s);
			}
		}
		t = p;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2172
# 16-Character-Sum_of_Numbers.py

# ??°?????????
# ?????????????????°???????????????????¨??????????????????°?????????????????????????????????

# Input
# ?????°??????????????????????????\?????¨??????????????????????????????????????????????????????????????´??° x ?????????????????§?????????????????????
# x ??? 1000 ?????\????????´??°??§??????
# x ??? 0 ?????¨?????\?????????????????¨??????????????????????????????????????????????????????????????£????????????????????????
# Output
# ????????????????????????????????????x ???????????????????????????????????????????????????

# Sample Input
# 123
# 55
# 1000
# 0
# Sample Output
# 6
# 10
# 1

data=[]

while 1:
	temp = int( input() )
	if temp==0:
		break;
	else:
		data.append( temp )

for i in range( len(data) ):
	num = list( map(int, list( str( data[i] ) ) ) )
	print( sum(num) )

Measured memory_bytes: 7588
n = int(input())
sp = [[i+1]+input().split() for i in range(n)]
sp = list(map(lambda x: [x[0], x[1], int(x[2])], sp))
sp.sort(key=lambda x: x[2], reverse=True)
sp.sort(key=lambda x: x[1])

for i in sp:
    print(i[0])

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int a, b, w;
    scanf("%d%d%d", &w, &a, &b);
   	if(b > a + w){
   		printf("%d", b - (a + w));
   	}else if(a > b + w){
   		printf("%d", a - (b + w));
   	}else{
   	  	printf("0");  
   	}
   

}


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

using namespace std;

const int N = 2e4+10; 
int dp[N];

void solve() {
    int M, n;
    cin >> M >> n;
    memset(dp, 0x3f, sizeof dp);
    dp[0] = 0;
    for (int _ = 0; _ < n; _++) {
        int x,y;
        cin >> x >> y;
        for (int i = 0; i+x < N; i++) {
            dp[i+x] = min(dp[i+x], dp[i] + y);
        }
    }
    int res = dp[M];
    for (int i = M; i < N; i++) {
        res = min(res, dp[i]);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

#define forn(n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	if(a > b) {
		forn(a) {
			cout << b;
		}
	}
	else forn(b){
		cout << a;
	}

	cout << "\n";
}

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


int main()
{
    int N;
    cin >> N;
    vector<int> A(N+1);

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

    for (int i = N; i >= 1; --i){
        int sum = 0;
        for (int j = i + i; j<=N; j+=i){
            sum ^= B[j];
        }
        B[i] = sum ^ A[i];
    }

    vector<int> ans;
    for (int i = 1; i <= N; ++i){
        if(B[i])
            ans.push_back(i);
    }
    cout << ans.size() << endl;
    for (int i = 0; i<ans.size(); ++i)
    {
        cout << ans[i] << (i + 1 == ans.size() ? '\n' : ' ');
    }

    return 0;
}

Measured memory_bytes: 3064
N = int(input())
a = list(map(int, input().split()))
c1 = 0
c2 = 0 
c3 = 0
for i in range(N):
    if a[i] == 1:
        c1 += 1
    if a[i] == 2:
        c2 += 1
    if a[i] == 3:
        c3 += 1
dp= [[[0] * (N+1) for i in range(N+1)] for j in range(N+1)]
for k in range(c3+1):
    for j in range(c3+c2-k+1):
        for i in range(N-j-k+1):
            if i == j == k == 0:
                continue
            else:
                res = N
                if i > 0:
                    res += dp[k][j][i-1]*i
                if j > 0:
                    res += dp[k][j-1][i+1]*j
                if k > 0:
                    res += dp[k-1][j+1][i]*k
                dp[k][j][i] = res/(i+j+k)
print(dp[c3][c2][c1])

Measured memory_bytes: 500232
f = True
while True:
    n = int(input())
    if n == 0: break
    tbl = []
    for i in range(n):
        name, w, l, d = list(input().split())
        tbl.append([name, i, 3*int(w)+int(d)])
    if f: f = False
    else: print()
    for i in sorted(tbl, key=lambda x:(-x[2],x[1])): print(i[0], ',', i[2], sep='')


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

int main() {
    int N;
    cin >> N;
    set<string> S;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
}

Measured memory_bytes: 19260
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
	int n;cin >> n;
	vector<string> a(n);
	vector<int> t(n,0);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		int T;cin >> T;
		if(i == 0)t[i] = T;
		else t[i] = t[i-1] + T;
	}
	map<string,int> m;
	for (int i = 0; i < n; ++i)
	{
		m[a[i]] = t[i];
	}
	string x;cin >> x;
	cout << t[n-1] - m[x] << endl;
	return 0;	
}

Measured memory_bytes: 764
#!/usr/bin/env python3
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] + list(accumulate(a))
sb = [0] + list(accumulate(b))
ans = 0
for i in range(n + 1):
    if sa[i] > k:
        continue
    j = bisect(sb, k - sa[i])
    ans = max(ans, i + j)
print(ans - 1)


Measured memory_bytes: 50676
#include<stdio.h>
int math_minus(int,int);
int math_plus(int,int);
void result(int,int,int);
int main(void){
  int i,c1[3],c2[3],x,y,z,t;
  for(i = 0; i < 3; i++){
    scanf("%d",&c1[i]);
  }
  for(i = 0; i < 3; i++){
    scanf("%d",&c2[i]);
  }
  x = math_minus(c1[0],c2[0]);
  y = math_minus(c1[1],c2[1]);
  z = math_plus(c1[2],c2[2]);
  t = math_minus(c1[2],c2[2]);

  if((x + y) > z )printf("4\n");
  if((x + y) == z)printf("3\n");
  if((x + y) < z){
    if((x + y) > t)printf("2\n");
    if((x + y) == t)printf("1\n");
    if((x + y) < t)printf("0\n");
  }

  return 0;
}
int math_minus(int x,int y){
  return (x - y) * (x - y);
}

int math_plus(int x,int y){
  return (x + y) * (x + y);
}



Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
int m1,d1,m2,d2;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>m1>>d1>>m2>>d2;
	if(d2==1)
		cout<<1<<endl;
	else
		cout<<0<<endl;
	return 0;
}


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

int main() {
    int m;
    cin>>m;
    if (m >= 400 && m <= 599)
        cout<<"8";
    else if (m >= 600 && m <= 799)
        cout<<"7";
    else if (m >= 800 && m <= 999)
        cout<<"6";
    else if (m >= 1000 && m <= 1199)
        cout<<"5";
    else if (m >= 1200 && m <= 1399)
        cout<<"4";
    else if (m >= 1400 && m <= 1599)
        cout<<"3";
    else if (m >= 1600 && m <= 1799)
        cout<<"2";
    else
        cout<<"1"; 
    return 0;
}

Measured memory_bytes: 3632
a,b,c,d = map(int,input().split())
n = int(input())
a1 = a*8
b1 = b*4
c1 = c*2
d1 = d
g = n//2
n %= 2
ans = 0
ans += g*(min(a1,b1,c1,d1))
g = n//1
g = int(g)
n = n%1
a1 = a*4
b1 = b*2
c1 = c
ans += g*(min(a1,b1,c1))
g = n//0.5
g = int(g)
n = n%0.5
a1 = a*2
b1 = b*1
ans += g*(min(a1,b1))
g = n//0.25
g = int(g)
n = n%0.25
a1 = a
ans += g*a1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>
#include <stack>
#include <queue>

using namespace std;

class c_roundrobin
{
private:

public:
    c_roundrobin();
    void f_input();
};

c_roundrobin::c_roundrobin()
{
    
}

void c_roundrobin::f_input()
{
    long n;
    int t;
    long i;
    string pn[100000];
    unsigned int pt[100000];
    long sumOfTime;
    queue<string> qu1;  
    queue<long> qu2;
    long temp1;
    string temp2;
    
    cin >> n >> t;
    for ( i = 0; i < n; ++i ){
        cin >> pn[i] >> pt[i];    
    }
    
    for ( i = 0; i < n; ++i ){
        qu1.push(pn[i]);
        qu2.push(pt[i]);   
    }
    
    sumOfTime = 0;
    i = 0;
    for (;;){
        temp2 = qu1.front();
        temp1 = qu2.front(); 
        if (temp1 > t){
            sumOfTime = sumOfTime + t;
            temp1 = temp1 - t;
            qu2.push(temp1);
            qu2.pop();
            qu1.push(temp2);   
            qu1.pop();
        }else{
            sumOfTime = sumOfTime + temp1;
            pn[i]=temp2;
            pt[i]=sumOfTime;
            i = i +1;
            //t= t + (t - temp1);
            qu2.pop();
            qu1.pop();
        }
        if (qu1.empty() || qu2.empty())break;
    }
    
    for ( i = 0; i < n; ++i){
        cout << pn[i] << " " << pt[i] << endl;
    } 
}

int main(){
    
    c_roundrobin roundrobin01;
    roundrobin01.f_input();
    
    return 0;
}

Measured memory_bytes: 6964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=666;
ll a[N],base[N];
int n,_;
char s[N];
bool solve() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",a+i);
	scanf("%s",s+1);
	rep(i,0,60) base[i]=0;
	bool valid=1;
	per(i,1,n+1) {
		ll x=a[i];
		if (s[i]=='1') {
			per(j,0,60) {
				if ((x&(1ll<<j))&&base[j]==0) {
					return 0;
				}
				x=min(x,x^base[j]);
			}
		} else {
			per(j,0,60) {
				if ((x&(1ll<<j))&&base[j]==0) {
					base[j]=x;
					break;
				}
				x=min(x,x^base[j]);
			}
		}
	}
	return 1;
}

int main() {
	for (scanf("%d",&_);_;_--) {
		puts(solve()?"0":"1");
	}
}

Measured memory_bytes: 3700
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<stack>
#include<vector>
using namespace std;
int main()
{
	int n=0;
	int a[120]={0};
	scanf("%d",&n);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		sum+=a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n&&sum%10==0;i++)
		if(a[i]%10!=0)
			sum-=a[i];
	if(sum%10==0)
		printf("0");
	else
		printf("%d",sum);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
//#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

const ll inf = 1LL<<60;
int n, m;
ll L;
ll dis[310][310];

ll ans[310][310];

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n >> m >> L;
    Forn(i, n) Forn(j, n)
    {
        if(i == j) dis[i][j] = ans[i][j] = 0;
        else dis[i][j] = ans[i][j] = inf;
    }
    forn(i, m)
    {
        int x, y, w;
        cin >> x >> y >> w;
        dis[x][y] = dis[y][x] = w;
    }
    Forn(k,n)Forn(i,n)Forn(j,n) if(dis[i][k]+dis[k][j]<dis[i][j]) dis[i][j] = dis[i][k]+dis[k][j];
    Forn(i, n) Forn(j, n) if(dis[i][j] <= L) ans[i][j] = 0;
    Forn(k,n)Forn(i,n)Forn(j,n) if(ans[i][k]+ans[k][j]+1<ans[i][j]) ans[i][j] = ans[i][k]+ans[k][j]+1;

    int q;
    cin >> q;
    Forn(ii, q)
    {
        int x, y;
        cin >> x >> y;
        if(ans[x][y] > 500) cout << -1 << '\n';
        else cout << ans[x][y] << '\n';
    }

}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const lint inf = 1e18;

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  V<> b(n); for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) if (2 * b[i] >= a[i] and a[i] != b[i]) return cout << -1 << '\n', 0;
  V<lint> c(50);
  for (int i = 0; i < 50; i++) c[i] = 1LL << i;
  VV<lint> d; assign(d, 51, 51, inf);
  for (int i = 0; i < 51; i++) d[i][i] = 0;
  auto f = [&]() {
    for (int i = 1; i < 51; i++) for (int k = 1; k < 50; k++) d[i][i % k] = min(d[i][i % k], c[k]);
    for (int k = 0; k < 51; k++) for (int i = 0; i < 51; i++) for (int j = 0; j < 51; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  };
  lint res = 0;
  for (int k = 49; k; k--) {
    f();
    for (int i = 0; i < n; i++) if (d[a[i]][b[i]] >= c[k]) {
      res += c[k];
      c[k] = 0;
      break;
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] r = new int[n];
        for (int i = 0; i < n-1; i++) {
            int temp = sc.nextInt();
            r[temp-1]++;
        }
        for (int i = 0; i < n; i++) {
            System.out.println(r[i]);
        }
    }
}


Measured memory_bytes: 70492
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define X real()
#define y imag()

bool resuelveCaso(vb const& res) {
	int n;
	cin >> n;
	if (!cin) return false;
	if (res[n]) cout << "Yes\n";
	else cout << "No\n";

	return true;
}

int main() {
	vb res(101);
	res[0] = true;

	for (int i = 0; i <= 100; i = i+4) {
		res[i] = true;
	}

	for (int i = 7; i <= 100; i = i + 4) {
		res[i] = true;
	}

	for (int i = 14; i <= 100; i = i + 4) {
		res[i] = true;
	}

	for (int i = 21; i <= 100; i = i + 4) {
		res[i] = true;
	}

	for (int i = 0; i <= 100; i = i + 7) {
		res[i] = true;
	}

	for (int i = 4; i <= 100; i = i + 7) {
		res[i] = true;
	}

	for (int i = 8; i <= 100; i = i + 7) {
		res[i] = true;
	}

	for (int i = 12; i <= 100; i = i + 7) {
		res[i] = true;
	}

	for (int i = 16; i <= 100; i = i + 7) {
		res[i] = true;
	}

	for (int i = 20; i <= 100; i = i + 7) {
		res[i] = true;
	}

	for (int i = 24; i <= 100; i = i + 7) {
		res[i] = true;
	}

	while (resuelveCaso(res)) {}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
    min_p = min(p[i - 1],p[i],p[i + 1])
    max_p = max(p[i - 1],p[i],p[i + 1])
    if p[i] != min_p and p[i] != max_p:
        count += 1
print(count)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int N, K;
int h[300];

vector<int> comp;

long long dp[301][301][301];


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

	cin >> N >> K;
	rep(i, N)cin >> h[i];

	comp.push_back(0);
	rep(i, N)comp.push_back(h[i]);
	sort(all(comp));
	uniq(comp);

	rep(i, N) {
		h[i] = lower_bound(all(comp), h[i]) - comp.begin();
	}

	const long long llinf = 1LL << 60;
	rep(i, N + 1)rep(j, N + 1)rep(k, K + 1)dp[i][j][k] = llinf;

	dp[0][0][0] = 0;
	rep(i, N) rep(j, N + 1)rep(k, K + 1) if(dp[i][j][k] != llinf){
		dp[i + 1][h[i]][k] = min(dp[i + 1][h[i]][k], dp[i][j][k] + (j < h[i] ? comp[h[i]] - comp[j] : 0));
		if (k < K) {
			dp[i + 1][j][k + 1] = min(dp[i + 1][j][k + 1], dp[i][j][k]);
		}
	}
	long long ans = llinf;
	rep(j, N + 1)rep(k, K + 1)
		ans = min(ans, dp[N][j][k]);

	cout << ans << endl;

	return 0;
}

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

int main() {
	long long int n,k,a,b;
	cin>>n>>k;
	a=n%k;
	b=k-a;
	if(b<a){
		cout<<b;
	}else{
		cout<<a;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
  {
     int n,a=0,w=0,t=0,r=0;
     cin>>n;
     string s;
     while(n--)
     {
       cin>>s;
       
       if(s.compare("AC")==0)
       a++;
       else if(s.compare("WA")==0)
       w++;
       else if(s.compare("TLE")==0)
       t++;
       else if(s.compare("RE")==0)
       r++;
     }
     
     cout<<"AC x "<<a<<endl;
     cout<<"WA x "<<w<<endl;
     cout<<"TLE x "<<t<<endl;
     cout<<"RE x "<<r<<endl;
     
  }

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
vector<long long> ab(0);
int x, y, z, k;
vector<long long> a, b, c;
int ck (long long val) {
  int ret = 0;
  for (int i = 0; i < z; i++) {
    ret += ab.end() - lower_bound(ab.begin(), ab.end(), val - c[i]);
  }
  return ret;
}
int main() {
  cin >> x >> y >> z >> k;
  a.resize(x);
  b.resize(y);
  c.resize(z);
  for (int i = 0; i < x; i++) cin >> a[i];
  for (int i = 0; i < y; i++) cin >> b[i];
  for (int i = 0; i < z; i++) cin >> c[i];
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      ab.push_back(a[i] + b[j]);
    }
  }
  sort(ab.begin(), ab.end());
  long long ok(0), ng(1e11), md;
  while (ng - ok > 1) {
    md = (ng + ok) >> 1;
    if (ck(md) >= k) ok = md;
    else ng = md;
  }
  long long val = ok;
  vector<long long> ret;
  for (int i = 0; i < z; i++) {
    for (auto it = lower_bound(ab.begin(), ab.end(), val - c[i]); it != ab.end(); it++) {
      ret.push_back(*it + c[i]);
    }
  }
  sort(ret.begin(), ret.end(), greater<long long>());
  for (int i = 0; i < k; i++) {
    cout << ret[i] << endl;
  }
  return 0;
}

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

int main()
{
  char c;
  cin>>c;
  if(c == 'a'||c == 'e'||c == 'o'||c == 'u'||c == 'i'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" <<endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstring>
#include<queue>
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
const int MAXN=1005;
const long double EPS=1e-13;
int n;
long double S[2],E[2];
long double d[MAXN];
bool vis[MAXN];
struct circle
{
	long double x,y,r;
}C[MAXN];
long double jl(int i,int j)
{
	long double o=sqrt((C[i].x-C[j].x)*(C[i].x-C[j].x)+(C[i].y-C[j].y)*(C[i].y-C[j].y));
	o=o-C[i].r-C[j].r;
	if(o<EPS)
		o=0.0;
	return o;
}
void dj(int s,int t)
{
	fill(d,d+MAXN,-1);
	int mi=s;
	vis[s]=1;
	d[s]=0.0;
	while(1)
	{
		int k=mi;
		mi=-1;
		if(k==t)
			break;
		vis[k]=1;
		for(int i=1;i<=n+2;i++)
		{
			if(vis[i])
				continue;
			long double o=jl(k,i);
			if((d[i]==-1)||d[k]+o<d[i])
			{
				d[i]=d[k]+o;
			}
			if(d[i]!=-1&&(mi==-1||d[mi]>d[i]))
				mi=i;
		}
	}
}
int main()
{
	scanf("%Lf %Lf %Lf %Lf",&S[0],&S[1],&E[0],&E[1]);
	scanf("%d",&n);
	C[1].x=S[0];
	C[1].y=S[1];
	C[1].r=0;
	C[n+2].x=E[0];
	C[n+2].y=E[1];
	C[n+2].r=0;
	for(int i=2;i<=n+1;i++)
	{
		scanf("%Lf %Lf %Lf",&C[i].x,&C[i].y,&C[i].r);
	}
	dj(1,n+2);
	cout<<setiosflags(ios::fixed)<<setprecision(10)<<d[n+2];
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N, A, B = LI()
print(min(A*N, B))

Measured memory_bytes: 38512
S=gets.chars
def w
  i=0
  return [i+1, i+2] if i=S.each_cons(2).to_a.index{|a,b|a==b}
  return [i+1, i+3] if i=S.each_cons(3).to_a.index{|a,b,c|a==c}
  [-1, -1]
end
puts w*" "


Measured memory_bytes: 16764
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int h,w,i,j,x=0,y=0;
	cin>>h>>w;
	char s[h][w];
	int a[h][w]={0};
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			cin>>s[i][j];
			if(s[i][j]=='#')
			{
				x++;
			}
		}
	}
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(s[i][j]=='#')
			{
			   if(s[i-1][j]=='#' && i-1>=0)
				{
					a[i][j]=1;	
				}
				if(s[i+1][j]=='#' && i+1<h)
				{
					a[i][j]=1;
				}
				if(s[i][j-1]=='#' && j-1>=0)
				{
					a[i][j]=1;		
				}		
				if(s[i][j+1]=='#' && j+1<w)
				{
					a[i][j]=1;
				}
			}
			
		}
	}
	
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(s[i][j]=='#' && a[i][j]==1)
			{
				y++;
			}
		}
	}
	if(x==y)
	{
		cout<<"Yes"<<endl;
		
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
	string N;
	cin >> N;
	

	if (N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[3] == N[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
from bisect import bisect_left, bisect_right

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

neg = bisect_left(A, 0)
pos = bisect_right(A, 0)

def less(x):
    res = 0
    b = 0
    for i in range(0, neg):
        while b != N and A[i] * A[b] >= x:
            b += 1
        while b != 0 and A[i] * A[b - 1] < x:
            b -= 1
        res += max(i - b, 0)
    for i in range(neg, pos):
        if x > 0:
            res += i
    for i in range(pos, N):
        while b != N and A[i] * A[b] < x:
            b += 1
        while b != 0 and A[i] * A[b - 1] >= x:
            b -= 1
        res += min(b, i)
    return res

l = - (10 ** 18 + 1)
r = - l
while l + 1 < r:
    m = (l + r) // 2
    if less(m) < K:
        l = m
    else:
        r = m
print(l)


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

using namespace std;

#define MAX 100000

int main(){

	int n,k;
	int in;
	int cnt,a;
	int ans;
	set<int> card;
	int white;

	while(1){

		cin>>n>>k;
		if(n==0&&k==0) break;

		white=0;
		for(int i=0;i<k;i++){
			cin>>in;
			if(in!=0){
				card.insert(in);
			} else{
				white++;
			}
		}

		ans=0;
		for(int i=1;i<=n-ans;i++){
			if(card.find(i)!=card.end()){
				cnt=0;
				a=white;
				for(int j=0;j<=n;j++){
					if(card.find(i+j)!=card.end()) cnt++;
					else if(a>0) a--,cnt++;
					else break;

				}
				if(ans<cnt) ans=cnt;
			}
		}

		cout<<ans<<endl;

		if(!card.empty()) card.clear();

	}
	return 0;
}

Measured memory_bytes: 4944
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(i == 0) {
				System.out.print(c);
			}
			if(i == s.length() - 1) {
				System.out.print(s.length() - 2);
				System.out.println(c);
			}
		}
	}
}


Measured memory_bytes: 21844
#include <cmath>
#include <iostream>
#include <vector>

int main() {
    int n;
    std::cin >> n;
    std::vector<int64_t> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];

    if (std::find(a.begin(), a.end(), 0) != a.end()) {
        std::cout << 0 << std::endl;
        return 0;
    }

    double log = 0;
    int64_t sum = 1;
    for (int i = 0; i < n; i++) {
        sum *= a[i];
        log += std::log10(a[i]);
    }
    if ((log > 18) || (sum > int64_t(1e18)))
        std::cout << -1 << std::endl;
    else
        std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
using namespace std;

template<class T>inline bool chmax(T&a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T&a, T b) { if (a > b) { a = b; return 1; }return 0; }
int n, m;


#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = 1 << 29;




int main() {
	
	
	map<string, int> mp ;
	string s[101], t[101];

	cin >> n;
	
	rep(n) {
		cin >> s[i];

		if (mp.count(s[i]))mp[s[i]] += 1;
		else mp[s[i]] = 1;

	}
	cin >> m;
	rep(m) {
		cin >> t[i];
		if (mp.count(t[i]))mp[t[i]] -= 1;
		else mp[t[i]] = -1;
	}

	int ans = 0;
	for (auto x : mp) {
		ans = max(ans, x.second);
	}
	cout << ans << endl;
    

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long mod = 1000000007;

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

	int a, b;
	cin >> a >> b;

	for (int i = 1; i <= 3; ++i) {
		if (i != a && i != b)cout << i << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int main(void){
  int a, b,i=0, j=0,k,l;
  int p[N], q[N];

  while(scanf("%d %d", &a, &b), a!=0 && b!=0){
    p[i] = a;
    q[i] = b;
    i++;
  }

  while(j<i){
    for(k=1; k<=p[j]; k++){
      for(l=1; l<=q[j]; l++){
        if((k%2!=0 && l%2!=0) || (k%2==0 && l%2==0))
          printf("#");
        else
          printf(".");
      }
      printf("\n");
    }
    printf("\n");
    j++;
  }

  return 0;
}



Measured memory_bytes: 2108
def solve(A,n):
    x=2**n
    for i in range(x):
        count=A[0]
        for j in range(n):
            if (i>>j) & 1:
                count+=A[j+1]
            else:
                count-=A[j+1]
        if count==7:
            return i

n=3
A=list(map(int,input()))
i=solve(A,n)
ans=str(A[0])
for j in range(n):
    if (i>>j) & 1:
        ans+="+"+str(A[j+1])
    else:
        ans+="-"+str(A[j+1])
ans+="=7"
print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    set<string> se;
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        string s;
        cin >> s;
        se.insert(s);
    }
    cout << se.size() << "\n";

    return 0;
}

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

int main() {
  
  int N,K;
  cin >> N >> K;
  vector<int> num(N);
  
  for(int i=0; i<N; i++){
    cin >> num.at(i);
  }
  sort(num.begin(), num.end());
  
  int min=1000000000;
  for(int i=0; i<(N-K+1); i++){
    if(min>(num.at(i+K-1)-num.at(i))){min=(num.at(i+K-1)-num.at(i));}
  }
  
  cout << min << endl;
}


Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules ! vec_md { ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) } ; ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] } ; ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] } ; }

fn main() {
    input! {
        n: u64, k: usize,
        d: [u64;k]
    }
    let dset = d.into_iter().collect::<std::collections::HashSet<_>>();
    let mut dc: Vec<u64> = vec![];
    for i in 0..10 {
        if !dset.contains(&i) {
            dc.push(i);
        }
    }
    let dc_set = dc .into_iter().collect::<std::collections::HashSet<_>>();
    for i in n..100_000 {
        if is_ok(i, &dc_set) {
            println!("{}", i);
            break;
        }
    }
}

fn is_ok(t: u64, dc_set: &std::collections::HashSet<u64>) -> bool {
    if t == 0 {
        return true;
    }
    if !dc_set.contains(&(t % 10)) {
        false
    } else {
        is_ok(t / 10, dc_set)
    }
}

Measured memory_bytes: 4352