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

bool match(char c, char d) {
  if (c == '?' or d == '?') {
    return true;
  }
  return c == d;
}

vector<bool> f(const string& s, const string& t) {
  int n = s.size();
  vector<bool> res(n + 1, true);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < (int)t.size(); ++j) {
      if (i + j < n and not match(s[i + j], t[j])) {
        res[i] = false;
        break;
      }
    }
  }
  return res;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vector<string> s(3);
  for (auto&& e : s) {
    cin >> e;
  }
  sort(begin(s), end(s));
  int res = 1e9;
  do {
    auto b01 = f(s[0], s[1]);
    auto b02 = f(s[0], s[2]);
    auto b12 = f(s[1], s[2]);
    for (int i = 0; i <= (int)s[0].size(); ++i) {
      for (int j = i; j <= max((int)s[0].size(), i + (int)s[1].size()); ++j) {
        if (b01[i] and (j > (int)s[0].size() or b02[j]) and (j - i > (int)s[1].size() or b12[j - i])) {
          res = min(res, max({(int)s[0].size(), i + (int)s[1].size(), j + (int)s[2].size()}));
        }
      }
    }
  } while (next_permutation(begin(s), end(s)));
  cout << res << '\n';
}


Measured memory_bytes: 256
s = input()
ans = float('inf')
for i in range(26):
    c = chr(ord('a') + i)
    work_s = s
    cnt = 0
    while len(set(work_s)) != 1:
        next_s = ''
        for i in range(len(work_s) - 1):
            if work_s[i] == c or work_s[i + 1] == c:
                next_s += c
            else:
                next_s += work_s[i]
        work_s = next_s
        cnt += 1
    if ans > cnt:
        ans = cnt

print(ans)

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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  
  int answer = 0;
  
  for(int i=0; i<n-1; i++) {
    for(int j=i+1; j<n; j++) {
      answer += a.at(i) * a.at(j);
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <sstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1e-9;


signed main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a,b;
  cin>>a>>b;
  cout << max({a+b, a-b, a*b}) << endl;

  return 0;
}


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

typedef long long ll;

int digit(int x){
    int tmp = 0;
    while(x != 0){
        tmp++;
        x /= 10;
    }
    return tmp;
}

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

    int ans = 15;
    for(ll i = 1; i <= sqrt(n); i++){
        if(n%i == 0){
            ans = min(ans, max(digit(i), digit(n/i)));
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  if(S[0]=='S')cout<<"Cloudy"<<endl;
  else if(S[0]=='C')cout<<"Rainy"<<endl;
  else cout<<"Sunny"<<endl;
  return 0;
}


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

using namespace std;

int main(){
    string s;
    vector<string>S;
    int K;
    cin >> s >> K;
    int tmp = min(5,(int)s.size());
    for(int i = 1; i <= tmp; i++){
        for(int j = 0; j < s.size(); j++){
            S.push_back(s.substr(j,i));
        }
    }
    sort(S.begin(),S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    // for(int i = 0; i < K; i++){
    //     cout << S[i] << endl;
    // }
    cout << S[K-1] << endl;

}


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

using namespace std;

int main(){
    string s;
    while(cin >> s){
        int K; cin >> K;
        for(auto& c : s){
            if(c == 'a') continue;
            int sub = 26 - (c-'a');
            if(sub <= K){
                c = 'a';
                K -= sub;
            }
        }
        s.back() = (s.back()-'a'+K)%26 + 'a';
        cout << s << endl;
    }
}

Measured memory_bytes: 512
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var KS = Console.ReadLine().SplittedStringToInt32List();
        var K = KS[0];
        var S = KS[1];
        var count = 0;
        for (int i = 0; i <= K; i++)
        {
            for (int j = 0; j <= K; j++)
            {
                var rem = S - i - j;
                if (rem >= 0 && rem <= K)
                {
                    count++;
                }
            }
        }
        Console.WriteLine(count);

        Console.ReadLine();
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();

    public const int INF = int.MaxValue / 2;
    #endregion
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

int main() {
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    ll p = (a1 - b1) * t1;
    ll q = (a2 - b2) * t2;

    if (p > 0) {
        p *= -1;
        q *= -1;
    }

    if (p + q == 0) {
        cout << "infinity" << endl;
    } else if (p + q < 0) {
        cout << 0 << endl;
    } else {
        ll s = (-p) / (p + q);
        ll t = (-p) % (p + q);
        if (t == 0) {
            cout << s * 2 << endl;
        } else {
            cout << s * 2 + 1 << endl;
        }
    }

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node find(Node u, int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key){
      u=u->left;
    }
    else{
      u=u->right;
    }
  }
  return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
	}

    else {
      x = x->right;
    } 
  }

  z->parent=y;
  if(y == NIL){ 
    root = z;
  }
  else if(z->key < y->key){
    y->left = z ;
  }
  else {
    y->right = z;
  } 
}

