akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define ff first
#define ss second
#define pb push_back

int bexp(int a, int b)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a);

        a = (a * a); 
        b >>= 1;
    }
    return res;
}

#define N 200010
#define MOD 1000000007

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


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);


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

    if (b >= ((a + k - 1)/ k) * k)
        cout << "OK";
    else
        cout << "NG";
    return 0;
}


Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;

int main()
{
    char S[7];

    if (scanf("%s", S) < 1) return 0;

    int ans = 0;
    for (int i = 0; i < 6; i++)
    {
        if (S[i] == '1') ans++;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int l=a+b;
    int r=c+d;
    if(l>r){cout<<"Left"<<endl;}
    else if(l<r){cout<<"Right"<<endl;}
    else{cout<<"Balanced"<<endl;}
    return 0;
}



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

int main() {
    string S, T, res;
    cin >> S >> T;
    for (int i = 0; i < S.size(); i++) {
        res += T[i];
    }
    if (S == res) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <bitset>

using namespace std;

const int MAX_R = 10;
const int MAX_C = 10000;

//input
int R, C;
bitset<MAX_C> a[MAX_R];

int ans;

void dfs(int k){
    if(k == R){
        //row certain
        int result = 0;            //cur max value
        for(int j = 0; j < C; j ++){
            int upNum = 0;            //up numbers without fliping
            for(int i = 0; i < R; i ++){
                if(a[i][j]) upNum ++;
            }
            result += max(upNum, R - upNum);    
        }
        ans = max(ans, result);
        return;
    }
    //without fliping
    dfs(k + 1);
    //&#183;flip
    a[k].flip();
    dfs(k + 1);

    a[k].flip();
}

void solve(){
    ans = 0;
    dfs(0);
    printf("%d\n", ans);
}

int main(int argc, char const *argv[]){

    while(scanf("%d %d", &R, &C)){
        if(R == 0 && C == 0) break;

        for(int i = 0; i < R; i ++){
            for(int j = 0; j < C; j ++){
                bool tmp;
                scanf("%d", &tmp);
                a[i][j] = tmp;
            }
        }
        solve();
    }

    return 0;
}

Measured memory_bytes: 1040
n, k = map(int, input().split())
a = list(map(int, input().split()))

max_dig = 40

# dp[i桁][smaller]
dp = [[-1 for _ in range(2)] for _ in range(max_dig+1)]
dp[0][0] = 0

for i in range(max_dig):
    cnt = 0
    for j in range(n):
        if (a[j] >> (max_dig-i-1)) & 1:
            cnt += 1

    cost0 = 2**(max_dig-i-1) * cnt
    cost1 = 2**(max_dig-i-1) * (n - cnt)
    
    if dp[i][1] != -1:
        dp[i+1][1] = dp[i][1] + max(cost0, cost1)
    
    if dp[i][0] != -1:
        if (k >> (max_dig-i-1)) & 1:
            dp[i+1][1] = max(dp[i+1][1], dp[i][0] + cost0)
    
    if dp[i][0] != -1:
        if (k >> (max_dig-i-1)) & 1:
            dp[i+1][0] = dp[i][0] + cost1
        else:
            dp[i+1][0] = dp[i][0] + cost0

print(max(dp[max_dig][0], dp[max_dig][1]))

Measured memory_bytes: 68696
def dijkstra(graph, start, inf = Float::INFINITY)
  vertex_num = graph.size
  dist = Array.new(vertex_num, inf)
  used = Array.new(vertex_num)
  dist[start] = 0
  loop do
    v = -1
    vertex_num.times do |u|
      v = u if !used[u] && (v == -1 || dist[u] < dist[v])
    end
    break if v == -1
    used[v] = true
    graph[v].each do |e|
      dist[e.to] = dist[v] + e.cost if dist[e.to] > dist[v] + e.cost
    end
  end
  return dist
end

Edge = Struct.new(:to, :cost)
sx, sy, tx, ty = gets.split.map(&:to_i)
n = gets.to_i
g = Array.new(n + 2) { [] }
inputs = n.times.map { gets.split.map(&:to_i) }
inputs << [sx, sy, 0]
inputs << [tx, ty, 0]
(n + 2).times do |i|
  xi, yi, ri = inputs[i]
  (i + 1...n + 2).each do |j|
    xj, yj, rj = inputs[j]
    cost = ((xi - xj) ** 2 + (yi - yj) ** 2) ** 0.5
    cost -= ri + rj
    cost = 0 if cost < 0
    g[i] << Edge.new(j, cost)
    g[j] << Edge.new(i, cost)
  end
end
p dijkstra(g, n)[n + 1]


Measured memory_bytes: 59260
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <fstream>

#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

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

ll LCM(ll a, ll b) {
    return a/GCD(a,b)*b;
}

class DMegalomania {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;in>>n;
        vector<pair<ll,ll>> v(n);
        rep(i,n) {
            ll a,b;in>>a>>b;
            v[i].first=b;
            v[i].second=a;
        }
        sort(all(v));

        ll now = 0;
        for(auto i: v){
            now+=i.second;
            if(now>i.first){
                out<<"No"<<endl;
                return;
            }
        }
        out<<"Yes"<<endl;
	}
};


int main() {
	DMegalomania solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h> 
#define pb push_back
#define mp make_pair
#define ll long long int
#define ff first
#define ss second 
#define S size()
#define mod  998244353
#define mset(a,k) memset(a,k,sizeof(a));
#define fr(i, x, y) for ( ll i = x; i < y;i++)
#define dr(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define pqueue priority_queue<ll>
#define piqueue priority_queue<ll,vll ,greater<ll>>
#define mapcl map<char,ll>
#define mapll map<ll,ll>
#define mapsl map<string,ll>
#define vi vector<ll>
#define vs vector<string>
#define psi pair<string,ll> 
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define vii vector<pii>
using namespace std;
void fast(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}  
//----------------------------------------FUNCTIONS------------------------------------- 
vi primes;
void sieve(ll n){
    vector<bool> prime(n+1,true);
    for(ll p = 2; p * p <= n; p++){
        if(prime[p] == true){
            for (ll i = p*2; i <= n; i += p)
                prime[i] = false;
        }
    }
    for (int p = 2; p <= n; p++)
       if(prime[p])
          primes.pb(p);
}

ll modexpo(ll a,ll b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    ll temp=modexpo(a,b/2);
    if(b%2)
    return (temp%mod*temp%mod*a)%mod;
    return (temp%mod*temp%mod)%mod;
}

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

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

ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vin(ll n){vi a(n);fr(i, 0, n) cin>>a[i];return a;}

void out(vi a){
    for(int i=0;i<(ll)a.S;i++){
        cout<<a[i]<<' ';
    }
    cout<<'\n';
}
void        in(ll *a, ll n)        {for(ll i=0;i<n;i++)cin>>a[i];}
void out(ll *a,ll n){fr(i,0,n){cout<<a[i]<<" ";}}
void out1(vi v){fr(i,0,(ll)v.S){cout<<v[i]<<" ";}cout<<'\n';}
//----------------------------------------START------------------------------------------- 	
int solve(); 
vector<int> v[1001];
int main()
{
	fast();
	//clock_t start=clock();
	ll t=1;
	//cin>>t;
	while(t--)
	{
		fr(i,0,1001)v[i].clear();
		solve();
	}
	/*cout<<"--------------------------------------------\n";
      cout<<(clock() - start )/(double) CLOCKS_PER_SEC<<'\n';*/
} 
int solve()
{
	ll n;
	cin>>n;
	mapsl m;
	fr(i,0,n)
	{
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<m.S<<'\n';
  return 0;
}  


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

int main () {
    int j,count=0,N,count1=0;
    cin >> N ;
    vector<int> a(N);
    for(int i=0;i<N;i++) {
        cin >> a.at(i);
        count=max(count,a.at(i));
    }
    for(j=0;j<N;j++){
        if(count==a.at(j)) break;
    }
    for(int k=0;k<N;k++){
        if(k==j) {
            for(int p=0;p<N;p++){
               if(j!=p) count1=max(count1,a.at(p));
            }
            cout << count1 << endl;
        }else cout << count << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cmath>
#include <limits>
#include <math.h>
#include <cassert>

#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, m, n) for (int i = m; i < n; i++)
#define INF 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    string x;

    cin >> x;
    int len = x.length();
    if (x.at(len - 1) != 's')
    {
        cout << x << "s" << endl;
    }
    else
    {
        cout << x << "es" << endl;
    }
}


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

int main() {
    ll x, y;
    cin >> x >> y;

    int ans = 0;
    while (x <= y) x *= 2, ans++;

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
 
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if( (abs(b - a) <= d and abs(c - b) <= d) or abs(a-c) <= d )
		cout << "Yes";
	else cout << "No";
}

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

int main ()
{
    int a, b ,c;
    int t = 0;
    cin >> a >> b >> c;

    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            t++;
        }
    }
    cout << t << '\n';

    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
using namespace std;
int dp[101][10001]={};
int main(){
	int N,W,v[101],w[101];
	cin>>N>>W;
	for(int i=1;i<=N;i++)cin>>v[i]>>w[i];
	for(int i=1;i<=N;i++)for(int j=1;j<=W;j++){
		if(j>=w[i])dp[i][j]=max(dp[i][j-w[i]]+v[i],max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]));
		else dp[i][j]=dp[i-1][j];
	}

	cout<<dp[N][W]<<"\n";
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];

    sort(v.begin(), v.end());

    auto iter = lower_bound(v.begin(), v.end(), v[N-1]/2);
    int m;
    if( iter-1 < v.begin() || fabs( (*iter) - v[N-1]/2.) < fabs(*(iter-1)- v[N-1]/2.)) m = *iter;
    else m = *(iter - 1);

    cout << v[N-1] << " " << m << endl;
}

