akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++14

int main(){
    ll n;cin>>n;
    ll bottle[MAX];
    memset(bottle,0,sizeof(bottle));
    for(ll x=1;x<=n;x++){
        for(ll y=x;y<=n;y++){
            for(ll z=y;z<=n;z++){
                ll i=x*x+y*y+z*z+x*y+z*(x+y);
                if(i>n)break;
                if(z==x && y==x)bottle[i]++;
                else if(y==z || y==x)bottle[i]+=3;
                else bottle[i]+=6;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout<<bottle[i]<<endl;
    }
}
    

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

void LCS(string X, string Y){
    X = ' ' + X; //＋演算子でX[0]に空白を挿入
    Y = ' ' + Y;
    int C[X.length()][Y.length()];
    
    for (int i = 0; i < X.length(); i++){
        C[i][0] = 0;
    }
    for (int i = 0; i < Y.length(); i++){
        C[0][i] = 0;
    }
    
    for (int i = 1; i < X.length(); i++){
        for (int j = 1; j < Y.length(); j++){
            if ( X[i] == Y[j] ) C[i][j] = C[i-1][j-1] + 1;
            else C[i][j] = max(C[i][j-1], C[i-1][j]);
        }
    }
    cout << C[X.length()-1][Y.length()-1] << endl;
    
}

int main(){
    int n;
    string X, Y;
    cin >> n;
    
    for (int i = 0; i < n; i++ ){
        cin >> X;
        cin >> Y;
        LCS(X, Y);
    }
    
    return 0;
}



Measured memory_bytes: 6996
import * as fs from 'fs';

// main
function main(input: string[]) {
    // param
    var n: number = 0;
    var m: number = 0;
    var ans: number = 0;
    // init
    [n, m] = input.shift().split(" ").map(x => Number(x));
    // solve
    ans = n * (n - 1) / 2 + m * (m - 1) / 2
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        var input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            input = lines;
            main(input);
        });
    }
}
entrypoint();


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

struct Edge {
    int to, cnt, cost;
    Edge(int t, int s, int c) : to(t), cnt(s), cost(c) {}
};

bool operator<(const Edge &a, const Edge &b) { return a.cost >= b.cost; }

int dist[100005][4];  // i 番目に j 回の反復で来た
const int INF = 1e9;

int main() {
    int n, m;
    cin >> n >> m;
    vector<Edge> g[n];
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(Edge(v, 0, 1));
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    for (int i = 0; i < 100005; i++) {
        for (int j = 0; j < 4; j++) {
            dist[i][j] = INF;
        }
    }
    priority_queue<Edge> que;
    que.push(Edge(s, 0, 0));
    dist[s][0] = 0;
    vector<vector<bool> > used(n, vector<bool>(4, false));
    while (!que.empty()) {
        int v = que.top().to;
        int cnt = que.top().cnt;
        int cost = que.top().cost;
        que.pop();
        if (dist[v][cnt] < cost) continue;
        if (used[v][cnt]) continue;
        used[v][cnt] = true;
        for (int i = 0; i < g[v].size(); i++) {
            Edge e = g[v][i];
            int nxc = cost + e.cost;
            if (cnt + 1 == 3) {
                if (dist[e.to][cnt + 1] > nxc) {
                    dist[e.to][cnt + 1] = nxc;
                    que.push(Edge(e.to, (cnt + 1) % 3, nxc));
                }
            } else {
                que.push(Edge(e.to, (cnt + 1) % 3, cost));
            }
        }
    }
    if (dist[t][3] == INF) {
        cout << -1 << endl;
    } else {
        cout << dist[t][3] << endl;
    }
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,T,i,ans=1;cin>>N;
  REP(i,N){cin>>T;ans/=__gcd(ans,T);ans*=T;}
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		String s[] = new String[N];
		for(int i = 0; i < N; i++){
			s[i] = sc.next();
		}
		Arrays.sort(s);
		for(int i = 0; i < N; i++){
			System.out.print(s[i]);
		}
		System.out.println("");
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
  LL N, x;
  cin >> N >> x;
  vector<LL> a(N);
  for(auto& i: a) cin >> i;
  auto b = a;
  LL res = 1e18;
  for(auto i = 0; i < N; ++i) {
    auto sum = x*i;
    for(auto j = 0; j < N; ++j) sum += (b[j] = min(b[j], a[(j-i+N)%N]));
    res = min(res, sum);
  }
  cout << res << endl;
}


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

	