void inorder(Node u){

  if(u->left != NIL){
    inorder(u->left);
  }

  printf(" %d",u->key);

  if(u->right != NIL){
    inorder(u->right);
  }

}

void preorder(Node u){

  printf(" %d",u->key);

  if(u->left != NIL){
    preorder(u->left);
  }

  if(u->right != NIL){
    preorder(u->right);
  }

}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = find(root, x);
      if ( t != NIL ) {
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    } 
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 19364
import numpy as np

N = int(input())
L = list( map(int,input().split()) )

D = np.zeros(2*(10**5)+1,dtype=int)


for i in L:
    D[i] += 1

Dcopy = D

# D = np.where(D>1,(D-1)*D/2,0)
D = D*(D-1)/2
temp = int(D.sum())

for j in range(len(L)):
    if Dcopy[L[j]] > 1:
        print(temp - Dcopy[L[j]] + 1)
    else:
        print(temp)

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

int main() {
  int n;
  cin >> n;
  if(n%1000==0) cout << 0 << endl;
  else cout << 1000-n%1000 << endl;
  return 0;
}


Measured memory_bytes: 3616
// This template code suggested by KT BYTE Computer Science Academy
//   for use in reading and writing files for USACO problems.

// https://content.ktbyte.com/problem.java

import java.util.*;
import java.io.*;

public class Main {

    static StreamTokenizer in;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    static int[] dp;
    static boolean[] visited;
    static LinkedList<Integer>[] linkedLists;
    static int n;
    static int m;

    public static void main(String[] args) throws Exception {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        n = nextInt();
        m = nextInt();

        linkedLists = new LinkedList[n];

        for (int i = 0; i < n; i++) {
            linkedLists[i] = new LinkedList<>();
        }

        for (int i = 0; i < m; i++) {
            int node1 = nextInt() - 1;
            int node2 = nextInt() - 1;

            linkedLists[node1].add(node2);
        }

        dp = new int[n]; // longest path starting at node i

        visited = new boolean[n];

        for (int i = 0; i < n; i++) {
            if (visited[i]) continue;
            dfs(i);
        }

        int result = 0;

        for (int i = 0; i < n; i++) {
            result = Math.max(result, dp[i]);
        }

        out.println(result);

        out.close();
    }

    static void dfs(int curNode) {
        visited[curNode] = true;

        for (int i: linkedLists[curNode]) {
            if (visited[i]) {
                dp[curNode] = Math.max(dp[curNode], dp[i] + 1);
            }

            else {
                dfs(i);
                dp[curNode] = Math.max(dp[curNode], dp[i] + 1);
            }
        }
    }
}