Measured memory_bytes: 640
#include<iostream>
int main(){
	int a,b,c,d;
	int area1,area2;

	std::cin >> a >> b >> c >> d;

	area1 = a * b;
	area2 = c * d;

	if(area1 > area2)
		std::cout << area1 << '\n';
	else
		std:: cout << area2 << '\n';

	return 0;
}


Measured memory_bytes: 384
def get_num(n, m):
    ans = 0
    for x in range(n, 2, -1):
        if 3 * x - 2 < m:
            return ans
        for y in range(x - 1, 1, -1):
            if x + 2 * y - 1 < m:
                break
            for z in range(y - 1, 0, -1):
                s = x + y + z
                if s == m:
                    ans += 1
                    break 
    return ans


while True:
    [n, m] = [int(x) for x in raw_input().split()]
    if [n, m] == [0, 0]:
        break
    print(get_num(n, m))

Measured memory_bytes: 6420
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), pena(n);
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (ac[p]) continue;
    if (s == "AC") {
      ac[p] = 1;
    } else {
      pena[p]++;
    }
  }
  int AC = 0, PENA = 0;
  rep(i, n) {
    AC += ac[i];
    if (ac[i]) PENA += pena[i];
  }
  cout << AC << " " << PENA << endl;
}


Measured memory_bytes: 1024
s = input()
found = 0
ans = 0
if s[0] == 'R':
    ans+=1
    if s[1] == 'R':
        ans += 1
        if s[2] == 'R':
            ans += 1