int main() {
  
	int N, M, C;
	cin >>N >>M >>C;
	
	vector<int> B(M);
	for(int i=0; i<M; i++){
		
		cin >>B.at(i);
		
	}
	
	vector<vector<int>> AB(N,vector<int>(M));
	for(int i=0; i<N; i++){
		
		for(int j=0; j<M; j++){
			
			cin >>AB.at(i).at(j);
			
		}
		
	}
	
	
	int total=0;
	int ans=0;
	
	for(int i=0; i<N; i++){
		
		total=0;
		for(int j=0; j<M; j++){
			
			total+=AB.at(i).at(j)*B.at(j);
			
		}
		
		total+=C;
		
		if(total>0){
			
			ans++;
			
		}
		
	}
	
	cout <<ans <<endl;
	
  
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <iostream>
#include <unordered_set>
#include <map>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    if ((n + 1) / 2 >= k) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, long long K, std::vector<long long> H){
    if(K >= N){
        cout<< 0 << endl; return;
    }
    sort(ALL(H)); reverse(ALL(H));
    if(K > 0){
        REP(i, K){
            H[i]=0;
        }
    }
    ll sum=0;
    REP(i, N) sum+=H[i];
    cout<<sum<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, K, std::move(H));
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
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();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,M;
  string S,T;
  cin>>N>>M>>S>>T;
  bool CAN=true;
  
  ll Ns=N/gcd(N,M),Ms=M/gcd(N,M);
  
  for(int i=0; i<gcd(N,M); ++i){
    if(S[Ns*i]!=T[Ms*i]) CAN=false;
  }
  
  if(CAN) co(lcm(N,M));
  else co(-1);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)  
#define rep(i,n) for(long long int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int maxInt = 2147483647;
const int mx=100005;
int dp[2*mx],a[mx];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    ref(i,1,n)cin >> a[i];
    ref(i,0,k){
    	if(dp[i]==0){
    		ref(j,1,n){
    			dp[i+a[j]]=1;
    		}
    	}
    }
    if(dp[k])cout <<"First"<<endl;
    else cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 1024
#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<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 main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	string s;
	cin>>s;
	int a,b,c;
	a=b=c=0;
	for (char ch :s){
		if (ch=='a')a++;
		else if (ch=='b')b++;
		else c++;
	}

	int n = (s.size()+2)/3;
	int m = s.size()/3;
	//cout << a << ' ' << b << ' ' << c << ' ' << n << ' '<<m<<endl;
	cout << (m<=a && a<=n && m<=b && b<=n && m<=c && c<=n?"YES":"NO")<<endl;


	return 0;
}

Measured memory_bytes: 512
N,K,Q = map(int, input().split())
List = [int(input()) for i in range(Q)]
PList=[K-Q]*N
for i in range(0,Q):
    PList[(List[i])-1]+=1
for j in range(0,N):
    if PList[j]>0:
        print("Yes")
    else:
        print("No")

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



int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i,n) cin >> a[i+1];

    int ans = 0;
    int light = 1;
    rep(i,n){
        light = a[light];
        ans++;
        if(light == 2) {
            break;
        }
        
    }

    if(light == 2) cout << ans << endl;
    else cout << -1 <<endl;

}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <limits.h>

int main()
{
    int N, K;
    std::cin >> N >> K;

    std::vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> H[i];
    }
    std::sort(H.begin(), H.end());

    int min = INT_MAX;

    for (int i = 0; i < N - K + 1; i++)
    {
        int r = H[i + K - 1];
        int l = H[i];
        min = std::min(min, r - l);
    }
    std::cout << min << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int N;
void enu(string t) {
	if (t.size() == N) {
		cout << t << endl;
	}
	else {
		int cnt = 1;
		string tmp = t;
		sort(tmp.begin(), tmp.end());
		for (int i = 0; i < t.size() - 1; i++) {
			if (tmp[i] != tmp[i + 1]) cnt++;
		}
		for (int i = 0; i < cnt + 1; i++) {
			tmp = t;
			char c = 'a' + i;
			tmp.push_back(c);
			enu(tmp);
		}
	}
}
int main()
{
	cin >> N;
	enu("a");
}


Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
void Yes(){
    cout << "Yes" << endl;
    exit(0);
}
void No(){
    cout << "No" << endl;
    exit(0);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n){
        cin >> s[i];
        string t;
        for(auto x :s[i]){
            if(x==')' and t.size() and t.back()=='(')t.pop_back();
            else t += x;
        }
        s[i] = move(t);
    }
    int a = 0, b = 0;
    vector<pair<int,int>>d, e;
    rep(i,n){
        if(s[i].size()==0)continue;
        if(s[i].front()=='(')a += s[i].size();
        else if(s[i].back()==')')b += s[i].size();
        else{
            int cnt = 0, cnt2 = 0;
            for(auto x : s[i])if(x == ')')cnt++;
            cnt2 = (int) s[i].size() - cnt;
            if(cnt <= cnt2)d.emplace_back(cnt, cnt2);
            else e.emplace_back(cnt, cnt2);
        }
    }
    sort(d.begin(), d.end());
    for(auto &x : d){
        if(a - x.first < 0)No();
        a -= x.first;
        a += x.second;
    }
    for(auto &x : e){
        if(a - x.first < 0)No();
        a -= x.first;
        a += x.second;
    }
    a -= b;
    if(a == 0)Yes();
    else No();
}


