akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(void)
{
	char after[32][9] = { 
		"100101", "10011010", "0101", "0001", "110", "01001",
		"10011011", "010000", "0111", "10011000", "0110", "00100",
		"10011001", "10011110", "00101", "111", "10011111", "1000",
		"00110", "00111", "10011100", "10011101", "000010",
		"10010010", "10010011", "10010000", "101", "000000", "000011",
		"10010001", "010001", "000001"
	};
	char before[32][6] = {
		"00000", "00001", "00010", "00011", "00100", "00101", "00110",
		"00111", "01000", "01001", "01010", "01011", "01100", "01101",
		"01110", "01111", "10000", "10001", "10010", "10011", "10100",
		"10101", "10110", "10111", "11000", "11001", "11010", "11011",
		"11100", "11101", "11110", "11111"
	};
	
	char str[2048], str2[2048];
	int i, j, f, len;
	
	while (fgets(str, 2048, stdin) != NULL){
		for (i = 0; i < 2048; i++){
			str2[i] = '\0';
		}
		
		i = 0;
		while (str[i] != '\0'){
			if (str[i] >= 'A' && str[i] <= 'Z'){
				strcat(str2, before[str[i] - 'A']);
			}
			switch (str[i]){
				case ' ':
				strcat(str2, before[26]);
				break;
				
				case '.':
				strcat(str2, before[27]);
				break;
				
				case ',':
				strcat(str2, before[28]);
				break;
				
				case '-':
				strcat(str2, before[29]);
				break;
				
				case '\'':
				strcat(str2, before[30]);
				break;
				
				case '?':
				strcat(str2, before[31]);
				break;
			}
			i++;
		}
		
		i = 0;
		while (1){
			for (j = 0, f = 0; j < 32; j++){
				if (strncmp(&str2[i], after[j], strlen(after[j])) == 0){
					f = 1;
					i += strlen(after[j]);
					if (j >= 0 && j <= 25){
						printf("%c", j + 'A');
					}
					else {
						switch (j){
							case 26:
							printf(" ");
							break;
							
							case 27:
							printf("\'");
							break;
							
							case 28:
							printf(",");
							break;
							
							case 29:
							printf("-");
							break;
							
							case 30:
							printf(".");
							break;
							
							case 31:
							printf("?");
							break;
						}
					}
				}
			}
			if (f == 0){
				break;
			}
		}
		
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 532
object Main extends App {
  val input = readLine
  val countOfWords = input.split(" ")(0).toInt
  def getWordsList(i: Int, list: List[String]): List[String] = {
    val word = readLine
    if(countOfWords < i ) list else getWordsList(i + 1, list :+ word)
  }
  val wordsList: List[String] = getWordsList(1, List.empty)
  println(wordsList.sorted.mkString(""))
}


Measured memory_bytes: 27200
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define M 1000000007

using namespace std;


int main(){
    int n;cin>>n;
    int arr[100001]={0};
    ll sum=0;
    for(int i=0;i<n;i++){
        int k;cin>>k;
        sum+=k;
        arr[k]+=1;
    }
    int q;cin>>q;
    ll arr1[q];
    for(int i=0;i<q;i++){
        int a;int b;cin>>a>>b;
        int t=arr[a];
        if(t>0){
        arr[a]=0;
        arr[b]+=t;
        sum=sum+t*(b-a);
        arr1[i]=sum;
        }
        else if(t==0){
            arr1[i]=sum;
        }
    }
    for(int i=0;i<q;i++){
        cout<<arr1[i]<<endl;
    }
    



}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const LL LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 2e5 + 10;
int N, u[maxn], v[maxn];
int main()
{
    scanf("%d", &N);
    for(int i = 1; i <= N - 1; i++)
        scanf("%d %d", &u[i], &v[i]);
    LL ans = 0;
    for(int i = 1; i <= N; i++)
        ans += (LL) i * (N - i + 1);
    for(int i = 1; i <= N - 1; i++)
    {
        if(u[i] > v[i])
            swap(u[i], v[i]);
        ans -= (LL) u[i] * (N - v[i] + 1);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
 
int n,q,l,r,cnt;
string s;

int main() {
	cin>>n>>q>>s;
	vector<int> arr(n,0);
	for (int i=1; i<n; i++){
		if(s[i]=='C' && s[i-1]=='A'){
			arr[i]++;
		}
		arr[i] += arr[i-1];
	}
	while(q--){
		cin>>l>>r;
		l--;r--;
		int res = arr[r];
		if(l>=0) res -= arr[l];
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define endl "\n"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1e9 + 7;
const string YES = "Yes";
const string NO = "No";
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if(n > m/2){
        ans = m/2;
    }
    else{
        m -= n * 2;
        ans = n + (m / 4);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)

class segmenttree{
    private:
    int n;
    long long identity = 0;//単位元
    std::vector<long long> dat;
    public:
    
    void init(int N){
        n=1;
        while(n<N)n*=2;
        dat.clear();
        for(int i=0;i<2*n-1;++i){
            dat.push_back(identity);
        }
    }
    
    long long calc(long long a,long long b){
        return (a+b)%3;
    }
    
    void update(int k,long long a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=calc(dat[2*k+1],dat[2*k+2]);
        }
    }
    
    long long query(long long a,long long b){
        a+=n;
        b+=n;
        long long R=0;
        while(a < b){
            if(a % 2 == 1){
                R = calc(R, dat[a - 1]);
                a += 1;
            }
            a /= 2;
            if(b % 2 == 1){
                b -= 1;
                R = calc(R, dat[b - 1]);
            }
            b /= 2;
        }
        return R;
    }
};


int main(){
    
    string S,T;
    int Q;
    int A[114514],B[114514],C[114514],D[114514];
    int G[114514],H[114514];
    
    cin >> S >> T;
    cin >> Q;
    REP(i,Q){
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--;B[i]--;C[i]--;D[i]--;
    }
    
    //Aを1、Bを2、O(=AB)を0と扱う
    
    segmenttree Sseg,Tseg;
    
    //Sをセグる
    Sseg.init(S.size());
    REP(i,S.size()){
        Sseg.update(i,(S[i]=='A'?1:2));
    }
    REP(i,Q){
        G[i]=Sseg.query(A[i],B[i]+1);
    }
    //Tをセグる
    Tseg.init(T.size());
    REP(i,T.size()){
        Tseg.update(i,(T[i]=='A'?1:2));
    }
    REP(i,Q){
        H[i]=Tseg.query(C[i],D[i]+1);
    }
    
    //REP(i,Q){cout << G[i] <<" "<< H[i] << endl;}
    
    REP(i,Q){
        if(G[i]==H[i]){
            cout << "YES" << '\n';
        }else{
            cout << "NO" << '\n';
        }
    }
    
    return 0;
}

Measured memory_bytes: 8116
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int INF=(1<<30);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n; cin >> n;
  vector<vector<int>> hoge(n, vector<int>(3));
  int a, b ,c;
  for (int i = 0; i < n; i++){
    cin >> hoge[i][0] >> hoge[i][1] >> hoge[i][2];
  }
  vector<vector<int>> dp(n, vector<int>(3));
  dp[0][0] = hoge[0][0];
  dp[0][1] = hoge[0][1];
  dp[0][2] = hoge[0][2];
    // for (int i = 0; i < n; i++){
    //   for (int a = 0; a < 3; a++)
    //   {
    //     cout << dp[i][a] << " ";
    //   }
    //   cout << endl;
    // }
  for (int i = 1; i < n; i++){
    for (int a = 0; a < 3; a++){
      for(int b = 0; b < 3; b++){
          if(b == a) continue;
          dp[i][a] = max(dp[i][a], hoge[i][a] + dp[i - 1][b]);
      }
    }
    // for (int i = 0; i < n; i++){
    //   for (int a = 0; a < 3; a++)
    //   {
    //     cout << dp[i][a] << " ";
    //   }
    //   cout << endl;
    // }
  }
  // cout << max(dp[n - 1][0], dp[n-1][1], dp[n-1][2]) << endl;
  cout << *max_element(dp[n - 1].begin(), dp[n - 1].end()) << endl;
}

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

namespace ABC141
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = CIN.String();
            Console.WriteLine(S == "Sunny" ? "Cloudy" : (S == "Cloudy" ? "Rainy" : "Sunny"));
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
    string s;
    cin>>s;
    deque<char> dq;
    for(char c:s)
        dq.push_back(c);
    
    int rev=0,q;
    cin>>q;
    while(q--)
    {
        int t;
        cin>>t;
        if(t==1)
            rev=1-rev;
        else
        {
            int f;
            cin>>f;
            char c;
            cin>>c;
            f--;
            if(rev^f)
            dq.push_back(c);
            else
            dq.push_front(c);
        }
    }
    if(rev!=0)
    reverse(dq.begin(),dq.end());
    for(auto c:dq)
        cout<<c;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  vector<pair<ll, ll>> ranges;
  for (int i = 0; i < n; i++) {
    ll x, l; cin >> x >> l;
    ranges.emplace_back(x + l, x - l);
  }
  sort(ranges.begin(), ranges.end());
  ll lst = -1e18;
  int ans = 0;
  for (auto& e: ranges) {
    if (e.second >= lst) {
      ans++;
      lst = max(lst, e.first);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420
//Keep Working hard
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int (i) = (a); (i) < (b) ;(i)++)

void fileIO()
{
        #ifndef ONLINE_JUDGE
        freopen("int.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
//    fileIO();
    int a,b;
    cin >> a >> b;
        cout << (a+b)/2+(a+b)%2;
    return 0;
}


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

typedef long double ld;
typedef long long ll;

using namespace std;

const ll p = 998244353;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
//     freopen("input.txt", "r", stdin);
    cout << setprecision(20);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    vector<pair<int, int>> b(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> b[i].first;
        b[i].second = i;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    bool det = 0;
    for (int i = 0; i < n; i++) {
        if (a[i].first > b[i].first) {
            cout << "No";
            return 0;
        }
        if (i < n-1 && a[i + 1].first <= b[i].first) {
            det = 1;
        }
    }
    if (det) {
        cout << "Yes";
        return 0;
    }
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        c[b[i].second] = a[i].second;
    }
    int t = 0;
    int x = 0;
    while (c[x] != 0) {
        t++;
        x = c[x];
    }
//    cout<<t;
    if (t < n - 1) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 2176
from collections import deque
H, W = map(int, input().split())
area = ['#']*(W+2)
for i in range(H):
    area += ['#']+list(input())+['#']
area += ['#']*(W+2)
H+=2
W+=2
move = [-1, 1, W, -W]
ans = 0
for i in range(H):
    for j in range(W):
        st = W*i+j
        if area[st]=='#': continue
        dq = deque([])
        dist = [-1]*(H*W)
        dq.append(st)
        dist[st] = 0
        while dq:
            now = dq.popleft()
            for dx in move:
                nxt = now+dx
                if dist[nxt]>=0 or area[nxt]=='#': continue
                dist[nxt] = dist[now]+1
                ans = max(ans, dist[nxt])
                dq.append(nxt)
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
int dp[11][11];

int main()
{
    string a;
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        a=to_string(i);
        dp[a[0]-'0'][a.back()-'0']++;
    }
    ll ans=0;
    for(int i=0; i<=9; ++i)
        for(int j=0; j<=9; ++j)
            ans+=dp[i][j]*dp[j][i];
    cout<<ans;
    return 0;
}


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


int main()
{
  int i,j,k;
  ll H,W,N;
  
  cin >> H;
  cin >> W;
  cin >> N;
  
  if( H<W ){
    if( N%W == 0 ){
      cout << N/W << endl;      
    }
    else{
      cout << N/W+1 << endl;
    }        
  }
  else{
    if( N%H == 0 ){
      cout << N/H << endl;
    }
    else{
      cout << N/H+1 << endl;
    }         
  }
  
  
  
  
  return 0;
}

Measured memory_bytes: 3504
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
if T[0] > A[0] or T[-1] < A[-1]:
    print(0)
    exit()
for i in range(1, N):
    if T[i-1] != T[i] and T[i] > A[i]:
        print(0)
        exit()
    if A[N-i-1] != A[N-i] and A[N-i-1] > T[N-i-1]:
        print(0)
        exit()
h = [-1] * N
h[0] = T[0]
h[-1] = A[-1]
for i in range(1, N-1):
    if T[i] != T[i-1]:
        h[i] = T[i]
    if A[i] != A[i+1]:
        h[i] = A[i]
ans, mod = 1, 10**9+7
for i in range(1, N-1):
    if h[i] == -1:
        ans = ans * min(A[i], T[i]) % mod
print(ans) 

Measured memory_bytes: 82148
import java.util.Scanner;
class Main
{
  public static boolean isPrime(int x)
  {
    if(x==2)
    {
      return true;
    }
    if((x<2)||(x%2==0))
    {
      return false;
    }
    int i=3;
    while(i<=Math.sqrt(x))
    {
      if(x%i==0)
      {
        return false;
      }
      i=i+2;
    }
    return true;
  }
  public static void main(String[]av)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] num=new int[n];
    for(int i=0;i<n;i++)
    {
      num[i]=sc.nextInt();
    }
    int count=0;
    for(int i=0;i<n;i++)
    {
      if(isPrime(num[i]))
      {
        count++;
      }
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 42208
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  ll n,k; cin >> n >> k;
  vector<ll> a(n), f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());

  ll l = -1;
  ll r = 1e12;
  ll ans = 0;
  while (l+1<r) {
    ll x = (l+r)/2;
    bool ok = [&] {
      ll sum = 0;
      rep(i, n)
      {
        sum += max(0LL, a[i] - (ll)x / f[i]);
      }
      return sum <= k;
    }();
    if (ok) r = x;
    else l = x;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 6428
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstdio>
#include <deque>
#include <cmath>
#include <stack>
#include <ctime>
#include <queue>
#include <set>
#include <map>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
#define X first
#define Y second
#define MP make_pair
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
 
const int ppr[] = {257, 263};
const ll INF = 2e18;
const int inf = 2e9;
const int mod[] = {int(1e9 + 7), int(1e9 + 9)};
const int N = 1e6 + 123;
const ld pi = 3.141592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

ll a, b;

inline bool ch(ll x) {
	for(ll i = 2; i * i <= x; i++)
		if(x % i == 0) return 0;
	return 1;
}                      

main() {             	
//  freopen(".in", "r", stdin);                          
//  freopen(".out", "w", stdout);
 
//	srand(time(NULL));
	
	speed;

	cin >> a >> b;

	ll g = __gcd(a, b);

	ll ans = 1;
	for(ll i = 2; i <= min(ll(1e6), g); i++)
		if(g % i == 0) {
			while(g % i == 0) g /= i;
			ans++;
		}
	if(g > 1) ans++;
	cout << ans;	

    return 0;
}  

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int  N,i;
	scanf("%d",&N);
	char S[N],T;


//入力
    scanf("%s ",S);
    printf("\n");
    for(i=0;i<N;i++) {
    	scanf("%c",&T);
    	printf("%c%c",S[i],T);
    }

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   lli A,B,L,R,N,M,K,sum=0,num=0,flag=0;
   cin >> N >> A >> B;
   Vec(P,lli,N,0);
   rep(i,0,N)cin >> P[i];
   rep(i,1,N){
      if((P[i]-P[i-1])*A>B)sum+=B;
      else sum+=(P[i]-P[i-1])*A;
   }
   Out(sum);
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>

#include <cstdlib>

int main() {
  std::string S, T;
  std::cin >> S >> T;

  int min = -1;
  for (std::size_t i = 0; i + T.size() <= S.size(); ++i) {
    int cnt_diff = 0;

    for (std::size_t j = 0; j < T.size(); ++j) {
      if (T.at(j) != S.at(i + j)) {
        ++cnt_diff;
      }
    }

    if (min < 0 || cnt_diff < min) {
      min = cnt_diff;
    }
  }

  std::cout << min << '\n';
}


Measured memory_bytes: 3168
K, N = map(int, input().split())
A = list(map(int, input().split()))
max_diff = 0
for i in range(N-1):
    max_diff = max(max_diff, A[i + 1] - A[i])
max_diff = max(max_diff, K - A[-1] + A[0])
print(K - max_diff)

Measured memory_bytes: 26444
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................
//Atlanta       83 71  8  0 1 6 1
//Atlanta       83 71  8  0 1 6 1
   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  int[] n1=int_arr();
	        		  int n=n1[0],m=n1[1],x=n1[2];//,k=n1[3];
	        		 // int[] arr=int_arr();

	        		 int res=100000000;
	        		 int[][] d=new int[n][m+1];
	        		 for(int i=0;i<n;i++){d[i]=int_arr();}
	        		 for(int i=0;i<1<<n;i++){
	        		 	int[] tmp=new int[m];
	        		 	int tc=0;
	        		 	for(int j=0;j<12;j++){
	        		 		if((i&1<<j)!=0){
	        		 			tc+=d[j][0];
	        		 			for(int k=0;k<m;k++){
	        		 				tmp[k]+=d[j][k+1];
	        		 			}
	        		 		}
	        		 	}
	        		 	boolean bb=true;
	        		 	for(int k=0;k<m;k++){
	        		 		if(tmp[k]<x){bb=false;break;}
	        		 	}
	        		 	if(bb){res=Math.min(res,tc);}
	        		 	else{continue;}
	        		 }
	        		 if(res==100000000){out.write("-1");}
	        		 else{out.write(res+"");}
	        		  
	        		  
	        	
                      out.flush();
	        		 
	}
}
	       
	          



	
  





Measured memory_bytes: 37436
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#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 llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/


//BinaryIndexTree(siz):長さsizで初期化
//sum(k):区間[0,k]の和を求める
//add(k,x):要素kにxを加える

template<typename T>
struct BinaryIndexTree {

	int n;
	vector<T> data;
	
	BinaryIndexTree(int siz)
	{
		n = siz;
		//1-indexなので配列は1つ多めに用意する
		data.resize(siz + 1, 0);
	}


	T sum(int k) {

		//[0,k)までの和を計算
		T ret = 0;
		while (k > 0) {
			ret += data[k - 1];
			k -= k & -k;
		}
		return ret;
	}

	//0-index
	void add(int k, int x)
	{
		//a_kにxを加算する
		while (k <= n) {
			data[k - 1] += x;
			k += k & -k;
		}
	}


	// bitに入ってる中でx番目に小さい数を求める
	// 1番小さい数はx = 1;
	// bitに3を入れる→add(3, 1), 3を出す→add(3, -1)
	// return == nの場合x個も入っていない
	ll min_xth(int x) {
		int left = -1, right = n;
		while (left + 1 < right) {
			int mid = (left + right) / 2;
			int temp = sum(mid + 1);
			if (temp < x) {
				left = mid;
			}
			else {
				right = mid;
			}
		}
		return right;
	}


	// pを順番通りにするための交換回数
	ll bubble(vector<T> p) {
		int n = p.size();
		ll ans = 0;
		for (int j = 0; j < n; j++) {
			ans += (j - sum(p[j] + 1));
			add(p[j], 1);
		}
		return ans;
	}


};


int main() {

	int n;
	cin >> n;
	vector<int> a;
	a.push_back(0);

	ll sum = 0;

	for (int i = 0; i < n; i++)
	{
		int c;
		cin >> c;
		a.push_back(c);
	}

	

	a.push_back(0);
	for (int i = 0; i <= n; i++)
	{
		sum += abs(a[(i + 1) % (n+2)] - a[i]);
	}

	cerr <<"sum= " <<  sum << endl;

	for (int i = 1; i <= n; i++)
	{
		cerr << abs(a[(i + 1) % (n + 2)] - a[i]) << " " << abs(a[i] - a[(i + n+2 - 1) % (n + 2)]) << " " << abs(a[(i + 1) % (n + 2)] - a[(i + n+2 - 1) % (n + 2)]) << endl;
		cout << sum - abs(a[(i + 1) % (n+2)] - a[i]) - abs(a[i] - a[(i + n+2 - 1) % (n+2)]) + abs(a[(i + 1) % (n+2)] - a[(i + n+2 - 1) % (n+2)]) << endl;
	}


	return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    vector<double> v(n);
    REP(i,n) cin >> v[i];
    sort(ALL(v));
    double ans=v[0];
    for(int i=1;i<n;i++){
        ans+=v[i];
        ans/=2;
    }
    printf("%.7f\n",ans);

    return 0;
}

Measured memory_bytes: 3824
#include<iostream>
#include<cmath>
 
using namespace std;
 
int main(){
  long int N;
  int kataware;
  int i;
  cin >> N ;
  
  for(i=sqrt(N);i>0;i--){
  	if(N%i==0){
      kataware = i;
      break;
    }
    
  }
  cout << kataware + (N / kataware ) -2 << endl;
  
  
  return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(double, t, x);
  out(t / x);
}


Measured memory_bytes: 3784
while True:
    try:
        num = int(input())
        lst = list(map(int, input().split()))
        ans = 0
        ans += lst[-1] + lst[0]
        if num == 2:
            print(ans)
            continue
        for i in range(1, num-1):
            ans += min(lst[i], lst[i-1])
        print(ans)
    except:
        break

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
  int a,b;
  char op;

  while(true){
      cin >> a >> op >> b;
      if(op == '+'){
          cout << a+b;
      }else if(op == '-'){
          cout << a-b;
      }else if(op == '*'){
          cout << a*b;
      }else if(op == '/'){
          cout << a/b;
      }else{
          break;
      }
   cout << endl;
   }

}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct sieve {
	vector<int> s;
	sieve(int n) : s(n + 1) {
		for (ll i = 0; i <= n; i++) {
			s[i] = i;
		}
		for (ll i = 2; i <= n; i++) {
			if (s[i] == i) {
				for (ll j = i * i; j <= n; j += i) {
					if (s[j] == j) {
						s[j] = i;
					}
				}
			}
		}
	}
	vector<pair<int, int>> primeFac(int n) {
		vector<pair<int, int>> res;
		while (n != 1) {
			int p = s[n], cnt = 0;
			while (s[n] == p) {
				n /= p;
				cnt++;
			}
			res.push_back(make_pair(p, cnt));
		}
		return res;
	}
};
int gcd(int x, int y) {
	int r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int g = a[0];
	for (int i = 0; i < n; i++) {
		g = gcd(a[i], g);
	}
	if (g != 1) {
		cout << "not coprime" << endl;
		return 0;
	}
	sieve s(1000100);
	vector<int> p(1000100, 0);
	for (int i = 0; i < n; i++) {
		vector<pair<int, int>> f;
		f = s.primeFac(a[i]);
		for (auto v : f) {
			p[v.first]++;
		}
	}
	for (int i = 0; i < 1000100; i++) {
		if (p[i] >= 2) {
			cout << "setwise coprime" << endl;
			return 0;
		}
	}
	cout << "pairwise coprime" << endl;
	return 0;
}


Measured memory_bytes: 14820
#include<stdio.h>

int main(void)
{
  int a,b;
  //数値の入力
  scanf("%d %d",&a,&b);
  //判定
  if(a*b%2==0)
  {
    printf("Even");
  }
  else
  {
    printf("Odd");
  }
  return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
amax = a[0]
asum = 0
acount = 0
result = 0

for i in range(0,n):
  if amax > a[i]:
    acount+=1
    asum+=a[i]
    if i == n-1:
      result += amax*acount-asum
  else:
    result += amax*acount-asum
    amax = a[i]
    asum = 0
    acount = 0

    
print(result)

Measured memory_bytes: 94164
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int MOD = 10000;

int solve(string s, int m)
{
    int n = s.size();

    vector<vector<vector<vector<int> > > > dp1(n+1, vector<vector<vector<int> > >(10, vector<vector<int> >(2, vector<int>(m, 0))));
    vector<vector<vector<vector<int> > > > dp2(n+1, vector<vector<vector<int> > >(10, vector<vector<int> >(2, vector<int>(m, 0))));

    for(int i=0; i<n; ++i){
        for(int x=1; x<=9; ++x){
            if(i == 0 && x > s[0] - '0')
                continue;
            if(i == 0 && x == s[0] - '0'){
                dp1[i+1][x][0][x%m] = 1;
                if(i < n-1)
                    dp2[i+1][x][0][x%m] = 1;
            }else{
                dp1[i+1][x][1][x%m] = 1;
                if(i < n-1)
                    dp2[i+1][x][1][x%m] = 1;
            }
        }

        for(int x=0; x<=9; ++x){
            for(int j=0; j<2; ++j){
                for(int rest=0; rest<m; ++rest){
                    for(int y=0; y<=9; ++y){
                        if(j == 0 && y > s[i] - '0')
                            continue;
                        if(y == x)
                            continue;

                        int k = (j == 1 || y < s[i] - '0')? 1:0;
                        int rest1 = (rest * 10 + y) % m;
                        if((i % 2 == 0) ^ (y > x)){
                            dp1[i+1][y][k][rest1] += dp1[i][x][j][rest];
                            dp1[i+1][y][k][rest1] %= MOD;
                        }else{
                            dp2[i+1][y][k][rest1] += dp2[i][x][j][rest];
                            dp2[i+1][y][k][rest1] %= MOD;
                        }

                    }
                }
            }
        }
    }

    int ret = 0;
    for(int i=0; i<=9; ++i){
        for(int j=0; j<2; ++j){
            ret += dp1[n][i][j][0] + dp2[n][i][j][0];
        }
    }
    ret %= MOD;

    return ret;
}

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

    for(int i=a.size()-1; ; --i){
        if(a[i] > '0'){
            -- a[i];
            break;
        }
        a[i] = '9';
    }

    int ret = solve(b, m) - solve(a, m);
    ret = (ret % MOD + MOD) % MOD;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 39000
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			cout << *p << ' ';
		}
		cout << endl;
	}
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;

//----------------------------------------------

ll a[200005];

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

	ll ans = a[n-1];

	int tmp = n-2;

	repr(i,n-1){
		if(tmp <= 0) break;
		ans+=a[i];
		tmp--;
		if(tmp <= 0) break;
		ans+=a[i];
		tmp--;
	}
	prints(ans);


	return 0;
}




Measured memory_bytes: 5196
N, M, R = map(int, input().split())
r = list(map(int, input().split()))

#Warshall Floyd
d = [[float('inf')]*N for _ in range(N)]
for _ in range(M): #ひとまず枝があるペアは枝の長さをセット
    a,b,t = map(int, input().split())
    d[a-1][b-1] = t
    d[b-1][a-1] = t

for i in range(N):
    d[i][i] = 0 #自身への最短経路は0
#三重ループ
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])