elif s[1] == 'R':
    ans +=1
    if s[2] == 'R':
        ans+=1
elif s[2] == 'R':
    ans+=1
print(ans)

Measured memory_bytes: 9068
n,p=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):a[i]%=2
o=a.count(1)
z=n-o
if o==0:
  if p==0:print(2**z)
  else:print(0)
else:
  print(2**(n-1))

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 13;

int n;
char s[MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	cin >> s;
}

void work ()
{
	// main work

	n = strlen ( s );
	lp ( i, 1, n ) {
		if ( s[i-1] == 'A' && s[i] == 'C' ) {
			cout << "Yes" << endl;
			return;
		}
	}

	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int mon[12],month,day,day2,i,j;
  mon[0]=31;
  mon[1]=29;
  mon[2]=31;
  mon[3]=30;
  mon[4]=31;
  mon[5]=30;
  mon[6]=31;
  mon[7]=31;
  mon[8]=30;
  mon[9]=31;
  mon[10]=30;
  mon[11]=31;
  while(1){
    scanf("%d %d",&month,&day);
    if(month==0 && day==0){
      break;
    }
    day2=0;
    for(i=2;i<month+1;i++){
      day2+=mon[i-2];
    }
    day2+=day;
    day2%=7;
    if(day2==1){
      printf("Thursday\n");
    }
    else if(day2==2){
      printf("Friday\n");
    }
    else if(day2==3){
      printf("Saturday\n");
    }
    else if(day2==4){
      printf("Sunday\n");
    }
     else if(day2==5){
      printf("Monday\n");
    }
    else if(day2==6){
      printf("Tuesday\n");
    }
    else if(day2==0){
      printf("Wednesday\n");
    }
  }
  return 0;
}