Measured memory_bytes: 34796
#include <bits/stdc++.h>
using namespace std;
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 1; i < n; ++i) {
        if(s[i] != s[i-1]) ++cnt;
    }
    cnt = n-cnt-1;
    cout << min(n-1, cnt+2*k);
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int N,I,max=0;
    scanf("%d",&N);
    int p[N],P=0;
    for(int i=0;i<N;i++)scanf("%d",&p[i]);
    for(int i=0;i<N;i++)if(max<p[i]){
        max=p[i];
        I=i;
    }
    for(int i=0;i<N;i++){
        if(I==i)p[i]/=2;
        P=P+p[i];
    }
    printf("%d\n",P);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
robotList=[]
for i in range(n):
  x,l = map(int,input().split())
  s = max(x-l,0)
  t = min(10**9,x+l)  
  robotList.append([t,s])
  
robotList.sort()

count = 0
tmp = 0
for robot in robotList:
  if robot[1] >= tmp:
    count += 1
    tmp = robot[0]

print(count)


Measured memory_bytes: 20096
#include <stdio.h>

int main(void)
{
	int w, m;
	
	while (1){
		
		scanf("%d", &w);
		
		if (w == -1){
			break;
		}
		
		m = 1150;
		
		if (w > 30){
			
			m += 160 * (w - 30);
			w = 30;
		}
		if (w > 20){
			m += 140 * (w - 20);
			w = 20;
		}
		if (w > 10){
			m += 125 * (w - 10);
		}
		printf("%d\n", 4280 - m);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+5;
int n,a,b;
void solve()
{
    if(a+b-1>n||(ll)a*b<n){printf("-1\n");return;}
    while(n>0)
    {
        int x=min(a,n-b+1);
        for(int i=n-x+1;i<=n;i++)
            printf("%d ",i);
        n-=x;
        b--;
    }
    printf("\n");
}
int main()
{
    while(scanf("%d%d%d",&n,&a,&b)!=EOF)
        solve();
}


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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++) cin >> S.at(i);
    map<string, int> cnt;
    for(int i=0; i<N; i++) cnt[S.at(i)]++;
    int max_cnt = 0;
    for(auto itr=cnt.begin(); itr!=cnt.end(); itr++){
        if(max_cnt < itr->second) max_cnt = itr->second;
    }
    for(auto itr=cnt.begin(); itr!=cnt.end(); itr++){
        if(itr->second == max_cnt) cout << itr->first << endl;
    }
}

Measured memory_bytes: 25112
#include<bits/stdc++.h>
using namespace std;
string s;
int ans=100,now,mx;
char i;
main(){
  cin>>s;
  for(i='a';i<='z';i++){
    now=0,mx=0;
    for(auto c:s){
      if(c==i)now=0;
      else mx=max(mx,++now);
    }
    ans=min(ans,mx);
  }
  cout<<ans<<endl;
}


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

#define int long long

using namespace std;



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string cad;
    cin >> cad;

    int sum = 0;

    for(int i = 0 ; i < cad.size() ; i++)
    {
    	sum += cad[i]-'0';
    }

    if(sum%9 == 0)
    {
    	cout << "Yes" << '\n';
    }
    else
    {
    	cout << "No" << '\n';
    }

    return 0;
}

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

using namespace std;