from itertools import groupby, accumulate, product, permutations, combinations
def solve(r,d):
    ans = float('inf')
    for p in permutations(r,R):
        dist = 0
        for i in range(R-1):
            dist += d[p[i]-1][p[i+1]-1]
        ans = min(ans,dist)
    return ans
print(solve(r,d))

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

vector<char> dp(100000001, 0);

bool is(int n) {
  if (dp[n] == 0) {
    int sqrt_n = sqrt(n);
    for (int i = 2; i <= sqrt_n; i++) {
      if (n % i == 0) {
        dp[n] = 1;
        return true;
      } else {
        dp[n] = -1;
      }
    }
    return false;
  } else {
    if (dp[n] == 1) return true;
    else return false;
  }
};

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    if (is(num)) ans++;
  }

  cout << n - ans << endl;
};



Measured memory_bytes: 100332
def push(X):
    coin=X
    X-=1
    return X,coin
A,B=map(int,input().split())
coin=0
if A>B:
    A,coin=push(A)
else:
    B,coin=push(B)
if A>B:
    coin+=A
else:
    coin+=B
print(coin)

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

namespace program
{
    class Program
    {
        static void Main()
        {
          var a = Input.ScanInt();
          int res = 0;
          for(int i=1;i<=a;i++){
            if(1<=i && i <= 9) res++;
            if(100 <= i && i <= 999) res++;
            if(10000 <= i && i <= 99999) res++;
          }
          Out(res);
        }
      
