akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
 
const ll INF = 1e17;
ll N, M, L, Q;
ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];
 
void input() {
    cin >> N >> M >> L;
    for(int i = 1; i <= M; i++) cin >> A[i] >> B[i] >> C[i];
    cin >> Q;
    for(int i = 1; i <= Q; i++) cin >> s[i] >> t[i];
}
 
void solve() {
    input();
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            fuel[i][j] = INF;
            dist[i][j] = INF;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }
    for(int i = 1; i <= M; i++) {
        chmin(fuel[A[i]][B[i]], C[i]);
        chmin(fuel[B[i]][A[i]], C[i]);
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(fuel[j][k], fuel[j][i] + fuel[i][k]);
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(i == j) continue;
            if(fuel[i][j] <= L) chmin(dist[i][j], 1LL);
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    for(int i = 1; i <= Q; i++) {
        if(dist[t[i]][s[i]] < INF) cout << dist[t[i]][s[i]] - 1 << "\n";
        else cout << -1 << "\n";
    }
    return;
}
 
int main() {
    solve();
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    if (n == 1){
        cout << n << endl;
        return 0;
    }

    int max = 0, ans = 0;
    for (auto i = n; i > 0; i--) {
        int tmp = i, count = 0;
        while(!(tmp % 2)) {
            tmp /= 2;
            count++;
        }
        if (count > max) {
            max = count;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;


int n, k;
int h[100100];
int dp[100100];

int main()
{
    memset(dp, 0x3f, sizeof dp);
    dp[0] = 0;

    scanf("%d", &n);
    k = 2;
    for (int i = 0; i < n; ++i)
        scanf("%d", &h[i]);

    for (int i = 1; i < n; ++i)
    {
        for (int j = 1; j <= k; ++j)
            if (i-j > -1)
                dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
    printf("%d\n", dp[n-1]);

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll int
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cout<<"Case #"<<v1+1<<": ";



int main()
{
    fastio
    ll t,i,j,x,f;
    //cin>>t;
    
    
    ll n;
    string s;
    cin>>n>>s;
    ll res=0;
    ll start=n,end=-1;
    
    for(i=0;i<n;i++)
    {
        if(s[i]=='W')
        {
            start=i;
            break;
        }
    }
    
    for(i=n-1;i>=0;i--)
    {
        if(s[i]=='R')
        {
            end=i;
            break;
        }
    }
    if(start>end)
    cout<<'0';
    else
    {
        ll re=0,rw=0;
        for(i=start;i<=end;i++)
        {
            if(s[i]=='W')
            ++re;
            else
            ++rw;
        }
        ll cnt=0;
        
        for(i=0;i<n;i++)
        {
            if(s[i]=='R')
            ++cnt;
        }
        ll r2=0;
        
        for(i=0;i<cnt;i++)
        {
            if(s[i]=='W')
            ++r2;
        }
        
        cout<<min(r2,min(re,rw));
    }
}


Measured memory_bytes: 3772
#include <iostream>
using namespace std;
int main(){
  int N;char str[100+1];
  cin >> N >> str;
  if(N%2==0){
    bool TF=true;
    for(int i=0;i<N/2;i++){
      if(str[i]!=str[i+N/2])TF=false;
    }
    cout << (TF?"Yes":"No") << endl;
  }else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
int main(){
  int N,T[100],M,P,X;
  int sum=0;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&T[i]);
    sum+=T[i];
  }
  scanf("%d",&M);
  for(int i=0;i<M;i++){
    scanf("%d %d",&P,&X);
    printf("%d\n",sum-(T[P-1]-X));
  }
  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - XOR Circle
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef map<int,int> mii;

/* global variables */

mii amap;

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    amap[a]++;
  }

  mii::iterator zit = amap.find(0);
  if (zit != amap.end() && zit->second == n)
    puts("Yes");
  else if (n % 3 == 0) {
    int m = n / 3;
    if (amap.size() == 2 && zit != amap.end() && zit->second == m)
      puts("Yes");
    else if (amap.size() == 3) {
      bool ok = true;
      int x = 0;
      for (mii::iterator mit = amap.begin(); ok && mit != amap.end(); mit++) {
	x ^= mit->first;
	ok = (mit->second == m);
      }
      if (ok && x == 0) puts("Yes");
      else puts("No");
    }
    else
      puts("No");
  }
  else
    puts("No");
  return 0;
}


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

int main() {
int n;
  cin>>n;
  int k[2*n];
  for(int i=0;i<2*n;i++)
    cin>>k[i];
  
  sort(k,k+2*n);
  
  int res=0;
  for(int i=0;i<=2*n-1;i+=2){
    res+=k[i];}
  
  cout<<res<<endl;
  
  
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

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

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

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

LL f(LL x) {
	if (x % 4 == 0)return x;
	if (x % 4 == 3)return 0;
	if (x % 4 == 2)return x + 1;
	if (x % 4 == 1)return 1;
}

int main() {
	LL a, b;
	cin >> a >> b;
	cout << (f(b) ^ f(a - 1)) << endl;
}

Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64)::n,i,d,ans
    integer(int64)::nr(3)
    character(:),allocatable::s
    read*, n
    allocate(character(n):: s)
    read*, s
    nr(:) = 0
    do i=1,n
        if (s(i:i) == 'R') then
            nr(1)=nr(1)+1
        else if (s(i:i) == 'G') then
            nr(2)=nr(2)+1
        else
            nr(3)=nr(3)+1
        end if
    end do
    ans = product(nr)
    d=0

    do while(d < n)
        i=1
        do 
            if (i+2*d+2 > n) exit
            if (s(i:i) /= s(i+d+1:i+d+1) .and. s(i+d+1:i+d+1) /= s(i+2*d+2:i+2*d+2) .and. s(i+2*d+2:i+2*d+2) /= s(i:i)) then
                ans=ans-1
            end if
            i=i+1
        end do
        d=d+1
    end do

    print*, ans

end program name

Measured memory_bytes: 2812
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a, b, c; cin >> a >> b >> c;
	bool f = a[a.length() - 1] == b[0], g = b[b.length() - 1] == c[0];
	cout << (f&&g ? "YES" : "NO") << endl;
	return 0;
}

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

using namespace std; 

int main(){ 
  int n;
  string s;
  cin>>n>>s;
  int a=0;
  int b=0;
  for(int i=0;i<n;++i){
    if(s.at(i)=='I'){
      a+=1;
      b=max(a,b);
    }
    else a-=1;
  }
  cout<<b;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

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

const int mod = 1e9 + 7;
const char nl = '\n';

void solve(){
    ll n;
    cin >> n;
    int ans(0);
    for(int  i = 2; i < 1000010; ++i){
        int cur(0);
        while(n % i == 0){
            cur++;
            n /= i;
        }
        for(int j = 1; j < 10000; ++j){
            if(cur < j)
                break;
            ans++; cur -= j;
        }
    }
    if(n > 1)
        ans++;
        cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


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

int main(){
	int n;	cin>>n;
	vector<int> x(n+1), y(n+1);
	x[0]=0;

	for(int i=1;i<=n;i++){
		cin>>x[i];
		y[i]=x[i];
	}

	sort(y.begin(), y.end());
	int l=y[n/2], r=y[n/2 +1];

	for(int i=1;i<=n;i++){
		if(x[i]<=l) cout<<r<<endl;
		else cout<<l<<endl;

	}

	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MOD = 998244353;
#define int long long int
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define isYes(x) printf("%s\n", (x) ? "Yes" : "No")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define isIn(x, y, h, w) (x >= 0 && x < h && y >= 0 && y < w)
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
#define range(c, r) (c).begin(), (c).begin() + (r)    // Mainly used in sorting
#define present(c, x) ((c).find(x) != (c).end())      // for sets, maps, multi-maps
#define cpresent(c, x) (find(all(c), x) != (c).end()) // for vectors
#define run(x, c) for ((x) = (c).begin(); (x) != (c).end(); (x)++)
const double pi = 3.141592653589793238;
#define double long double
signed main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    h = h + (m / (double)(60));
    double degang = (double)(abs((double)(30) * h - ((double)(6) * m)));
    double radang = pi * degang / (double)(180);
    double c = (a * a) + (b * b) - (((double)(2) * a * b) * cos(radang));
    c = sqrt(c);
    cout << setprecision(100) << c << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define sz(x) ((long long)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define oo 1e15;
const ld eps = 1e-9;
const ld pi = acosl(-1);
const int mod = 998244353;
const int mod1 = 1e9 + 7;


mt19937_64 rnd(time(0));

void faster()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
}

signed main() {
    faster();
    // freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
    //______________________________________
    /*__*/double start = clock();/*__*/
    //_____________________________________
    int maxn = 2e5;
    int n, W;
    cin >> n >> W;
    vector <pair <int, int> > v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].second >> v[i].first;
    vector <vector <ll> > dp(n + 1, vector <ll> (maxn + 1, 1e15));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++)
    {
        dp[i][0] = 0;
        for (int j = 0; j < maxn; j++)
        {
            if (j < v[i - 1].first)
            {
                dp[i][j] = dp[i - 1][j];
            }
            else
            {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i - 1].first] + v[i - 1].second);
            }
        }
    }
    int ans = 0;
    for (int i = maxn; i >= 0; i--)
    {
        if (dp[n][i] <= W)
        {
            ans = i;
            break;
        }
    }
    cout << ans;
    //______________________________________
    //  cerr << "Time " << (clock() - start)  * 1.0 / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 159744
n,l=map(int,input().split())
mi=10000
for i in range(n):
    m=l+i
    if mi!=min(mi,abs(m)):
        j=i
        mi=min(mi,abs(m))
#print(j,mi)
ans=0
for i in range(n):
    if i!=j:
        ans+=l+i
print(ans)


Measured memory_bytes: 9080
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


s = input()
K = int(input())
n = len(s)


def code(s):
    return ord(s)-97

def char(c):
    c = c % 26
    return chr(c+97)


# ans = ""
ans_list = []
for p in range(n):
    c = code(s[p])
    if c == 0:
        # ans += "a"
        ans_list.append("a")
        continue
    if 26-c > K:
        # ans += s[p]
        ans_list.append(s[p])
        continue
    # ans += "a"
    ans_list.append("a")
    K -= 26-c
ans = "".join(ans_list)
ans = ans[:-1] + char(code(ans[-1])+K)

print(ans)


Measured memory_bytes: 47344
//
// Created by David Sarpong on 5/30/20.
//

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

int main(int argc, char** argv) {
    int N;
    cin >> N;

    unordered_set<int> s;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;

        if (s.find(x) != s.end()) {
            cout << "NO" << "\n";
            return 0;
        }

        s.insert(x);
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int digits(ll m){
    int re = 0;
    while(m > 0){
        m /= 10;
        re++;
    }
    return re;
}
int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> l(h, vector<int>(w, 0));
    vector<vector<int>> r(h, vector<int>(w, 0));
    vector<vector<int>> u(h, vector<int>(w, 0));
    vector<vector<int>> d(h, vector<int>(w, 0));
    vector<vector<int>> total(h, vector<int>(w, 0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#') l[i][j] = 0;
            else{
                if(j == 0) l[i][j] = 1;
                else l[i][j] = l[i][j - 1] + 1;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = w - 1; j >= 0; j--){
            if(s[i][j] == '#') r[i][j] = 0;
            else{
                if(j == w - 1) r[i][j] = 1;
                else r[i][j] = r[i][j + 1] + 1;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#') u[i][j] = 0;
            else{
                if(i == 0) u[i][j] = 1;
                else u[i][j] = u[i - 1][j] + 1;
            }
        }
    }
    for(int i = h - 1; i >= 0; i--){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#') d[i][j] = 0;
            else{
                if(i == h - 1) d[i][j] = 1;
                else d[i][j] = d[i + 1][j] + 1;
            }
        }
    }
    int ans_max = 0;
    rep(i, h){
        rep(j, w){
            ans_max = max(l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3, ans_max);
        }
    }
    cout << ans_max << endl;
}

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

using namespace std;

int main(){
  int N, M; 
  cin >> N >> M;
  
  if(N > M){
  cout << 0;
  return 0;
  }
  
  vector<int> A(M,0);
  for(int i = 0; i < M; i++) cin >> A[i];
  
  sort(A.begin(), A.end());
  
  vector<int> B(M-1,0);
  
  for(int i = 0; i < M-1; i++){
    B[i] = A[i+1]-A[i];
  }
  
  sort(B.begin(),B.end(),greater<int>());
  int ans = A[M-1] - A[0];
  for(int i = 0; i < N-1; i++){
    ans -= B[i];
  }
  cout << ans;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

class myStack{
public:
  myStack(int n){
    top = 0;
    data = new int[n];
    MAX = n;
  }
  ~myStack(){
    delete [] data;
  }
  void push(int x){
    top++;
    data[top] = x;
  }
  int pop(){
    top--;
    return data[top+1];
  }
  bool isEmpty(){
    return top == 0;
  }
  bool isFull(){
    return top == MAX - 1;
  }
  void PrintData(){
    for(int i=1;i<=top;i++){
      cout << "stack: " << data[i] << " " << endl;
    }
  }

private:
  int *data;
  int MAX;
  int top;
};

int main(){
  myStack stack(200);
  char s[100];
  int a, b;
  while(cin >> s){
    //cout << s[0] << endl;
    //if(s[0] == 'a') break;
    if(s[0] == '+'){
      a = stack.pop();
      b = stack.pop();
      stack.push(a + b);
    }
    else if(s[0] == '-'){
      a = stack.pop();
      b = stack.pop();
      stack.push(b - a);
    }
    else if(s[0] == '*'){
      a = stack.pop();
      b = stack.pop();
      stack.push(a * b);
    }
    else{
      stack.push(atoi(s));
    }
    //if(s[0] == '*') break;
    //stack.PrintData();
  }
  //stack.PrintData();
  cout << stack.pop() << endl;
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    sort(all(A));
    vector<int> X = A;
    uni(A);
    cout << (A == X ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

  ll n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  int ans = 0;
  rep(i, n) {
    while(a[i]%2 == 0 && a[i] != 0) {
      ans++;
      a[i] /= 2;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
import math
while 1:
    n = int(input())
    if n == -1:
        break
    elif n == 0:
        print(0)
    else:
        p = int(math.log(n,4))

        l =[None for i in range(p)]
        x = n
        for i in range(p):
            l[i] = x // (4 ** (p - i))
            x = x % (4 ** (p - i))
        l.append(x)

        print(*l,sep="")



Measured memory_bytes: 5688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#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 rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    ll N, M; cin >> N >> M;
    ll t = 1LL<<M;
    ll each_time = 1900LL * M + 100LL * (N - M);
    cout << each_time * t << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
unsigned int dp[101][101];
int main(void){
  int n;  cin>>n;
  vector<PII> v(n);
  REP(i,n)cin>>v[i].first>>v[i].second;

  REP(i,n+1)REP(j,n+1)dp[i][j] = (i==j)?0:INF;

  FOR(i,1,n){
    REP(j,n-i+1){
      FOR(k,j,j+i){
        int cost = v[j].first * v[k].second * v[k+1].first * v[j+i].second;
        dp[j][j+i] = min(dp[j][j+i],cost+dp[j][k]+dp[k+1][j+i]);
      }
    }
  }
  cout<<dp[0][n-1]<<endl;

  return 0;
}

Measured memory_bytes: 0
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define inf 1000000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


//edge cases when n=1,m=1.wrong variable in loop.if<->while;merge resize;LLONG_MAX
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
    speed
    //global var
    int n;cin>>n;
    vector<int> inp(n);
    for(int i=0;i<n;++i){cin>>inp[i];}
    int maxi=0,ans=0;;
    for(auto it:inp){
        if(it<maxi){
            ans+=maxi-it;
        }
        maxi=max(maxi,it);
    }
    cout<<ans<<"\n";
}
//try thinking from a different angle after spending some time


Measured memory_bytes: 4784
n=int(input())
a=list(map(int,input().split()))
a1=[]
a2=[]
for i in range(n):
    if i%2==0:
        a1.append(a[i])
    else:
        a2.append(a[i])
if n%2==0:
    a2.reverse()
    b=a2+a1
else:
    a1.reverse()
    b=a1+a2
for i in range(n):
    print(b[i],end=" ")
print()

Measured memory_bytes: 26180
#include <stdio.h>
#include <math.h>

typedef long long int lli;

int main()
{
    int iN;
    int iCnt;
    long lAns;
    long lA;
    long lAPre;


    scanf("%d", &iN);
    lAns=0;
    for(iCnt = 0 ;iCnt < iN; iCnt++)
    { 
        scanf("%ld", &lA);
        if(iCnt==0)
        {
            lAPre = lA;
        }
        else
        {
            lAns += fmax(0, lAPre - lA);
            if (lAPre - lA > 0)
                ;
            else
            {
                lAPre = lA;
            }
                
        }
    }

    printf("%ld\n", lAns);

    return 0;
}

Measured memory_bytes: 2136
/*input
5
grape
grape
grape
grape
grape


*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;
    



int32_t main() {
    IOS;
	int t;
	cin>>t;
	set<string> st;
	while(t--){
		string s;cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<endl;
    return 0;
}       



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

/* constant */

const int MAX_N = 100;

/* typedef */

typedef vector<int> vi;

/* global variables */

vi nbrs[MAX_N];
int ds[MAX_N], fs[MAX_N];

/* subroutines */

int dfs(int u, int t) {
  ds[u] = ++t;

  for (int i = 0; i < nbrs[u].size(); i++) {
    int &v = nbrs[u][i];
    if (! ds[v]) t = dfs(v, t);
  }

  return (fs[u] = ++t);
}

/* main */

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

  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    u--;

    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      v--;
      nbrs[u].push_back(v);
    }
  }

  int t = 0;
  for (int i = 0; i < n; i++)
    if (! ds[i]) t = dfs(i, t);

  for (int i = 0; i < n; i++)
    printf("%d %d %d\n", i + 1, ds[i], fs[i]);

  return 0;
}



Measured memory_bytes: 3276
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if(a > b){
		cout << "a > b" << endl;
	}else if(a < b){
		cout << "a < b" << endl;
	}else{
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
def main():
    n, k, q = map(int, input().split())
    point = [0]+[k-q]*n

    for a in range(q):
        point[int(input())] += 1

    for i in point[1:]:
        if i <= 0:
            print("No")
        else:
            print("Yes")


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	vector<string> grid(n);
	for (int i=0; i<n; i++) {
		cin>>grid[i];
		for (int j=0; j<m; j++)
			if(grid[i][j]=='.')
				grid[i][j]='0';
	}

	for (int i=0; i<n; i++) for (int j=0; j<m; j++) if(grid[i][j]=='#') {
		for (int dx=-1; dx<=1; dx++) for (int dy=-1; dy<=1; dy++) if(abs(dx)+abs(dy)) {
			int ii=i+dx, jj=j+dy;
			if(0<=ii&&ii<n&&0<=jj&&jj<m && grid[ii][jj]!='#')
				grid[ii][jj]++;
		}
	}

	for (int i=0; i<n; i++)
		cout << grid[i] << endl;
	return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);


int main(){
    int H,W,Ch,Cw,Dh,Dw;

    int dx[4] = {1,-1,0,0};
    int dy[4] = {0,0,1,-1};
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    Ch--,Cw--,Dh--,Dw--;
    vector<vector<char>> S(H,vector<char> (W));

    rep(h,H) {
        string s;
        cin >> s;
        rep(w,W) {
            S[h][w] = s[w];
        }
    }
    vector<vector<int>> seen(H,vector<int> (W,-1));

    deque<pair<int,int>> que;
    que.push_front(make_pair(Ch,Cw));
    seen[Ch][Cw] = 0;
    
    while(que.size()>0) {
        auto p = que.front();
        que.pop_front();
        int h = p.first;
        int w = p.second;
        rep(i,4) {
                
            int hn = h + dy[i];
            int wn = w + dx[i];
            if (hn>=0 && hn<H && wn>=0 && wn<W) {
                if (S[hn][wn]=='.' && (seen[hn][wn]==-1 || seen[hn][wn]>seen[h][w])) {
                    que.push_front(make_pair(hn,wn));
                    seen[hn][wn] = seen[h][w];
                } 
            }
        }
        rep(i,5) {
            rep(j,5) {
                int hn = h-2+i;
                int wn = w-2+j;
                if (hn>=0 && hn<H && wn>=0 && wn<W) {
                    if (S[hn][wn]=='.' && (seen[hn][wn]==-1 || seen[hn][wn]>seen[h][w]+1)) {
                        que.push_back(make_pair(hn,wn));
                        seen[hn][wn] = seen[h][w] + 1;
                    } 
                }
            }
        }
        
    }
    cout << seen[Dh][Dw] << endl;

}


Measured memory_bytes: 8664
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define max_n 7654321
#define mod 1000000007
#define inf ((int) (1e9+7))

#define PI acos(-1.0)
#define eps 1e-9

int main() {
	ios::sync_with_stdio(0); cin.tie(); cout.tie(0);
	int x;
	cin >> x;
	cout << ((x == 3 || x == 5 || x == 7) ? "YES" : "NO") << endl;
	return 0;
}

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

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

    int n;
    cin>>n;
    int ans=INF;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        int cnt=0;
        while(a%2==0){
            cnt++;
            a/=2;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
//while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

int n;
string s;

string w="AKIHABARA";
int k=9;

int dp[107][107];

int main()
{
	cin >> s;
	n=s.size();
	dp[0][0]=1;
	for (int i=0; i<=n; i++)
	{
		for (int j=0; j<=k; j++)
		{
			if (!dp[i][j])
				continue;
			if (i<n && j<k && s[i]==w[j])
				dp[i+1][j+1]=1;
			if (j<k && w[j]=='A')
				dp[i][j+1]=1;
		}
	}
	if (dp[n][k])
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
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};

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;
  cin>>n;
  string s[n];
  REP(i,n){
    cin>>s[i];
  }
  int firstB = 0;
  int lastA = 0;
  int AandB = 0;
  int ABCount = 0;
  REP(i,n){
    string now = s[i];

    if(now[0] == 'B'&&now[now.size()-1] !='A')firstB++;
    if(now[0] != 'B'&&now[now.size()-1] =='A')lastA++;
    if(now[0] == 'B'&&now[now.size()-1] =='A')AandB++;

    REP(j,now.size()-1){
      if(now[j]=='A'&&now[j+1]=='B'){
        ABCount++;
      }
    }
  }

  int renketu = max(0,AandB-1);
  if(lastA>0&&AandB>0){
    renketu++;
    lastA--;
  }
  if(firstB>0&&AandB>0){
    renketu++;
    firstB--;
  }
  renketu+= min(lastA,firstB);
  //if(lastA-firstB!=0)renketu++;
  ABCount += renketu;

  cout<<ABCount<<endl;

 

  return 0;
}

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

int main() {
	string S;
	cin >> S;

	bool sein[26] = { false };
	if (S.length() < 26) {
		for (char c : S) sein[c - 'a'] = true;
		cout << S;
		for (int i = 0; i < 26; i++) {
			if (!sein[i]) {
				cout << (char)('a' + i) << endl;
				break;
			}
		}
	}
	else {
		if (S == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
			return 0;
		}
		string origin = S;
		next_permutation(S.begin(), S.end());
		for (int i = 0; i < S.length(); i++) {
			cout << S.at(i);
			if (origin.at(i) != S.at(i)) break;
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

template<class T>
struct BellmanFord {
private:
    struct Edge {
        int from, to;
        T cost;
    };
    
    int n;
    vector<vector<int>> graph;
    vector<bool> used;
    vector<Edge> edges;
    vector<int> prev;
    
    void dfs(int v) {
        if (used[v]) return;
        used[v] = true;
        for(auto u : graph[v]) {
            dfs(u);
        }
    }
    
public:
    const T inf = numeric_limits<T>::max() / 2 - 1;
    vector<T> dist;
    vector<int> path;
    
    BellmanFord(){};
    BellmanFord(int _n) {
        n = _n;
        graph.resize(n);
        used.resize(n);
        dist.resize(n);
        prev.resize(n);
    }
    
    void add_edge(int from, int to, T cost) {
        edges.push_back((Edge){from, to, cost});
        graph[from].push_back(to);
    }
    
    bool get_distance(int from, int to = -1) {
        vector<bool> reach(n, true);
        for(int i = 0; i < n; i++) {
            fill(used.begin(), used.end(), false);
            dfs(i);
            if (to != -1) reach[i] = used[to];
        }
        fill(dist.begin(), dist.end(), inf);
        fill(prev.begin(), prev.end(), -1);
        dist[from] = 0;
        for(int i = 0; i < n; i++) {
            bool update = false;
            for(auto e : edges) {
                if ((!reach[e.from]) || (!reach[e.to]) || (dist[e.from] == inf)) continue;
                if (dist[e.to] > (dist[e.from] + e.cost)) {
                    dist[e.to] = dist[e.from] + e.cost;
                    prev[e.to] = e.from;
                    update = true;
                }
            }
            if (!update) break;
            if (i == (n - 1)) {
                return false;
            }
        }
        return true;
    }
    
    void get_path(int to) {
        path = vector<int>(0);
        for (; to != -1; to = prev[to]) {
            path.push_back(to);
        }
        reverse(path.begin(), path.end());
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m, p;
    cin >> n >> m >> p;
    BellmanFord<ll> bf(n);
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        bf.add_edge(a, b, p - c);
    }
    if (!bf.get_distance(0, n - 1)) {
        cout << -1 << endl;
    }
    else {
        ll ans = max(0LL, -bf.dist[n - 1]);
        cout << ans << endl;
    }
    return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    int x[n][d];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }

    int diff, sum, cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sum = 0;
            for (int k = 0; k < d; k++) {
                diff = abs(x[i][k] - x[j][k]);
                sum += (diff * diff);
            }

            for (int k = 0; k <= sum; k++) {
                if (k * k == sum) {
                    cnt++;
                    break;
                }
            }
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
a,b,m= list(map(int, input().split()))
ia = list(map(int, input().split()))
ib= list(map(int, input().split()))
z=min(ia)+min(ib)
for j in range(m):
    k= list(map(int, input().split()))
    bn=ia[(k[0]-1)]+ib[(k[1]-1)]-k[2]
    if z>bn:
        z=bn
print(z)


Measured memory_bytes: 18736
#include<iostream>
#include<string>
#include<stdio.h>

using namespace std;

int main() {

	int n;

	cin >> n;

	string s;

	cin >> s;

	
	for (int i=0; i < s.size(); i++) {
		if ((s[i] + n - 'A' <= 25)) {
			printf("%c", s[i] + n);
		}
		else {
			printf("%c", s[i] + n - 26);
		}
	}
	cout << endl;
	return 0;


}

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


using namespace std;

int main () {
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  
  int p = 1000000000;
  int z = max(X,Y);
    for (int c=0;c<=2*z;c+=2) {
      int sum = A*max(0,X-c/2)+B*max(0,Y-c/2)+C*c;
      if (p>sum) {
        p=sum;
      }
    }
      
  
  cout<<p<<endl;
  
  
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 0;
  int tmp_ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T') {
      // s[i] = 'x';
      tmp_ans = 0;
    } else {
      tmp_ans++;
    }
    ans = max(ans, tmp_ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char *argv[])
{
	int n,a[120],i,m=0,s,x,j=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]); 
	for(i=0;i<n;i++)
	{if(a[i]>=1&&a[i]<=399) j=1;
	if(a[i]>=400&&a[i]<=799) b=1;
	if(a[i]>=800&&a[i]<=1199) c=1;
	if(a[i]>=1200&&a[i]<=1599) d=1;
	if(a[i]>=1600&&a[i]<=1999) e=1;
	if(a[i]>=2000&&a[i]<=2399) f=1;
	if(a[i]>=2400&&a[i]<=2799) g=1;
	if(a[i]>=2800&&a[i]<=3199) h=1;
	if(a[i]>=3200) m++;
	}
	
	if(j==0&&b==0&&c==0&&d==0&e==0&&f==0&&g==0&&h==0) 
	{s=1;  x=m;}
	else {s=j+b+c+d+e+f+g+h;
         x=s+m;}
	
	printf("%d %d",s,x);
	
}
	



Measured memory_bytes: 128
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var s2 = Console.ReadLine().Trim();
        var t2 = Console.ReadLine().Trim();
        var s = string.Join("", s2.ToCharArray().OrderBy(x => x));
        var t = string.Join("", t2.ToCharArray().OrderByDescending(x => x));
        Console.WriteLine(t.CompareTo(s) > 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 13536
<?php

//1行目の入力値＝文字列sを2倍にしてくっつける
$strS = trim(fgets(STDIN));
$strS = str_repeat($strS, 2);

/*上で処理した文字列sにおいて2行目の入力値＝文字列pが存在するか検索して、
1回でも存在すればyesを出力、そうでなければnoを出力*/
$strP = trim(fgets(STDIN));
if (strpos($strS, $strP) !== false) {
    echo "Yes" . "\n";
} else {
    echo "No" . "\n";
}


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main() {
  long A, V, B, W, T;
  cin >> A >> V;
  cin >> B >> W;
  cin >> T;
  if(A<B) {
  if(V*T+A<W*T+B) {
    cout << "NO" << endl;
  }
  else {
    cout << "YES" << endl;
  }
  }
  else {
    if (W*T+A>V*T+B) {
      cout << "NO" << endl;
    }
    else {
      cout << "YES" << endl;
    }
  }
}


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

#define YES(condition) if(condition){ cout << "YES" << endl; }else{ cout << "NO" << endl; }
#define Yes(condition) if(condition){ cout << "Yes" << endl; }else{ cout << "No" << endl; }
#define POSS(condition) if(condition){ cout << "POSSIBLE" << endl; }else{ cout << "IMPOSSIBLE" << endl; }
#define Poss(condition) if(condition){ cout << "Possible" << endl; }else{ cout << "Impossible" << endl; }
long power(long base, long exponent, long mod){ if(exponent % 2){ return power(base, exponent - 1, mod) * base % mod; }else if(exponent){ long root_ans = power(base, exponent / 2, mod); return root_ans * root_ans % mod; }else{ return 1; }}

int main(){
    int N;
    cin >> N;
    vector<int> nums_count(1e5, 0);
    for(int i = 0; i < N; i++){
        int num;
        cin >> num;
        nums_count[num - 1]++;
    }
    int ans = 0, two_card_count = 0;
    for(int i = 0; i < 1e5; i++){
        ans += max(0, nums_count[i] - 1) / 2;
        two_card_count += (!(nums_count[i] % 2) && nums_count[i]);
    }
    cout << N - (ans + (two_card_count + 1) / 2) * 2 << endl;
}



Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<string>s(n);
    rep(i,n)cin >> s[i];
    int mi = inf;
    rep(bits,(1<<(n-1))){
        int c = __builtin_popcount(bits);
        vector<int> p(n);
        vector<int> cnt(c+1);
        int t = 0;
        p[0] = 0;
        rep(k,n-1){
            if((bits>>k)&1){
                t++;
                p[k+1] = t;
            }else{
                p[k+1] = t;
            }
        }
        int sss = c;
        bool ng = 0;
        rep(j,m){
            bool flag = 0;
            rep(i,n){
                if(s[i][j]=='1'){
                    if(cnt[p[i]]>=k){
                        flag = 1;
                    }else{
                        cnt[p[i]]++;
                    }
                }
            }
            if(flag){
                sss++;
                rep(i,c+1){
                    cnt[i] = 0;
                }
                rep(i,n){
                    if(s[i][j]=='1'){
                        cnt[p[i]]++;
                        if(cnt[p[i]]>k){
                            ng = 1;
                        }
                    }
                }
            }
        }
        if(!ng)chmin(mi,sss);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll mod = 1000000007;
const int N = 100005;

ll ft[N * 2], inv_ft[N * 2];

ll fast_exp(ll v){
    ll m = mod - 2, r = 1;
    while(m){
        if(m & 1) r = r * v % mod;
        v = v * v % mod;
        m >>= 1;
    }
    return r;
}

ll bm(ll n, ll k){
    return ft[n] * (inv_ft[k] * inv_ft[n - k] % mod) % mod;
}

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

    ft[0] = inv_ft[0] = 1;
    for(int i = 1; i < N * 2; i++){
        ft[i] = ft[i - 1] * i % mod;
        inv_ft[i] = fast_exp(ft[i]);
    }
   
    int h, w, n;
    cin >> h >> w >> n;
    pii p[n + 1]; 
    ll dp[n + 1];
    p[n] = {h, w};
    for(int i = 0; i < n; i++)
        cin >> p[i].fi >> p[i].se;
    sort(p, p + n + 1);

    for(int i = 0; i <= n; i++){
        dp[i] = bm(p[i].fi + p[i].se - 2, p[i].fi - 1);
        for(int j = 0; j < i; j++)  
            if(p[j].se <= p[i].se)
                dp[i] = (dp[i] - dp[j] * bm(p[i].fi - p[j].fi + p[i].se - p[j].se, p[i].fi - p[j].fi) % mod + mod) % mod; 
    }
    cout << dp[n] << endl;
}

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

using namespace std;

long long n,m,k,x,y;

int main()
{
    cin>>n>>m;
    cin>>k;
    x=min(n,m);
    y=max(n,m);
    for(long long i=1;i<=x;i++)
    {
        if(i*y>=k){cout<<i;break;}
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define mod (int(1e9)+7)
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n][n];
	long long b[1<<n];
	b[0]=1;
	fill(b+1,b+(1<<n),0);
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			cin>>a[i][j];
	for(int i=1;i<(1<<n);++i)
	{
		for(int j=0;j<n;++j)
			if(((i>>j)&1)&&a[__builtin_popcount(i)-1][j]==1)
			{
				b[i]+=b[i-(1<<j)];
				b[i]%=mod;
			}
	}
	cout<<b[(1<<n)-1];
}

Measured memory_bytes: 16640