int main()
{
    int k,n,m=0,d;

    cin>>k>>n;

    int eva[n+1];

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

        if(i==n-1)
        {
            int d1=eva[i]-eva[i-1];
            int d2=(k-eva[i])+(eva[0]-0);

            d=max(d1,d2);

            if(d>m)
                m=d;
            //cout<<m<<endl;
        }
        else if(i!=0)
        {
            d=eva[i]-eva[i-1];

            if(d>m)
                m=d;
            //cout<<m<<endl;
        }
    }

    cout<<k-m<<endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int N = scn.nextInt();
        int count = 0;
        for(int i=0; i<N; i++) {
            int a = scn.nextInt();
            int b = scn.nextInt();
            if(a == b) {
                count++;
            } else {
                count = 0;
            }
            if(count == 3) {
                break;
            }
        }
        if(count == 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 36060
#include<bits/stdc++.h>
using namespace std;
int a,b,c,l;
int main(){
cin>>a>>b;
c=b;
while(c>0)
c/=10,l++;
a=a*pow(10,l)+b;
if(sqrt(a)==floor(sqrt(a))) cout<<"Yes";
else cout<<"No";}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(b == 100){
    b++;
  }
  if(a == 0){
    cout << b << endl;
  }else{
    long long ans = pow(100, a) * b;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
using VI = vector<int>;
// --------------------------------------------------------


// Verify: https://atcoder.jp/contests/abc150/tasks/abc150_c
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    VI P(N); REP(i,N) cin >> P[i];
    VI Q(N); REP(i,N) cin >> Q[i];

    VI R(N); iota(ALL(R), 1);
    int i = 1;
    int a = 1, b = 1;
    do {
        if (equal(ALL(P), ALL(R))) a = i;
        if (equal(ALL(Q), ALL(R))) b = i;
        i++;
    } while (next_permutation(ALL(R)));

    int ans = abs(a - b);
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3660
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b,ans;
  cin >> n >> a >> b;
  if(!(abs(a-b)%2)) {
    cout << abs(a-b)/2 << endl;
  }
  else {
    ans=min({a-1,b-1,n-a,n-b});
    cout << ans+1+(abs(a-b)-1)/2 << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  int A = N;
  
  while ((A / 10.0) > 0) {
    sum += A % 10;
    A /= 10;
  }
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
S = input()
for i in range(len(S)):
    if i%2 == 0:
        if S[i] not in ['R', 'U', 'D']:
            print('No')
            break
    else:
        if S[i] not in ['L', 'U', 'D']:
            print('No')
            break
else:
    print('Yes')

Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))

change=0
for i in range(N):
    mini = i
    for j in range(i+1,N):
        if A[mini]>A[j]:
            mini = j 
    if A[i] != A[mini]:
        A[i],A[mini] = A[mini],A[i]
        change += 1

print(" ".join(map(str,A)))
print(change)


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    cin >> vec[i];
  }
  int count = 0;
  for(int i=0; i<n; i++){
    if(vec[i]>=k) count++;
  }
  cout << count << endl;
}
  

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