Measured memory_bytes: 584
#include<stdio.h>
 
int main(){
  
  int a,b,n;
  int tax,tra;
  scanf("%d %d %d",&n,&a,&b);
  
  tra=n*a;
  
  if(tra>b)printf("%d",b);
  else if(tra<b)printf("%d",tra);
  else{printf("%d",b);}
  
  return 0;
  
}

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

signed main () {
    int n, k;
    cin >> n >> k;
    set < char > ban;
    for (int i = 0; i < k; ++i) {
        char d;
        cin >> d;
        ban.insert(d);
    }
    for (int i = n; i < 1000000; ++i) {
        string s = to_string(i);
        bool good = 1;
        for (auto d: s) {
            if (ban.find(d) != ban.end())
                good = 0;
        }
        if (good) {
            cout << s << '\n';
            break;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int m;
  cin >> m;
  vector<int> b(m);
  rep(i, m) cin >> b[i];

  vector<int> result;
  set_intersection(all(a), all(b), back_inserter(result));
  for (auto r : result)
    cout << r << endl;
  return 0;
}



Measured memory_bytes: 4816
#include<iostream>
using namespace std;
int m , n ,x = 0 , y = 0;
int main()
{
    cin >> m >> n;
    while(n--)
    {
        cin >> x;
        y += x;
    }
    if(m > y) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] dic = new char[H+2][W+2];
        for(int row=1;row<=H;row++){
            String cur = sc.next();
            for(int col=1;col<=W;col++){
                dic[row][col] = cur.charAt(col-1);
            }
        }
        for(int row=1;row<=H;row++){
            for(int col=1;col<=W;col++){
                if(dic[row][col]=='#') continue;
                int cnt = 0;
                if(dic[row-1][col-1]=='#') cnt++;
                if(dic[row-1][col]=='#') cnt++;
                if(dic[row-1][col+1]=='#') cnt++;
                if(dic[row][col-1]=='#') cnt++;
                if(dic[row][col+1]=='#') cnt++;
                if(dic[row+1][col-1]=='#') cnt++;
                if(dic[row+1][col]=='#') cnt++;
                if(dic[row+1][col+1]=='#') cnt++;
                dic[row][col] = (char)(cnt+'0');
            }
        }
        for(int row=1;row<=H;row++){
            StringBuilder sb = new StringBuilder();
            for(int col=1; col<=W;col++) sb.append(dic[row][col]);
            System.out.println(sb.toString());
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int main() {
    string s;
    cin >> s;
    //グーかパー
    //パー<=グー
    //なので初手は必ずグー
    int pcnt = 0;
    int rcnt = 1;
    int ans = 0;
    REP(i, s.length()) {
        if(i == 0) {
            continue;
        }
        if(s[i] == 'g') {
            if(pcnt + 1 <= rcnt) {
                pcnt++;
                ans++;
            } else {
                rcnt++;
            }
        } else {
            // paper
            if(pcnt + 1 <= rcnt) {
                pcnt++;
            } else {
                rcnt++;
                ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A + X >= B) {
			if(A >= B)
				System.out.println("delicious");
			else
				System.out.println("safe");
		}else{
			System.out.println("dangerous");
		}
	}
}


Measured memory_bytes: 21460
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if p[i] == i + 1:
        p[i], p[i + 1] = p[i + 1], p[i]
        ans += 1
if p[-1] == n:
    ans += 1
print(ans)


Measured memory_bytes: 13880
#include<stdio.h>

int main(void){
  int n ,i;
  int ca=0,cw=0,ct=0,cr=0;
  char s[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s);
    if(s[0]=='A'){
      ca++;
    }
    if(s[0]=='W'){
      cw++;
    }
    if(s[0]=='T'){
      ct++;
    }
    if(s[0]=='R'){
      cr++;
    }
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",ca,cw,ct,cr);
  return 0;
}

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

    int n,i,a,c=0,pre;
    cin >> n;
    for(i=0; i<n; i++)
    {
        cin >> a;
        if(i==0)pre=a,c=1;
        else
        {
            if(pre<=a)pre=a,c++;
        }
    }

    cout << c << "\n";


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define pb push_back
#define pii pair<int,int>
#define ll long long
using namespace std;
const int maxn=405;
const ll INF=1e13+7;
ll a[maxn],sum[maxn];
ll f[maxn][maxn];
ll c[maxn][maxn];
int n;
int main()
{
	cin>>n;
	rep(i,1,n) rep(j,1,n) f[i][j]=INF;
	rep(i,1,n)
	{
		cin>>a[i];
		f[i][i]=0;
		sum[i]=sum[i-1]+a[i];
	}
	rep(len,2,n)
	{
		rep(l,1,n)
		{
			int r=l+len-1;
			if(r>n) break;
			ll now=sum[r]-sum[l-1];
			rep(k,l,r-1) f[l][r]=min(f[l][r],f[l][k]+f[k+1][r]+now);
		}
	}
	cout<<f[1][n];
	return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include <cassert>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int N;
set<string> S;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N;
    rep(i,N){
        string s;
        cin>>s;
        S.insert(s);
    }
    cout << S.size() << endl;
    return 0;
}


Measured memory_bytes: 19208
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			u = scanner.nextInt();
			if ((n | u) == 0)
				break;
			need = new int[n];
			gain = new int[n];
			int all = 0;
			unit = new int[n];
			for (int i = 0; i < n; i++) {
				unit[i] = gain[i] = scanner.nextInt();
				all += unit[i];
				int k = scanner.nextInt();
				for (int j = 0; j < k; j++) {
					int x = scanner.nextInt();
					need[i] |= (1 << x);
				}
			}
			if (all == u) {
				System.out.println(n);
				continue;
			}
			ans = n;
			v = new boolean[1 << n];
			slove(0, 0, 0);
			System.out.println(ans);
		}
	}

	private void slove(int bit, int one, int have) {
		if (ans <= one)
			return;
		if (have >= u) {
			ans = one;
			return;
		}

		for (int i = 0; i < n; i++) {
			int a = bit | (1 << i);
			if (v[a] || (bit | need[i]) != bit)
				continue;
			v[a] = true;
			slove(bit | (1 << i), one + 1, have + unit[i]);
		}
	}

	int n, u;
	int[] need, unit, gain;
	int ans;
	boolean[] v;
}

Measured memory_bytes: 56620
#include <iostream>
#include <string>
#include <cmath>

using namespace std;


int main()
{
    ios::sync_with_stdio(0);
   int a,b,c,d,e,k;
   cin>>a>>b>>c>>d>>e>>k;
   if(b-a>k||c-a>k||d-a>k||e-a>k||c-b>k||d-b>k||e-b>k||d-c>k||e-c>k||e-d>k)
    cout<<":("<<endl;
   else
    cout<<"Yay!"<<endl;
}


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

using namespace std;

int main() {
  
  int N;
  while(cin >> N && N) {
    string name[N];
    int weight[N], strength[N];
    
    for(int i=0; i<N; i++)
      cin >> name[i] >> weight[i] >> strength[i];
    
    int per[N]; for(int i=0; i<N; i++) per[i] = i;
    int save[N]; for(int i=0; i<N; i++) save[i] = i;
    
    int mx = 0;
    int mxG = 0;
    
    do {
      
      int sum_weight = weight[per[0]];
      int G = weight[per[0]];
      bool ok = 1;
      for(int i=1; i<N; i++) {
	if(sum_weight <= strength[per[i]]) {
	  sum_weight += weight[per[i]];
	  G += (i+1)*weight[per[i]];
	}
	else {
	  ok = 0; break;
	}
      }
      
      if(ok) {
	if(G > mxG) {
	  mxG = G;
	  for(int i=0; i<N; i++) save[i] = per[i];
	}
      }
      
    } while(next_permutation(per, per+N));
    
    for(int i=N-1; i>=0; i--) {
      cout << name[save[i]] << endl;
    }
    
  }  
  
  return 0;
}

Measured memory_bytes: 1200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
			String c = br.readLine();
			if(c.equals("a") || c.equals("e") || c.equals("i") || c.equals("o") || c.equals("u")) {
				System.out.println("vowel");
			}else {
				System.out.println("consonant");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 21204
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <algorithm>
#include <iostream>
using namespace std;

#include <vector>
#include <numeric>
#include <math.h>
#define ld long double
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>


	int main()
	{ 

	/*	string s;

		cin >> s;
		int m = s.size();
		cout << m << endl;
		string ans;
		
		int k;
		cin >> k;

		if (m <= k) {
			cout << s << endl;
			return 0;
		}

		if (m > k) {
			rep(i, k)
				ans += s[i];
		}
		cout << ans << "..." << endl;
		return 0;*/


		
		string n;
		cin >> n;
		int m = n.length()-1;
		if (n[m] - '0' == 2 || n[m] - '0' == 4 || n[m] - '0' == 5 || n[m] - '0' == 7 || n[m] - '0' == 9) {
			cout << "hon" << endl;
			return 0;
		}
		if (n[m]-'0' == 0 || n[m] - '0' == 1 || n[m] - '0' == 6 || n[m] - '0' == 8) {
			cout << "pon" << endl;
			return 0;
		}
		if (n[m] == '3') {
			cout << "bon" << endl;
			return 0;
		}



		

	}


// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 3632
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"sort"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n, k := scanInt(), int64(scanInt())
	a := scanInts(n)
	f := scanInts(n)

	sort.Ints(a)
	sort.Ints(f)

	l,r := int64(-1), int64(1<<63-1)

	for l+1 < r {
		md := (l+r)/2
		if ok(md,k,a,f) {
			r = md
		} else {
			l = md
		}
	}

	fmt.Println(r)
}

func ok(ma, k int64, a, f []int) bool {
	c := int64(0)
	n := len(a)
	for i := 0; i < n; i++ {
		if ma <= int64(a[i])*int64(f[n-1-i]) {
			c += int64(a[i]) - ma/int64(f[n-1-i])
		}
	}

	return c <= k
}


Measured memory_bytes: 5632
/*input 
4
fere
*/


#include <bits/stdc++.h>
using namespace std;
 

 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))