Measured memory_bytes: 53448
import random
d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
numans=0
s=[]
for i in range(1,d+1):
    num1=1
    num2=-(10**100)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[j])*c[j])
    s.append(list(map(int,input().split())))
    for j in range(26):
        num5=s[i-1][j]-num3[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
    numans+=num2+s[i-1][num1-1]
    num[num1-1]=i
def sco(n1,n2,n3):
    n0=0
    n01=[0]*26
    old=ans[n1]
    ans[n1]=n2
    for k in range(n3):
        n0+=s[k][ans[k]-1]
        n01[ans[k]-1]=k+1
        for l in range(26):
            n0-=(k+1-n01[l])*c[l]
    return n0
for i in range(1540):
    num6=random.randint(1,26)
    num7=random.randint(2,365)
    num100=sco(num7-1,num6,d)
    if num100>numans:
        ans[num7-1]=num6
for i in range(d):
    print(ans[i])


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

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


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    L = LI()
    cnt = 0
    for b in itertools.combinations(L,3):
        a = sorted(b)
        if a[0] < a[1] < a[2] and a[0] + a[1] > a[2]:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 70448
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> v(5, 0);
    for (ll i = 0; i < n; i++)
    {
        string temp;
        cin >> temp;
        if (temp[0] == 'M')
        {
            v[0]++;
        }
        else if (temp[0] == 'A')
        {
            v[1]++;
        }
        else if (temp[0] == 'R')
        {
            v[2]++;
        }
        else if (temp[0] == 'C')
        {
            v[3]++;
        }
        else if (temp[0] == 'H')
        {
            v[4]++;
        }
    }

    ll ans = 0;
    for (ll i = 0; i < 3; i++)
    {
        for (ll k = i + 1; k < 4; k++)
        {
            for (ll p = k + 1; p < 5; p++)
            {
                ans += v[i] * v[k] * v[p];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
m = 10**9+7
def cmb(r):
    N = 1
    R = 1
    for i in range(r):
        N = N*(n - i) % m
        R = R*(i+1) % m
    return N*pow(R, m-2, m)%m

ans = (pow(2, n, m) - ((cmb(a) + cmb(b) + 1)%m))%m
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; ++i) {
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v)  {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    int h = 1;
    while(h <= n) {
        G.push_back(h);
        h = 3*h + 1;
    }
    for (int i = G.size() - 1; i >= 0; --i) {
       insertionSort(A, n, G[i]);
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &A[i]);
    }
    cnt = 0;
    shellSort(A, n);
    cout << G.size() << endl;
    for (int j = G.size() - 1; j >= 0; --j) {
        cout << G[j] << " ";
    }
    cout << endl;
    cout << cnt << endl;
    for (int k = 0; k < n; ++k) {
        cout << A[k] << endl;
    }
}

Measured memory_bytes: 7108
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(long i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    long r,d,xx;
    cin >> r >> d >> xx;
    rep(i,10){
        xx = r*xx - d;
        cout << xx << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int MOD = 1000000007;
main(){
    ll A[3];
    cin >> A[0] >> A[1] >> A[2];
    if(A[0]%2 == 0 || A[1]%2 == 0 || A[2]%2 == 0){
        cout << 0 << endl;
        return 0;
    }
    sort(A,A+3);
    cout << A[0]*A[1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NO -1

struct tree { int p, l, r;};
struct tree T[MAX];
int n;

void Preorder ( int u ) {
    if ( u == NO ) return;
    printf(" %d", u);
    Preorder(T[u].l);
    Preorder(T[u].r);
}

void Inorder ( int u ) {
    if ( u == NO ) return;
    Inorder(T[u].l);
    printf(" %d", u);
    Inorder(T[u].r);
}

void Postorder ( int u ) {
    if ( u == NO ) return;
    Postorder(T[u].l);
    Postorder(T[u].r);
    printf(" %d", u);
}

int main(void) {
    int i, v, l, r, f, root;
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
        T[i].p = NO;
    }

    for ( i = 0; i < n; i++ ) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if ( l != NO ) T[l].p = v;
        if ( r != NO ) T[r].p = v;
    }

    for ( i = 0; i < n; i++ ) {
        if ( T[i].p == NO ) root = i;
    }

    printf("Preorder\n");
    Preorder(root);
    printf("\nInorder\n");
    Inorder(root);
    printf("\nPostorder\n");
    Postorder(root);
    printf("\n");

    return 0;

}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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 int MOD = 2019;

ll combination(int n, int r)
{
    ll numerator = 1;
    ll denominator = 1;
    for (int i = 0; i < r; i++)
    {
        numerator *= n - i;
        if (numerator % (i + 1) == 0)
        {
            numerator /= (i + 1);
        }
        else
        {
            denominator *= (i + 1);
        }
    }
    return numerator / denominator;
}

int main()
{
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    int n = s.size();
    map<ll, int> mp; // mod2019の個数を保存する
    ++mp[0];
    ll num = 0;
    ll keta = 1;
    for (int i = 0; i < n; i++)
    {
        num += (s[i] - '0') * keta;
        num %= MOD;
        // cout << num << endl;
        ++mp[num];
        keta = (keta * 10) % MOD;
    }
    ll ans = 0;
    for (auto m : mp)
    {
        ans += combination(m.second, 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3680
N, A = gets.split.map(&:to_i)
xs = gets.split.map{|c| c.to_i - A}
dp = Array.new(N+1){Hash.new(0)}
dp[0][0] = 1
N.times do |i|
    dp[i].each do |k, v|
        dp[i+1][k] += v
        dp[i+1][k+xs[i]] += v
    end
end
puts dp[N][0] - 1

Measured memory_bytes: 3196
N, M = map(int, input().split())
lights = []
for i in range(M):
    k, *s = map(int, input().split())
    lights.append(list(map(lambda x: x-1, s)))
P = list(map(int, input().split()))
ans = 0
for b in range(2 ** N):
    flg = True
    for m in range(M):
        cnt = 0
        for switch in lights[m]:
            if (b >> switch) & 1:
                cnt += 1
        if cnt % 2 != P[m]:
            flg = False
    if flg:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
 
    long long ans = 0;
    int MaxNum = 0;
    for (int i = 0; i < N; i++)
    {
        //MaxNumを使い回すことで計算を抑える
        MaxNum = max(MaxNum, A[i]);
        int Bi = MaxNum;
        ans += Bi - A[i];
    }
 
    cout << ans << endl;
}

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

int main(){
  int N;
  string M;
  cin>>N;
  cin>>M;
  
  int count=0;
  for(int i=0;i<N-2;i++){
    if(M.at(i)=='A'){
      if(M.at(i+1)=='B'){
        if(M.at(i+2)=='C'){
          count++;
        }
      }
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>

using namespace std;

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

	if(a < b){
		int tmp = a;
		a = b;
		b = tmp;
	}
	if(a < c){
		int tmp = a;
		a = c;
		c = tmp;
	}
	for(int i = 0; i < k; ++i){
		a *= 2;
	}
	
	int ans = a + b + c;
	cout << ans << endl;
}


Measured memory_bytes: 256
N, M = (int(x) for x in input().split())
s = [0]*M
c = [0]*M
for i in range(M):
  s[i], c[i] = [int(p) for p in input().split()]

n = [0]*N

for j in range(len(s)):
  if N > 1 and s[j] == 1 and c[j] == 0:
    print(-1)
    exit()
for p in range(len(s)):
  for q in range(len(s)):
    if p == q:
      pass
    else:
      if s[p] == s[q] and c[p] != c[q]:
        print(-1)
        exit()		
for k in range(M):
  l = s[k]
  n[l-1] = c[k]
if N > 1 and n[0] == 0:
  n[0] = 1
resstr = [str(x) for x in n]
res = "".join(resstr)
result = int(res)   
print(result)

Measured memory_bytes: 3192
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      //取得
	  int A = sc.nextInt();
      int B = sc.nextInt();
      if(A<=8 && B<=8){
        System.out.println("Yay!");
      }else{
        System.out.println(":(");
      }
    }
}

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

using namespace std;

int main(){
    char s_1[10], s_2[10], s_3[10], *conc[3] = {""};
    while(scanf("%s %s %s", s_1, s_2, s_3)!=EOF){
        printf("%c%c%c\n", toupper(s_1[0]), toupper(s_2[0]), toupper(s_3[0]));
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
//#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 1000000000

#define MOD 1000000007

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void swap2(double* a, double* b)
{
	double tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)  //最大公約数
{
	if (a < b)
		swap(&a, &b);

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

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

long power(long x, int n) { //x^n 計算量O(logn)
	long ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x;
		}
		x = x * x; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

int choose(int n, int k) {
	return k == 0 ? 1 : (long long)choose(n - 1, k - 1) * n % MOD * power(k, MOD - 2) % MOD;
}

void bubble_sort(int a[], int n)
{
	int i, j, tmp;

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

		for (j = n - 1; j > i; j--)
		{
			if (a[j - 1] > a[j])
			{
				tmp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = tmp;
			}
		}
		printf("\n");
	}
}

void selection_sort(int a[], int n)
{
	int i, j, tmp, min, key;

	for (i = 0; i < n - 1; i++)
	{
		min = i;
		key = a[i];

		for (int k = 0; k < n; k++)
			printf("%d ", a[k]);

		for (j = i + 1; j < n; j++)
		{
			if (a[j] < a[min])
			{
				min = j;
				key = a[j];
			}
		}

		tmp = a[i];
		a[i] = a[min];
		a[min] = tmp;

		printf("\n");
	}

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

void insertion_sort(int a[], int n)
{
	int i, j, tmp;

	for (i = 1; i < n; i++)
	{
		j = i;

		while (j >= 1 && a[j - 1] > a[j])
		{
			tmp = a[j];
			a[j] = a[j - 1];
			a[j - 1] = tmp;
			j--;
		}
	}
}

void shell_sort(int a[], int n)
{
	int h, i, j;

	for (h = 1; h < n / 9; h = h * 3 + 1)
		;

	for (; h > 0; h /= 3)
	{
		for (int k = 0; k < n; k++)
			printf("%d ", a[k]);

		for (i = h; i < n; i++)
		{
			j = i;
			while (j >= h && a[j - h] > a[j])
			{
				swap(&a[j - h], &a[j]);
				j -= h;
			}
		}
		printf("\n");
	}

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

int partition(int a[], int l, int r)
{
	int i, j, pivot;

	i = l - 1;
	j = r;
	pivot = a[r];

	for (;;)
	{
		while (a[++i] < pivot)
			;
		while (i < j-- && pivot < a[j])
			;

		if (i >= j)
			break;

		swap(&a[i], &a[j]);
	}

	swap(&a[i], &a[r]);
	return i;
}

void quick_sort1(int a[], int l, int r)
{
	int v;

	if (l >= r)
		return;

	v = partition(a, l, r);

	quick_sort1(a, l, v - 1);
	quick_sort1(a, v + 1, r);
}

void quick_sort(int a[], int n)
{
	quick_sort1(a, 0, n - 1);
}

int keta(int a,int n)
{
	if (n == 1)
		return a % 10;

	for (int i = 0; i < n-1; i++)
		a /= 10;

	return a % 10;
}

int main() {
	
	int N, M, K;
	

	scanf("%d", &N);

	int a,b;

	a = N%100;
	b = N/100;

	if ( a>= 1 && a <= 12 && b >= 1 && b <= 12)
	{
		printf("AMBIGUOUS");
	}
	else if (a>=1 && a <= 12)
	{
		printf("YYMM");
	}
	else if (b>=1 && b <= 12)
	{
		printf("MMYY");
	}
	else
		printf("NA");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
	char s[5];
	cin >> s;
	int a = 0;
	int b = 0;
	for (int i = 0; i < strlen(s); i++)
	{
		if (s[i] == 'A')
			a++;
		else
			b++;
	}
		if (a > 0 && b > 0)
			cout << "Yes";
		else
			cout << "No";

}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);

  for (int i = 0; i < N; ++i) cin >> P[i];

  int ans = 1;
  int mi = P[0];

  for (int i = 1; i < N; ++i) {
    if (P[i] <= mi) ans++;
    mi = min(mi, P[i]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
from sys import stdin
input = stdin.readline

def main():
    N, K = map(int, input().rstrip().split())
    A = list(map(int, input().rstrip().split()))
    F = list(map(int, input().rstrip().split()))
    A.sort()
    F.sort(reverse=True)
    l = -1
    r = 10 ** 12
    while(r - l > 1):
        c = (l + r) // 2
        s = 0
        for i in range(N):
            d = A[i] - (c // F[i])
            s += max(0, d)
        if s <= K:
            r = c
        else:
            l = c
    print(r)

if __name__ == "__main__":
    main()
    


Measured memory_bytes: 113508
N = int(input())
T, A = map(int, input().split())
a = list(map(int, input().split()))

answers = []

for j in a:
  a_2 = T - j * 0.006
  answer = abs(A - a_2)
  answers.append(answer)

min_answer = min(answers)
index_number = answers.index(min_answer)
print(index_number +1)
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll a;
    cin >> a;
    cout << (a >= 30 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b){
  if(b)cout<<"Yes";
  else cout<<"No";
}
void yes(li b){
  if(b)cout<<"yes";
  else cout<<"no";
}

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


li N,K;
cin >>N>>K;

  vi H(N);
  Input(H);

  SortD(H);

  li sum=0;

  for(int i = 0+K; i<N;++i){
  	sum += H[i];
  }

  cout <<sum;

}

Measured memory_bytes: 4872
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=1e5+5;
//ll a[N],sum[N];
struct node{
    ll a,b,c;
}p[N];
int n,m,i,j,k;
bool cmp(node x,node y){
    return x.a*i+x.b*j+x.c*k>y.a*i+y.b*j+y.c*k;
}
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> n>>m;
    ll ans=0;
    for(int i=1;i<=n;i++)   cin >>p[i].a>>p[i].b >>p[i].c;
    for( i=-1;i<=1;i+=2){// i,j,k分别代表绝对值里的符号趋向
        for( j=-1;j<=1;j+=2){
            for( k=-1;k<=1;k+=2){
                sort(p+1,p+1+n,cmp);
                ll t[4]={0};
                for(int te=1;te<=m;te++)    t[1]+=p[te].a,t[2]+=p[te].b,t[3]+=p[te].c;
                ans=max(ans,t[1]*i+t[2]*j+t[3]*k);
            }
        }
    }
    cout << ans << endl;
 
    return 0;
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A >= C && B <= C) {
        cout << "Yes" << endl;
    }
    else if(A <= C && B >= C) { 
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



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

int main() {
  string A,B,C;
  cin >> A >> B >> C;
  int a = A.size(), b = B.size();
  
  if(A[a-1] == B[0] && B[b-1] == C[0]) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int l,r,d;
cin>>l>>r>>d;
int ans=0;
ans=r/d;
ans-=((l-1)/d);
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N ,M; cin >> N >> M;
  vector<ll> a(N); rep(i,N) cin >> a[i];
  SORT(a);

  // 2分探索で最小値を求める
  ll left = 0 , right = 1e15;
  ll cnt = 0;
  rep(loop, 53){
    // cout << left << " " << right << endl;
    ll m = (left + right) / 2;
    cnt = 0;
    rep(i,N){
      // 足してm以上になる個数を足していく
      cnt += N - POSL(a , m - a[i]);
    }
    if(cnt >= M) left = m;
    else right = m;
  }
  // leftが最小値
  vector<ll> sum(N + 1);
  for(ll i = 0 ; i < N ; i ++){
    sum[i + 1] = sum[i] + a[N - i - 1];
  }
  ll ans = 0;
  ans -= (cnt - M) * left;
  rep(i,N){
    ll tmp = N - POSL(a , left - a[i]);
    ans += tmp * a[i];
    ans += sum[tmp];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
n,m = map(int,input().split())
a = [[0 for j in range(m)]for i in range(n)]
b = [0 for i in range(m)]
c = [0 for i in range(n)]

for i in range(n):
    a[i]=list(map(int,input().split()))
for i in range(m):
    b[i]=int(input())
for i in range(n):
    sum = 0
    for j in range(m):
        sum += a[i][j]*b[j]
    c[i] = sum
    print(c[i])


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int c[3][3];

bool judge() {
    int d1 = c[0][2] - c[1][2], d2 = c[1][2] - c[2][2];
    REP(i, 2) {
        if(d1 != c[0][i] - c[1][i] || d2 != c[1][i] - c[2][i]) return false;
    }
    d1 = c[2][0] - c[2][1], d2 = c[2][1] - c[2][2];
    REP(i, 2) {
        if(d1 != c[i][0] - c[i][1] || d2 != c[i][1] - c[i][2]) return false;
    }
    return true;
}

int main() {
    REP(i, 3) {
        REP(j, 3) {
            cin >> c[i][j];
        }
    }

    cout << (judge() ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	int L;
	double x,V,ans;

	cin >> L;

	x = 0.001;
	ans = 0;

	while(x < L){
		V = (L-x)*(L-x)*x/4;					//Vの最大値を、予選決勝法で求めた
		if(ans < V){
			ans = V;
		}
		x = x + 0.001;
	}

	cout << "\n" << fixed << setprecision(15) << ans;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
//#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;




/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

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

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/
/*
const int N=100001;
ll fact_inverse[N];
ll num_inverse[N];
ll fact[N];
void number_inverse(int m){
   num_inverse[0]=1;
   num_inverse[1]=1;
   for(int i=2;i<=N;i++){
     num_inverse[i]=num_inverse[m%i]*(m - m/i)%m;
   }
}

void factorial_inverse(int m){
   fact_inverse[0]=1;
   fact_inverse[1]=1;
   for(int i=2;i<=N;i++){
      fact_inverse[i]=(num_inverse[i]*fact_inverse[i-1])%m;
   }
}

void factorial(int m){
  fact[0]=1;
  for(int i=1;i<=N;i++)fact[i]=(i*fact[i-1])%m;
}

int modular_nCr(int n,int r,int m){
   ll res=((fact[n]*fact_inverse[r])%m *  fact_inverse[n-r])%m;
   return res;
}
*/
 
int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
     ll a,b,c,d;
     cin>>a>>b>>c>>d;
     ll a1=a*c;
     ll a2=b*d;
     ll a3=b*c;
     ll a4=a*d;
     cout<<max(a1,max(a2,max(a3,a4)))<<endl;
}
}









Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int ans = 0;
    int p[n]; 
  	rep(i,n) cin >> p[i];
    rep(i,n-2){
        if(p[i] < p[i+1] && p[i+1] < p[i+2]) ans++;
      	else if(p[i] > p[i+1] && p[i+1] > p[i+2]) ans++;
    }
    ANS;
    
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

max_value = 0
for i in range(k):
    max_value += (p[i] + 1) * 0.5

l, r = 1, k
cur = max_value
while r < n:
    cur += (p[r] - p[l-1]) * 0.5
    max_value = max(max_value, cur)
    l += 1
    r += 1
print(max_value)


Measured memory_bytes: 25060
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int x,y;
  cin>>x>>y;
  cout<<max(0,x-2*y);
	return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int eaten = 0;
    int e1 = min(c, b);
    eaten += 2*e1;
    c -= e1;
    b -= e1;
    int e2 = min(c, a+1);
    eaten += e2;
    eaten += b;
    cout << eaten << endl;
}


Measured memory_bytes: 256
a = [0, 0, 0, 0, 0]
a.map! { STDIN.gets.to_i }
b = a.map {|n|((n%10)==0)?n:((n/10)+1)*10}
c = a.map {|n|((n%10)==0)?10:n%10}
i = c.index(c.min)
b[i] = a[i]
puts b.inject(:+)

Measured memory_bytes: 3836
using System;
using System.Collections.Generic;

namespace Testcode
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] d = Console.ReadLine().Split();
            int a = int.Parse(d[0]);
            int b = int.Parse(d[1]);
            int c = int.Parse(d[2]);

            int[] array = { a, b, c };
            List<int> copy = new List<int>(array);
            copy.Sort();

            Console.WriteLine(string.Join(" ", copy));
        }
    }
}



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

using namespace std;

int main() {
    int N, Q; string S; cin >> N >> Q >> S;
    vector<int> n(N);

    int count = 0;
    for (int i = 1; i < N; ++i) {
        if (S[i - 1] == 'A' && S[i] == 'C') {
            ++count;
        }
        n[i] = count;
    }

    int l, r;
    for (int i = 0; i < Q; ++i) {
        cin >> l >> r;
        cout << n[r-1] - n[l-1] << endl;
    }   
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[202020],B[202020],D[202020];

int le(int v) {
	v--;
	if(v<0) v+=N;
	return v;
}
int ri(int v) {
	v++;
	if(v>=N) v-=N;
	return v;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];
	
	ll num=0;
	queue<int> Q;
	FOR(i,N) if(B[i]>B[le(i)]+B[ri(i)] && B[i]>A[i]) Q.push(i);
	while(Q.size()) {
		i=Q.front();
		Q.pop();
		
		//cout<<num<<" "<<i<<" "<<B[0]<<" "<<B[1]<<" "<<B[2]<<endl;
		
		ll L=B[le(i)];
		ll R=B[ri(i)];
		ll S=L+R;
		
		if(B[i]<=S) continue;
		if(B[i]<A[i]) return _P("-1\n");
		if(B[i]<=A[i]) continue;
		
		if(A[i]>S) {
			if((B[i]-A[i])%S) return _P("-1\n");
			num+=(B[i]-A[i])/S;
			B[i]=A[i];
		}
		else {
			ll v=B[i]/S;
			if(B[i]%S) {
				num+=v;
				B[i]%=S;
			}
			else {
				num+=v-1;
				B[i]=S;
			}
		}
		x=le(i);
		if(B[x]>B[le(x)]+B[ri(x)] && B[x]>A[x]) Q.push(x);
		x=ri(i);
		if(B[x]>B[le(x)]+B[ri(x)] && B[x]>A[x]) Q.push(x);
	}
	
	FOR(i,N) if(A[i]!=B[i]) return _P("-1\n");
	cout<<num<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] nums=reader.readLine().split(" ");
        int num1=Integer.parseInt(nums[0]);
        int num2=Integer.parseInt(nums[1]);
        System.out.println(Integer.toString(num1*num2) + " " + Integer.toString((num1+num2)*2));
	}
}

Measured memory_bytes: 24252
def main():
    N = int(input())
    P = list(map(int, input().split()))
    cnt = 0
    for i in range(N):
        if P[i] != i+1:
            cnt += 1
    if cnt == 0 or cnt == 2:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int n_copy=n;
		long k = sc.nextLong();
		//long h = k%n;
		long k_copy = k;
		//System.out.println(h);
		int[] arr = new int[n+1];
		for(int i=1;i<=n;i++){
			arr[i]=sc.nextInt();
		}
		// find the cycle in the graph
		int l = arr[1];
		int r = arr[arr[1]];
		while(l!=r){
			l=arr[l];
			r=arr[arr[r]];
		}
		l =1;
		while(l!=r){
			l=arr[l];
			r=arr[r];
		}
		// found the first node of the cycle

		// number of the element before the start of the cycle
		int cycstart = l;
		int ele=0;
		l=1;
		while(l!=cycstart){
			ele++;
			l=arr[l];
		}

		// find the lenght of the cycle
		cycstart=l;
		int len=1;
		l=cycstart;
		while(arr[l]!=cycstart){
			len++;
			l=arr[l];
		}
		l=1;
		while(ele!=0 && k!=0){
			l=arr[l];
			ele--;
			k--;
		}
		if(k==0){
			System.out.println(l);
			return;
		}
		k = k%len;

		while(k!=0){
			l=arr[l];
			k--;
		}
		System.out.println(l);
	}
}

Measured memory_bytes: 60044
#include <iostream>

using namespace std;

int main(){
	int h, w;
	for(;;){
		cin >> h;
		cin >> w;
		if(0 == h && 00 == w){break;}

		for(int j = 0; j < w; j++){
			cout << "#";
		}
		cout << endl;

		for(int i = 1; i < h - 1; i++){
			cout << "#";
			for(int j = 1; j < w - 1; j++){
				cout << ".";
			}
			cout << "#" << endl;
		}

		for(int j = 0; j < w; j++){
			cout << "#";
		}
		cout << endl << endl;
	}
	return 0;
}

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

#define INF INT32_MAX
#define MAX 100

int N, M, C;
int A[MAX][MAX];
int B[MAX];

int main() {
	cin >> N >> M >> C;
	for( int i = 0; i < M; i++ ) {
		cin >> B[i];
	}
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < M; j++ ) {
			cin >> A[i][j];
		}
	}

	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		int s = 0;
		for( int j = 0; j < M; j++ ) {
			s += A[i][j] * B[j];
		}
		if( s + C > 0 ) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256