        static public void Out(object s) { Console.WriteLine(s); }
    }
    
    static class Input {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(); }
    }

    static class MyMath {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int n;
vector<int> graph[500000];
int x[500000];
int dfs(int v)
{
	x[v] = 1;
	int c = 0, f = 0;
	for (auto u : graph[v])
	{
		if (x[u] == 0)
		{
			f ^= (dfs(u) + 1);
			c++;
		}
	}
	return f;
}

int main()
{
	cin >> n;
	for (int i = 0; i + 1 < n; i++) {
		int v, u;
		cin >> v >> u;
		graph[v].push_back(u);
		graph[u].push_back(v);
	}
	if (dfs(1)) cout << "Alice";
	else cout << "Bob";
}


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

int main() {
	char s[3];
	cin >> s;
	int ca = 0, cb = 0, cc = 0;
	for (int i = 0; i < 3; i++)
		if (s[i] == 'a')
			ca++;
	for (int i = 0; i < 3; i++)
		if (s[i] == 'b')
			cb++;
	for (int i = 0; i < 3; i++)
		if (s[i] == 'c')
			cc++;
	if (ca == 1 && cb == 1 && cc == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll w[1000000]={0},val[1000000]={0},dp[102][100001];
ll fun(ll n,ll W)
{
    if(n<=0 || W<=0)
    return 0; 
    if(dp[n][W]!=-1)
    return dp[n][W];
    else
    {
        if(w[n]<=W)
        {
            return dp[n][W]=max(val[n]+fun(n-1,W-w[n]),fun(n-1,W));
        }
        return dp[n][W]=fun(n-1,W);
    }
}
int main()
{
    ll n,W,i;
    cin>>n>>W;
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=n;i++)
    {
        cin>>w[i];
        cin>>val[i];
    }
    cout<<fun(n,W)<<endl;
}

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

int x[51],y[51];
vector<int> vx,vy;

signed main(){

  int n,K; cin >> n >> K;
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
    vx.push_back(x[i]);
    vy.push_back(y[i]);
  }
  sort(vx.begin(),vx.end());
  sort(vy.begin(),vy.end());

  int ans = (1LL << 62);
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      for(int k = 0; k < n; k++){
        for(int l = k+1; l < n; l++){
          int cnt = 0;
          for(int m = 0; m < n; m++){
            cnt += vx[i] <= x[m] && x[m] <= vx[j] && vy[k] <= y[m] && y[m] <= vy[l];
          }
          if(cnt >= K){
            ans = min(ans,(vx[j]-vx[i])*(vy[l]-vy[k]));
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

const int N=2e5+20;

int n,k,a[N],ans;

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

	for(int i=1;i<n;i++) ans=max(ans,a[i]-a[i-1]);
	ans=max(ans,a[0]+k-a[n-1]);
	printf("%d",k-ans);
}

Measured memory_bytes: 1024
"use strict";
    
const main = arg => {
    arg     = arg.split("\n")[0].split(" ").map(n=>parseInt(n));
    const A = arg[0];
    const B = arg[1];
    
    console.log(A + B >= 24 ? (A + B) - 24 : A + B);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
const int N=1e5+50;
vector<vector<int>> v;
int dp[N];
//vector<bool> b;

int dfs(int x){
    if(dp[x]!=-1) return(dp[x]);
    if(v[x].size()==0) return(dp[x]=0);
    for(auto y:v[x]){
        dp[x]=max(dp[x],1+dfs(y));
    }
    return(dp[x]);
}

int32_t main(){
    IOS;
    int n,m;
    cin>>n>>m;
    v.resize(n);
    //b.resize(n);
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        v[x].pb(y);
    }   
    for(int i=0;i<n;i++){
        if(dp[i]==-1){
            dfs(i);
        }
    }
    int ans=0;
    for(int i=0;i<n;i++) ans=max(dp[i],ans);
    cout<<ans<<endl;
}

Measured memory_bytes: 7936
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char Hash[M][L];

int getComand(char a){
  if(a == 'A') return 1;
  else if(a == 'C')return 2;
  else if(a == 'G')return 3;
  else if(a == 'T')return 4;
  else return 0;
}

long long getK(char inf[]){
  long long sum=0,p=1,i;
  
  for(i=0;i<strlen(inf);i++){
    sum+=p*(getComand(inf[i]));
    p*=5;
  }
  return sum;
}

int h1(int k){return k%M;}
int h2(int k){return 1+(k%(M-1));}

int find(char inf[]){
  long long k,i,h;
  
  k=getK(inf);
  
  for(i=0;;i++){
    h=(h1(k)+ i*h2(k))%M;
    if(strcmp(Hash[h],inf)==0)return 1;
    else if(strlen(Hash[h])==0)return 0;
  }
  return 0;
}

int ins(char inf[]){
  
  long long k,i,h;
  
  k=getK(inf);
  
  for(i= 0;;i++){
    h=(h1(k)+i*h2(k))%M;
    
    if(strcmp(Hash[h],inf)==0)return 1;
    else if(strlen(Hash[h])==0){
      strcpy(Hash[h],inf);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n,h;
  char inf[L],comand[9];
  
  for(i=0;i<M;i++)Hash[i][0]='\0';
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s%s",&comand,&inf);

    if(comand[0]=='i')ins(inf);
    
    else{
      if(find(inf))printf("yes\n");
      else printf("no\n");      
    }
  }
  return 0;
}





Measured memory_bytes: 16100
#include <bits/stdc++.h>
using namespace std;
int n;
int a[3500];
int main(){
    scanf("%d",&n);
    int maximum = 0;
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        maximum += a[i] - 1;
    }
    printf("%d\n",maximum);
    return 0;
}


Measured memory_bytes: 256