#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 998244353
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
 
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 
ll n,i,j,k,m,x,c;
int a, k1;



void solve() 
{cin>>n;
string a;
cin>>a;
if(a.size()<=n)
    cout<<a;
else cout<<a.substr(0,n)<<"...";

} 

 
 
 
signed main()
{
 
    // inputFile;
    fast;
    int T = 1;
//cin >> T;

    while(T--){
//cout<<"Case #"<<(h-T)<<": ";
        solve();
cout<<endl;
     
        
        
 
    }
    
    
    return 0;
 
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <random>
#include <algorithm>
#include <unordered_set>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define Sort(a) sort(a.begin(),a.end())
#define cSort(a,cmp) sort(a.begin(),a.end(),cmp)
#define reSort(a) sort(a.rbegin(), a.rend())
static const ll llMAX = numeric_limits<long long>::max();
static const int intMAX = numeric_limits<int>::max();
static const ll  llMIN = numeric_limits<long long>::min();
static const int intMIN = numeric_limits<int>::min();
static const ll d_5 = 100000;
static const ll d9_7 = 1000000007;
static const ll d_9 = 1000000000;
static const double PI=3.14159265358979323846;
template<class T>
T gcd(T a,T b){
  if(a==0){
    return b;

  }else if(b==0){
    return a;
  }
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  int mode=1;
  if(mode==0){
    if(b%2==1){
      ll tmp = digitpower(a,(b-1)/2);
      tmp%=d9_7;
      tmp*=tmp;
      tmp%=d9_7;
      tmp*=a;
      return (tmp)%d9_7;
    }else{
      ll tmp = digitpower(a,(b)/2);
      tmp%=d9_7;
      tmp*=tmp;
      tmp%=d9_7;
      return (tmp)%d9_7;
    }
  }else{
    if(b%2==1){
      ll tmp = digitpower(a,(b-1)/2);
      tmp*=tmp;
      tmp*=a;
      return (tmp);
    }else{
      ll tmp = digitpower(a,(b)/2);
      tmp*=tmp;
      return (tmp);
    }
  }
  return 0;
  
}
template<class T>
void Printvector(std::vector<T> &a){
  int size = a.size();
  rep(i,size){
    cout<<a[i]<<" ";
  }
  cout<<endl;
}
template<class T>
void Printvector(std::vector<std::vector<T>> &a){
  int size = a.size();
  rep(i,size){
    int size2=a[i].size();
    rep(j,size2){
      cout<<a[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;
}
int main(void){
  ll n,k,c;
  string s;
  std::cin>>n;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    if(!(i%3==0 || i % 5 ==0)){
      ans+=i;
    }
  }
  std::cout<<ans<<endl;
  return 0;
}

//clang++ -g -fsanitize=address -fno-omit-frame-pointer 1.cpp -o test.exe

//<<std::setprecision(30)

//重複削除
 /* std::sort(vec.begin(), vec.end());
 
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());*/

  //ペアの全探索
  /*do{
		int s=0;
		for(int i=0;i<n/2;i++)s+=v[i]^v[i+n/2];
		r=max(s,r);
		reverse(v.begin()+n/2,v.end());
	}while(next_permutation(v.begin(),v.end()));*/


Measured memory_bytes: 3192
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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)*}
    };
}

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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        p: [u64; n],
    }

    let mut cnt = 0;
    for i in 1..n-1 {
        if (p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1]) {
            cnt += 1;
        }
    }
    
    println!("{}", cnt);
}


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