void solve(long long A, long long B, long long N){
    long long x = min(N, B-1);
    cout << ((A*x)/B) - A*(x/B) << endl;
    return;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>


using namespace std;


int main()
{
	int m, n;
	cin >> m >> n;
	if (m == n)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int X, Y, res;

int main() {
	cin >> X >> Y;
	if (X == 1 && Y == 1) {
		res = 400000;
	}
	if (X == 1)res += 300000;
	if (X == 2)res += 200000;
	if (X == 3)res += 100000;
	if (Y == 1)res += 300000;
	if (Y == 2)res += 200000;
	if (Y == 3)res += 100000;
	cout << res << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
	int n, ans = 0;
	string s;
	cin >> n >> s;
	for (int i = 1; i < n; i++) {
		if (s[i - 1] != s[i]) {
			ans++;
		}
	}
	cout << ans+1 << endl;
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std; 
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
 
typedef long long int ll; 
typedef long double ld; 

ll mod = 1e9+7;

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

ll mul(ll a, ll b){
	a = a%mod;
	b = b%mod;
	return (mod+(a*b)%mod)%mod;
}

int main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	
	ll arr[n];
	ll su = 0;
	for(ll i=0;i<n;i++){
		cin>>arr[i];
		su += arr[i];
	}
	ll ans = 0;
	for(ll i=0;i<n;i++){
		su-=arr[i];
		ans = add(ans, mul(arr[i], su));
	}	
	cout<<ans<<endl;
}


Measured memory_bytes: 5176
A,B,Q=gets.split.map &:to_i
I=1<<60
S=[-I]+A.times.map{gets.to_i}+[I]
T=[-I]+B.times.map{gets.to_i}+[I]
Q.times{
	x=gets.to_i
	b=S.bsearch_index{|e|x<e}||S.size
	d=T.bsearch_index{|e|x<e}||T.size
	r=I
	[S[b-1],S[b]].each{|s|[T[d-1],T[d]].each{|t|
		r=[r,(t-s).abs+(s-x).abs,(s-t).abs+(t-x).abs].min
	}}
	p r
}

Measured memory_bytes: 8060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    if(n<105){
        cout << 0 << endl;
        return 0;
    }
    ll res = 0;
    for(ll i=105;i<=n;i+=2){
        ll temp = 0;
        for(ll j=1;j<=i;j+=2){
            if(i%j==0) temp++;
        }
        if(temp==8) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;
using namespace std;

int LIS(int* A,int L){
  int DP[L];
  fill(DP,DP+L,INF);
  rep(i,L) *upper_bound(DP,DP+L,A[i])=A[i];
  return lower_bound(DP,DP+L,INF)-DP;
}
int LCM(int a,int b){
  int tmp,r,x;
  x=a*b;
  if(a<b) tmp=a,a=b,b=tmp;
  r=a%b;
  while(r!=0) a=b,b=r,r=a%b;
  x=x/b;
  return x;
}
int GCD(int a,int b){
  return (a*b)/LCM(a,b);
}

int main(void){
  int N;
  cin >> N;
  int a[N],b[N],c[N],dp[N][3];
  rep(i,N) cin >> a[i] >> b[i] >> c[i];
  dp[0][0]=a[0],dp[0][1]=b[0],dp[0][2]=c[0];
  for(int i=1;i<N;i++){
    dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
  }
  cout << max3(dp[N-1][0],dp[N-1][1],dp[N-1][2]) << endl;
}

Measured memory_bytes: 2560
import fractions
import math
 
N, M = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
 
def lcm(a, b):
    return a * b // fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num //= 2
        count += 1
    return count

two_num = check_two(a[0])

for i in range(1, len(a)):
    if two_num != check_two(a[i]):
        print(0)
        exit()
 
my_lcm = a[0]
for i in range(1, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > M:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

class UnionFind{
  public:
  //親の番号を格納する 親だった場合-1*集合のサイズ
  vector<int> Parent;

  //コンストラクタ 初めはバラバラの状態
  UnionFind(int N){
    Parent = vector<int>(N,-1);//要素数N,要素の値-1で初期化
  }

  //Ａがどのグループに属しているか調べる
  int root(int A){
    if(Parent[A] < 0)return A;//Aが親だったらA自身を返す
    return Parent[A] = root(Parent[A]);//親に繋ぎなおす
  }

  //頂点数を調べる
  int size(int A){
    return -Parent[root(A)];//Aの根×-1=集合のサイズ
  }

  //AとBをくっつける
  bool connect(int A, int B){
    //Aの根とBの根をくっつける
    A = root(A);
    B = root(B);
    if(A==B)return false;//既に同じグループならそのままでfalseを返す

    //Aのサイズ>=Bのサイズとする  
    if(size(A)<size(B))swap(A,B);

    Parent[A] += Parent[B];//AのサイズにBのサイズを足す
    Parent[B] = A;//Bの親をAに変更する
    return true;
  }

  //AとBが同じグループかどうか調べる
  bool same(int A,int B){
    if(root(A)==root(B))return true;
    else return false;
  }

};

int main(){
  int N,M;
  cin >> N >> M;
  int X[100010],Y[100010],Z[110];

  UnionFind UF(N);

  map<int,bool> check;

  rep(i,M){
    cin >> X[i] >> Y[i] >> Z[i];
    X[i]--;Y[i]--;
    UF.connect(X[i],Y[i]);
    //cout << X[i] << Y[i] << endl;
  }
  int ans = 0;
  rep(i,N){
    if(!check[UF.root(i)]){
      ans++;
      check[UF.root(i)]=1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6016
def main():
    N = int(input())
    # [4, 3, 3, 1, 3, 2]
    A = [int(input()) for _ in range(N)]
    current_max = max(A[1:N])
    current_max_index = A.index(current_max)
    # print('---')
    print(current_max)
    previous_max = current_max
    previous_max_index = current_max_index
    for i in range(1, N):
        # A_tmp = A[0:i] + A[i+1:N]
        if i != previous_max_index:
            current_max = max([A[i-1], previous_max])
            current_max_index = previous_max_index
        else:
            current_max = max(A[0:i] + A[i+1:N])
            current_max_index = A.index(current_max)
        print(current_max)
        previous_max = current_max
        previous_max_index = current_max_index


if __name__ == '__main__':
    main()


Measured memory_bytes: 15484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n, r;
    cin >> n >> r;
    int rate;
    if (n > 10) {
        rate = r;
    } else {
        rate = r + (100 * (10 - n));
    }
    cout << rate << endl;
    return 0;
}

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

int main() {
  long long N;
  cin>>N;
  long long A,B;
  for(long long i=1;i<=sqrt(N)+1;i++){
    if(N%i==0){
      A=i;
      B=N/i;
    }
  }
  cout<<A+B-2<<endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
 
int main(void) {
 
	// ??????????????\????????????2????????°?????\???????????°
	int line, column;
	scanf("%d %d", &line, &column);
	
	// ???????????????????????????
	int grid[line+1][column+1];
	
	for(int cnt1 = 0; cnt1 <= line; cnt1++) {
	  
	  for(int cnt2 = 0; cnt2 <= column; cnt2++) {
	  	
	    grid[cnt1][cnt2] = 0;
	    
	  }
	}
	
	// ????????????????????\??????
	for(int cnt1 = 0; cnt1 <= line; cnt1++) {
		
		if(cnt1 < line) {
			
			for(int cnt2 = 0; cnt2 <= column; cnt2++) {
				
				if(cnt2 < column) {
				
					scanf("%d", &grid[cnt1][cnt2]);
					printf("%d ", grid[cnt1][cnt2]);
					
					// ??????????????????????????????????¨??????\??????
					grid[cnt1][column] += grid[cnt1][cnt2];
					
					// ??????????????????????????????????¨??????\??????
					grid[line][cnt2] += grid[cnt1][cnt2];
					
				// ??????????¨??????????	
				} else {
					
					printf("%d\n", grid[cnt1][cnt2]);
					grid[line][column] += grid[cnt1][cnt2];
				}
			}
			
		} else {
			
			for(int cnt2 = 0; cnt2 <= column; cnt2++) {
				
				if(cnt2 != column) {
					
					printf("%d ", grid[cnt1][cnt2]);
					
				} else {
					
					printf("%d\n", grid[cnt1][cnt2]);
				}
			}
		}
	}
	return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if(a<=b && b<=c){
		cout << a << " " << b << " "  << c << endl;
	}
	else if(b<=a && a<=c){
		cout << b << " " << a << " " << c << endl;
	}
	else if(a<=c && c<=b){
		cout << a << " " << c << " " << b << endl;
	}
	else if(b<=c && c<=a){
		cout << b << " " << c << " " << a << endl;
	}
	else if(c<=a && a<=b){
		cout << c << " " << a << " " << b << endl;
	}
	else{
		cout << c << " " << b << " " << a << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
long long ab(long long a){
  if(a<0) return -a;
  else return a;
}
int main(){
int n; cin>>n;

long long a[110000];
int cnt[100001]={0};
int ans=0;
rep(i,n){
  cin>>a[i];
  if(a[i]>100000) ans++;
  else cnt[a[i]]++;
}
rep(i,100001){
  if(cnt[i]>=i) ans+=(cnt[i]-i);
  else ans+=cnt[i];
}

cout<<ans<<endl;
}


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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    ll n, k;
    cin >> n >> k;

    vector<ll> va(n);
    for (int i=0; i<n; ++i) cin >> va[i];
    sort(va.rbegin(), va.rend());

    vector<ll> vf(n);
    for (int i=0; i<n; ++i) cin >> vf[i];
    sort(vf.begin(), vf.end());

    ll l = 0, r = ll(1e12);
    while (l<r) {
        ll mid = l + (r-l)/2;

        bool ok = true;
        ll rem = k;
        for (int i=0; i<n; ++i) {
            ll needed = mid / vf[i];
            if (va[i]>needed) {
                rem -= va[i]-needed;
            }

            if (rem<0) {
                ok = false;
                break;
            }
        }

        if (ok) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    cout << l << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
        solve();
}


Measured memory_bytes: 3328
n=int(input())
a,b,c,d=-10**9,10**9,-10**9,10**9
for _ in range(n):
	x,y=map(int,input().split())
	a=max(a,x+y)
	b=min(b,x+y)
	c=max(c,x-y)
	d=min(d,x-y)
print(max(a-b,c-d))

Measured memory_bytes: 9156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String s = sc.next();
		boolean b = true;
		for (int i = 1; i < s.length(); i++) {
			if (s.charAt(i) == '9') {

			} else {
				b = false;
				break;
			}
		}
		int sum = 9 * (s.length() - 1) + s.charAt(0) - '0';
		if (b) {
		} else {
			sum += -1;
		}
		System.out.println(sum);

	}
}


Measured memory_bytes: 21844
from collections import defaultdict
n, W = map(int, input().split())
dd = defaultdict(list)
for i in range(n):
    weight, value = map(int, input().split())
    dd[weight].append(value)

for k in dd.keys():
    dd[k].sort(reverse=True)

a = min(dd.keys())
b, c, d = a+1, a+2, a+3
ans = 0
for w in range(len(dd[a])+1):
    for x in range(len(dd[b])+1):
        for y in range(len(dd[c])+1):
            for z in range(len(dd[d])+1):
                if W < a*w+b*x+c*y+d*z:
                    continue
                val = sum(dd[a][:w])+sum(dd[b][:x]) + \
                    sum(dd[c][:y])+sum(dd[d][:z])
                ans = max(ans, val)
print(ans)


Measured memory_bytes: 56920
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  string S,T;
  cin >> S >> T;
  int A,B;
  cin >> A >> B;
  string s;
  cin >> s;
  if(s == S){
    A--;
  }else{
    B--;
  }
  cout << A << " " << B << endl;

  return 0;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    unsigned long long t,a;
    t = 1ll; a = 1ll;
    unsigned long long A,T;
    for(int i=0;i<N;i++){
        cin >> T >> A;
        long long n = (t+T-1)/T;
        long long m = (a+A-1)/A;
        long long k = max(n,m);
        t = T*k;
        a = A*k;
    }
    cout << a + t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    int ans = 0;

    for(int i = 1; i <= n; i+=2) {
        int cou = 0;
        for(int j = 1; j <= i; j++) if(i % j == 0) cou++;
        if(cou == 8) ans++;
    }

    cout << ans << endl;

    return 0;
}   

Measured memory_bytes: 3608
#include <iostream>
#include <vector>

int main()
{
	int n;
	std::cin >> n;
	int wall = 0, ans = 0;
	for (int i = 0; i < n; ++i)
	{
		int h;
		std::cin >> h;
		if (wall <= h)
		{
			ans++;
		}
		wall = std::max(wall, h);
	}
	std::cout << ans;
}

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

#define F first
#define S second
#define pb push_back
#define mp make_pair

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

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

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

	ll n,i,j,sum= 0,sum1 = 0;

	cin >> n;
	ll a[n];

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

	sum1 -= a[0];
	ll f = 1e9 + 7;
	for(i=0;i<n-1;i++)
	{
		ll x = sum1;
		x %= f;

		ll w = a[i]%f;

		x*=w;
		sum += x%f;

		sum1 -= a[i+1];
	}

	cout << sum%f << endl;
}

Measured memory_bytes: 5176
'use strict';

const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("");
let answer = "Yes";

for (let i = 0; i < lines.length; i++) {
let count = 0;
//同じ文字を数える
lines.forEach(letter => {
if (lines[i] === letter)
count++;
});
//数えた数が奇数ならNoを返して抜ける
if (count % 2 === 1) {
answer = "No";
break;
}
}
console.log(answer);

Measured memory_bytes: 8008
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
L = list(map(int,readline().split()))
L = sorted(L)

cnt = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]+L[j] > L[k] and L[i]!=L[j] and L[j]!=L[k]:
                cnt += 1
print(cnt)


Measured memory_bytes: 67840
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;

//vector< vector<int> > v (size1, vector<int>(size2) );
vector< vector<pair<ll,ll>> > cost(100005);
stack<ll> s;
vector<bool> B(100005);
vector<ll> cost1(100005);
vector<ll> ans(100005);
ll a;

void dfs(){
    if(s.empty()==false){
        a=s.top();
        //cout<<'a'<<a<<endl;
        if(cost[a].size()==0){
            s.pop();
        }else {
            if(B[cost[a].back().first]==false){
                s.push(cost[a].back().first);
                B[cost[a].back().first]=true;
                cost1[cost[a].back().first]=(cost1[a]%2+cost[a].back().second%2)%2;
                //cout<<cost[a].back().first<<' '<<cost1[cost[a].back().first]<<endl;
                /*if((cost1[cost[a].back().first])%2==0){
                    ans[cost1[cost[a].back().first]]=0;
                }else{
                    ans[cost1[cost[a].back().first]]=1;
                }*/
                cost[a].pop_back();
            }else if(cost[a].size()>1){
                swap(cost[a].back(),cost[a].front());
            }else{
                cost[a].pop_back();
            }
        }
        dfs();
    }
}


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

    ll N;
    cin>>N;

    ll u,v,w;

    FOR(i,0,N-1){
        cin>>u>>v>>w;
        cost[u].push_back({v,w});
        cost[v].push_back({u,w});
    }
    
    FOR(i,1,100005){
        B[i]=false;
    }

    s.push(1);
    cost1[1]=0;
    B[1]=true;
    dfs();
    FOR(i,1,N+1){
        //cout<<i<<' '<<cost1[i]<<endl;
        if(cost1[i]%2==0){
            cout<<0<<endl;
        }else cout<<1<<endl;
    }
}

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

int dp[1 << 16][32];

int main() {
	int n, c;
	while(cin >> n >> c, n || c) {
		vector<int> a, b;
		for(int i = 0; i < n+c; i++) {
			int p = 0;
			for(int j = 0; j < 16; j++) {
				int tmp;
				cin >> tmp;
				p = (p << 1) | tmp;
			}
			if(i < n)
				a.push_back(p);
			else
				b.push_back(p);
		}
		for(int i = 0; i < (1 << 16); i++)
			for(int j = 0; j < 32; j++)
				dp[i][j] = -1;

		dp[0][0] = 0;
		for(int i = 0; i < a.size(); i++) {
			for(int j = 0; j < (1 << 16); j++) {
				if(dp[j][i] + 1) {
					for(int k = 0; k < b.size(); k++) {
						int tmp, cnt;
						tmp = (j|a[i]) & b[k];
						cnt = 0;
						while(tmp) {
							tmp -= tmp&(-tmp);
							cnt++;
						}
						dp[(j|a[i])&(~b[k])][i+1] = max(dp[(j|a[i])&(~b[k])][i+1], dp[j][i] + cnt);
					}
				}
			}
		}
		int res = 0;
		for(int i = 0; i < (1 << 16); i++) {
			res = max(dp[i][n], res);
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 9412
n = int(input())

xyhs = [list(map(int, input().split())) for _ in range(n)]
xyhs.sort(key=lambda i: i[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x, y, h = xyhs[0]
        ch = h + abs(cy - y) + abs(cx - x)

        if all([h == max(ch - abs(cy - y) - abs(cx - x), 0) for x, y, h in xyhs[1:]]):
            print(cx, cy, ch)
            exit()


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,j,k,l,i;
cin>> n;
    map<int,int>m;
for(i=1;i<=n;i++){
    cin>>j;
    m[j]=i;
}
for(k=1;k<n;k++){cout<<m[k]<<" ";}
cout<<m[n]<<endl;


}


Measured memory_bytes: 5504
def abc141d():
    import heapq
    n, m = map(int, input().split())
    a = list(map(lambda x: -int(x), input().split()))
    heapq.heapify(a)
    for _ in range(m):
        v = -heapq.heappop(a)
        v = v//2
        heapq.heappush(a, -v)
    print(abs(sum(a)))

abc141d()

Measured memory_bytes: 86376
#include <iostream>
#include <bitset>

int main()
{	
	int n; std::cin >> n;
	
	std::bitset<64>* mask = new std::bitset<64>[n];
	for (int i=0; i<n; i++) {
		mask[i] = std::bitset<64>(0);
		int k, b;
		std::cin >> k;
		for (int j=0; j<k; j++) {
			std::cin >> b;
			mask[i].set(b);
		}
	}
	
	std::bitset<64> bs(0);
	std::bitset<64> tmp;
	
	int q; std::cin >> q;
	for (int i=0; i<q; i++) {
		int op, k, m;
		std::cin >> op;
		switch (op) {
		case 0:
			std::cin >> k;
			std::cout << bs.test(k) << std::endl;
			break;
		case 1:
			std::cin >> m;
			bs |= mask[m];
			break;
		case 2:
			std::cin >> m;
			bs &= ~mask[m];
			break;
		case 3:
			std::cin >> m;
			bs ^= mask[m];
			break;
		case 4:
			std::cin >> m;
			tmp = bs & mask[m];
			std::cout << (tmp == mask[m]) << std::endl;
			break;
		case 5:
			std::cin >> m;
			tmp = bs & mask[m];
			std::cout << tmp.any() << std::endl;
			break;
		case 6:
			std::cin >> m;
			tmp = bs & mask[m];
			std::cout << tmp.none() << std::endl;
			break;
		case 7:
			std::cin >> m;
			tmp = bs & mask[m];
			std::cout << tmp.count() << std::endl;
			break;
		case 8:
			std::cin >> m;
			tmp = bs & mask[m];
			std::cout << tmp.to_ullong() << std::endl;
			break;
		}
	}
	
	delete[] mask;
	
	return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define fLoop for(lli i = 0; i < N; i++)
main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A * C, max(A * D, max(B * C, B * D)));
}

Measured memory_bytes: 3664