using namespace std;

int main(){
    int n,W;
    cin>>n>>W;
    long long wt[n],v[n];
    for(int i=0;i<n;i++)cin>>wt[i]>>v[i];
    long long dp[n+1][W+1];
    for(int i=0;i<=n;i++){
        for(int w=0;w<=W;w++){
            if(i==0 || w==0) {
                dp[i][w]=0;
                continue;
            }
            if(wt[i-1]<=w){
                dp[i][w]=max(v[i-1]+dp[i-1][w-wt[i-1]],dp[i-1][w]);
            }
            else
                dp[i][w]=dp[i-1][w];
        }
    }
    long long int max=dp[n][0];
    for(int w=0;w<=W;w++)
        if(dp[n][w]>max)
            max=dp[n][w];
    cout<<max;
}

Measured memory_bytes: 79104
"use strict"
function main(arg) {
    let [H1, M1, H2, M2, K] = arg.trim().split("\n")[0].split(" ").map(Number)
    let H1x = H1 * 60 + M1
    let H2x = H2 * 60 + M2
    console.log(H2x - H1x -K)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29632
#include<iostream>
using namespace std;
int main()
{
  long long int n, q, i, j, k, tmp, sum=0;
  int index[100001] = {0};
  cin >> n;
  long long int a[n];
  
  for(i=0; i<n; i++)
  {
      cin >> a[i];
      sum += a[i];
      index[a[i]]++;
  }
  
  cin >> q;
  int b[q][2];
  
  for(i=0; i<q; i++)
    for(j=0; j<2; j++)
        cin >> b[i][j];
  
  for(i=0; i<q; i++)
  {
      tmp = index[b[i][0]];
      if(tmp)
      {
          sum = sum - (tmp * (b[i][0]));
          index[b[i][0]] = 0;
          sum = sum + (tmp * (b[i][1]));
          index[b[i][1]] += tmp;
      }
      cout << sum << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 5576
def func(s):
    a = s[:len(s) // 2]
    b = s[len(s) // 2:]
    if a == b:
        return True
    else:
        return False


def main():
    s = input()
    for i in range(1, len(s)):
        t = s[:-i]
        if func(t):
            print(len(t))
            return 


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<stdio.h>
#include<algorithm>
#include <vector>
using namespace std;
int main(){
    int A, B, K;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&K);
vector<int> X;


    for(int i = 1;i<=min(A,B);i++){
        if(A%i == 0 && B%i == 0){
            X.push_back(i);
        }
    }

    int L = X.size()-K;

    printf("%d\n",X.at(L));

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
map<pair<int,int>,int> fri;
int solve(int tmp,int n,vector<int> invite)
{
  int answer=0;
  if(tmp>n){
    if(invite.size()<2) return 0;
    REP(i,invite.size()){
      int ind=1048576;
      REP(j,invite.size())
	if(i!=j) ind=min(ind,fri[make_pair(invite[i],invite[j])]);
      answer+=ind;
    }
    return answer;
  }
  answer=max(answer,solve(tmp+1,n,invite));
  vector<int> inviteAdd=vector<int>(invite);
  int indAdd=1048576;
  REP(i,invite.size())
    indAdd=min(indAdd,fri[make_pair(tmp,invite[i])]);
  if(indAdd>0){
    inviteAdd.push_back(tmp);
    answer=max(answer,solve(tmp+1,n,inviteAdd));
  }
  return answer;
}
int main(void)
{
  int n,m;
  cin >> n >> m;
  REP(i,128) REP(j,128) fri[make_pair(i,j)]=0;
  REP(i,m){
    int a,b,f;
    cin >> a >> b >> f;
    fri[make_pair(a,b)]=f;
    fri[make_pair(b,a)]=f;
  }
  cout << solve(1,n,vector<int>()) <<endl;
  return 0;
}

Measured memory_bytes: 2268
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
map<char,int> 
count_same_elements(const vector<char>& v){map<char,int>cmap; for_each(v.begin(),v.end(),[&cmap](int x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T,class U>
void msg_with_compare(T A,T B,U A_greater_B,U A_eq_B,U A_less_B){
    if(A==B){cout<<A_eq_B<<"\n";}else if(A>B){cout<<A_greater_B<<"\n";}else{cout<<A_less_B<<"\n";}}
template<class B,class T>
void msg_with_boolean(B A,T true_msg,T false_msg){cout<< ( A? true_msg:false_msg);}
template<class B,class T>
void msg_with_boolean(B A1,B A2,T both_true_msg,T true_false_msg,T false_true_msg,T both_false_msg){
    if(A1){if(A2){cout<<both_true_msg;}else{cout<<true_false_msg;}
    }else{if(A2){cout<<false_true_msg;}else{cout<<both_false_msg;}}
}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}

ll a,b,c,k;
vector<ll> v;
void input(){
    cin>>a>>b>>c>>k;
}
void src(){
    cout<<(a+b+c)+max({a,b,c})*(pow(2,k)-1);
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,a[N],b[N];
priority_queue<pii> Q;
long long ans=0;

int main() {
	cin>>n;
	for(int i=1;i<=n;i++) a[i]=gi();
	for(int i=1;i<=n;i++) {
		b[i]=gi();
		if(b[i]!=a[i]) Q.push(mp(b[i],i));
		if(b[i]<a[i]) return puts("-1"),0;
	}
	while(!Q.empty()) {
		int i=Q.top().se;Q.pop();
		int x=(i==1?n:i-1),y=(i==n?1:i+1);
		if(b[i]-a[i]<b[x]+b[y]) return puts("-1"),0;
		int d=(b[i]-a[i])/(b[x]+b[y]);
		b[i]-=d*(b[x]+b[y]);ans+=d;
		if(b[i]!=a[i]) Q.push(mp(b[i],i));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3700
s = input()
ans = 100
count = 0
a = []

for i in range(97, 97+26):
    for j in range(len(s)):
        if s[j] != chr(i):
            count += 1
        else:
            a.append(count)
            count = 0

    a.append(count)
    maax = max(a)
    if ans > maax:
        ans = maax
    count = 0
    a.clear()

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	string s;
	cin>>s;
	
	ll n1=((s[0]-'0')*10)+(s[1]-'0');
	ll n2=((s[2]-'0')*10)+(s[3]-'0');
	
	bool b1=0,b2=0;
	if(n1>=1&&n1<=12) b1=1;
	if(n2>=1&&n2<=12) b2=1;
	
	if(b1==1&&b2==1){
		cout<<"AMBIGUOUS"<<endl;
	}
	else if(b1==1){
		cout<<"MMYY"<<endl;
	}
	else if(b2==1){
		cout<<"YYMM"<<endl;
	}
	else{
		cout<<"NA"<<endl;
	}
} 

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<int,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


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

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL t(n);
	for(auto& tt: t) cin >>tt;
	ll ans =1;
	rep(i, n){
		ans = lcm(ans, t[i]);
	}
	cout <<ans <<"\n";
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<string, ll>;

int main(int argc, char const *argv[]) {
    ll h[100000], dp[100000];
    ll n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h[i];
        dp[i]=INF;
    }
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout << dp[n-1] << endl;


    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;

int main() {
    int a;
    cin >> a;
    int y = 0;
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < a; j++) {
            for (int k = 0; k < a; k++) {
                y += __gcd(i + 1, __gcd(j + 1, k + 1));
            }
        }
    }
    cout << y << endl;
}

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

int main() {
    int x, n;
    vector<int> nums;
    cin >> x >> n;

    if (n == 0) {
        cout << x << endl;
        return 0;
    }

    nums = vector<int>(n);
    for (int i = 0; i < n; i++) cin >> nums.at(i);

    int res;
    int p = -1;
    int cnt = 0;
    bool flg = false;

    while (1) {
        int candidate = x + p * cnt;
        //cout << "candidate: " << candidate << endl;

        for (int i = 0; i < n; i++) {
            if (candidate == nums.at(i))
                flg = true;
        }
        
        if (flg) {
            flg = false;
            p = p * (-1);
            if (p == -1) cnt += 1;
            continue;
        } else {
            res = candidate;
            break;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3652