akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();

        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) {
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 41832
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;
struct po{
  string a,b;
};
int n;
vector <po> str;
int ans;
string goal;
int cnt = 0;
set <string> memo;

void saiki(string y, int kai) {
  cnt++;
  // cout << y << endl;
  if(y == goal && ans > kai) ans = kai;
  
    
  if(ans > kai && y.size() < 11) 
    for(int i=0;i<n;i++) {
      string ima = y;
      for(int j=0;j<ima.size();j++) {
	if(str[i].a.size()>ima.size()-j) break; 
	int flg = 0;
	for(int k=0;k<str[i].a.size();k++) {
	  if(str[i].a[k] != ima[j+k]) {
	    flg = 1;
	    break;
	  }
	}
	if(flg == 0) {
	  string nx;
	  int nj;
	  for(int k=0;k<ima.size();k++) {
	    if(k == j) nx += str[i].b,k+= str[i].a.size()-1,nj = nx.size()-1;
	    else nx+= ima[k];
	  }
	  j = nj;
	  ima = nx;
	}
      }
      if(y != ima && memo.count(ima) == 0) {
	memo.insert(ima);
	saiki(ima,kai+1);

      }
    }
}



int main() {
  
  while(1) {
  cin >> n;
  if(n == 0) break;
  
  str.resize(n);
  for(int i=0;i<n;i++) cin >> str[i].a >> str[i].b;

  memo.clear();
  string start;
  cin >> start;
  cin >> goal;

  ans = 10000000;  
  saiki(start,0);
  if(ans == 10000000) cout << -1 <<endl;
  else cout << ans << endl;
  //cout <<cnt <<endl;
  }

  return 0;
}

Measured memory_bytes: 1720
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int r = scan.nextInt();
      	int b = scan.nextInt();
      	int g = scan.nextInt();
      	int s = 100 * r + 10 * b + g;
      	if(s % 4 == 0){
        	System.out.print("YES");
        }
      	else{
        	System.out.print("NO");
        }
    }
}

Measured memory_bytes: 23380
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X =sc.nextInt();
    if (X==3 || X==5 || X==7){
      System.out.println("YES");
    }else{
       System.out.println("NO");
    }
  }
}

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

int main()
{
    long long n,i;
    cin>>n;
    long long arr[n+10];
    long long arr1[n+10];
    for(i=0; i<n; i++)
    {
        cin>>arr[i];
        arr1[i]=arr[i];
    }
    sort(arr1,arr1+n);
    for(i=0; i<n; i++)
    {
        if(arr[i]==arr1[n-1])
            cout<<arr1[n-2]<<endl;
        else
            cout<<arr1[n-1]<<endl;
    }
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	long long int x;
	cin >> x;
	for(long long int a=0;a<=10000;a++){
		long long int B = pow(a,5) - x;
		long long int i=0, j=0;
		while(pow(i,5) <= B){
			if(pow(i,5) == B){
				cout << a << " " << i << endl;
				return 0;
			}else{
				i++;
			}
		}
		while(pow(j,5) >= B){
			if(pow(j,5) == B){
				cout << a << " " << j << endl;
				return 0;
			}else{
				j--;
			}
		}
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string S; cin >> S;
    if (S.size() == 3) reverse(all(S));
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "YES";
    private static final String NO = "NO";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] p = new int[N];
        for (int i=0; i<N; i++) {
            p[i] = sc.nextInt();
        }

        System.out.println(solve(N, p) ? YES : NO);
    }

    private static boolean solve(int N, int[] p) {
        int diff = 0;

        for (int i=0; i<N; i++) {
            if (p[i] != i+1) diff++;
        }

        if (diff <= 2) return true;

        return false;
    }
}

Measured memory_bytes: 23380
#include<stdio.h>
int main(){
  int n,s[400],l[400],p[400],m,w,i,j,k,dp[400][400],ans[400],flag=0;
  scanf("%d\n",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d %d\n",&s[i],&l[i],&p[i]);
  }
  for(i=0;i<=n;i++){
    for(j=0;j<=393;j++){
      dp[i][j]=0;
    }
  }
  for(i=1;i<=n;i++){
    for(k=s[i];k<=l[i];k++){
      for(j=0;j<=393;j++){
        if(j-k>=0){
          if(dp[i][j-k]+p[i]>dp[i][j]){
            dp[i][j]=dp[i][j-k]+p[i];
          }
          if(dp[i-1][j]>dp[i][j]){
            dp[i][j]=dp[i-1][j];
          }
        }
        else{
          if(dp[i-1][j]>dp[i][j]){
            dp[i][j]=dp[i-1][j];
          }
        }
      }
    }
  }
  scanf("%d\n",&m);
  for(i=0;i<m;i++){
    scanf("%d\n",&w);
    if(dp[n][w]==0){
      flag=1;
      break;
    }
    else{
      ans[i]=dp[n][w];
    }
  }
  if(flag==1){
    printf("-1\n");
  }
  else{
    for(i=0;i<m;i++){
      printf("%d\n",ans[i]);
    }
  }
  return 0;
}


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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
#define int long long
//#define double long double
#define MOD 1000000007LL

int fpow(int a, int b)
{
    int ret = 1;
    while (b)
    {
        if (b & 1)
            ret = ret * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return ret;
}

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

    int n;
    cin >> n;
    cout << (fpow(10, n) - fpow(9, n) - fpow(9, n) + fpow(8, n) + MOD * 10) % MOD << '\n';

    return 0;
}

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

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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int l, r, d;
    cin >> l >> r >> d;
    int ret = 0;
    for (int i = l; i <= r; ++i) {
        if (i % d == 0)
            ret++;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3588
def main():
    n=int(input())
    ans=[]
    if n==0:
        print(n)
    else:
        while n!=0:
            ans.append(n%2)
            n = n//(-2) + n%abs(-2)
        for i in ans[::-1]:
            print(i,end="")
        print()
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	array<ll, 5> c = {0, 0, 0, 0, 0};
	string s = "MARCH";
	for( int i = 0; i < n; ++i ){
		string temp;
		cin >> temp;
		for( int j = 0; j < 5; ++j ){
			if( temp.at(0) == s.at(j) ){
				++c.at(j);
				break;
			}
		}
	}
	ll ans =
	c.at(0) * c.at(1) * c.at(2) + c.at(0) * c.at(1) * c.at(3) +
	c.at(0) * c.at(1) * c.at(4) + c.at(0) * c.at(2) * c.at(3) +
	c.at(0) * c.at(2) * c.at(4) + c.at(0) * c.at(3) * c.at(4) +
	c.at(1) * c.at(2) * c.at(3) + c.at(1) * c.at(2) * c.at(4) +
	c.at(1) * c.at(3) * c.at(4) + c.at(2) * c.at(3) * c.at(4);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
def prime(a):
    if a == 2 or a == 3:
        return True
    for i in range(2, int(math.sqrt(a))+2):
        if a%i == 0:
            return False
    return True

b = int(input())
count = 0
for i in range(b):
    x = int(input())
    if prime(x):
        count += 1
print(count)



Measured memory_bytes: 5672
import collections
H,W = map(int,input().split())
Map = []
black_cnt = 0
for i in range(H):
    tmp = list(input())
    black_cnt += tmp.count('#')
    Map.append(tmp)

Counter = [[float('inf') for j in range(W)]for i in range(H)]
Visited = [[False for j in range(W)]for i in range(H)]
q = collections.deque()
q.append((0,0,0))
while q:
    y,x,cnt = q.popleft()
    if 0>y or H<=y or 0>x or W<=x:
        continue
    if Map[y][x] == '#':
        continue
    Counter[y][x] = min(Counter[y][x],cnt)
    if Visited[y][x]:
        continue
    Visited[y][x]=True
    
    cnt += 1
    q.append((y+1,x,cnt))
    q.append((y-1,x,cnt))
    q.append((y,x+1,cnt))
    q.append((y,x-1,cnt))
if Visited[H-1][W-1] == False:
    print('-1')
else:
    print(H*W-Counter[H-1][W-1]-black_cnt-1)


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

int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for(int i=2;i<n;i++){
	    dp[i] = min(abs(arr[i] - arr[i-1]) + dp[i-1], abs(arr[i] - arr[i-2]) + dp[i-2]);
	}
	cout<<dp[n-1];
	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N;
    cin >> N;

    vector<ll> a(N);
    rep (i, N) {
        cin >> a[i];
    }

    ll ans = 0;
    rep (i, N) {
        if (a[a[i]-1] == i+1) {
            ans++;
        }
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int a, b, c, d, e;
int main() {
    vector<int> a(5);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int num, min = 9, idx = 0;
    rep(i, 0, 5) {
        cin >> num;
        int keta = num % 10;
        if(keta < min && keta != 0) {
            min = keta;
            idx = i;
        }
        a[i] = num;
    }
    // lossを求める
    int sum = 0;
    for(int i = 0; i < 5; i++) {
        if(i == idx) {
            sum += a[i];
        } else if(a[i] % 10 == 0) {
            sum += a[i];
        } else {
            // cout << (10 - (a[i] % 10)) + a[i] << endl;

            sum += (10 - (a[i] % 10)) + a[i];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repp(i, n) for(int i = 1; i <= (int)(n); i++)
#define co(x) cout<<x<<endl
typedef long long int lint;
 
int main() {
  long double a,b,c;
  cin >> a >> b >> c;
  if(a + 2*sqrt(a*b) + b < c){co("Yes");}
  else{co("No");}
}

Measured memory_bytes: 256
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]

check = [(-1, 0), (0, -1), (1, 0), (0, 1)]
for j in range(h):
  for i in range(w):
    if grid[j][i] == "#":
      temp = [(i+cx, j+cy) for cx, cy in check if (0<= i+cx <w and 0<= j+cy <h)]
      count = 0
      for t_cx, t_cy in temp:
        if grid[t_cy][t_cx] == "#":
          count += 1
      if count == 0:
        print("No")
        exit()
print("Yes")

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(ki,k) {
        vector<int> b(n+1);
        // imos法
        rep(i,n) {
            int l = max(0, i-a[i]); // 左端を決める。ベクターの配列を超えないようにする
            int r = min(i+a[i]+1, n); // 右端を決める。ベクターの配列を超えないようにする
            b[l]++; b[r]--; // imos法。区間の左端に +1, 右端の1つみぎに -1。
        }
        rep(i,n) b[i+1] += b[i]; // 累積和を計算
        b.pop_back(); // 末尾に加えた、番兵を削除
        if (a == b) break; // 値はあるところで収束する。もし収束したら打ち切り
        a = b; // a の値を更新。ベクターでこの操作ができることは知らなかった。
    }
    rep(i,n) cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 4828
s = gets.chomp

if s.size.odd?
  s = s[0..-2]
else
  s = s[0..-3]
end

i = s.size
while s.size > 0
  if s[0..(i/2-1)] == s[(i/2)..-1]
    break
  end
  s =  s[0..-2]
  i = s.size
end

puts s.size

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

using namespace std;

int main(){
	int n, m;
	cin>>n>>m;
	vector<int> heights(n,0);
	for(int i=0; i<n; i++)
		cin>>heights[i];
	vector<int>counts(n,0);
	for(int i=0; i<m; i++){
		int a,b;
		cin>>a>>b;
		if(heights[a-1]>heights[b-1])
			counts[b-1]++;
		else if(heights[a-1]<heights[b-1])
			counts[a-1]++;
		else{
			counts[a-1]++;
			counts[b-1]++;
		}
	}
	int ans=0;
	for(int i=0; i<n; i++){
		if(counts[i]==0)
			ans++;
	}
	cout<<ans<<"\n";

}


Measured memory_bytes: 4032
#include <stdio.h>
int main(){
    int n,height,top[3];
    for(n=1;n<=10;n++){
        scanf("%d",&height);
        if(top[0]<height){
            top[2]=top[1];
            top[1]=top[0];
            top[0]=height;
        }
        else if(top[1]<height){
            top[2]=top[1];
            top[1]=height;
        }
        else if(top[2]<height){
            top[2]=height;
        }
    }
    for(n=0;n<3;n++){
        printf("%d\n",top[n]);
    }
    return 0;
}

Measured memory_bytes: 600
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a= inp()
print(800*a -(a//15)*200)


Measured memory_bytes: 3572
/* https://atcoder.jp/contests/arc084/tasks/arc084_a */

#include <iostream>
#include <vector>
#include <algorithm>

/* {{{ Variables */
int N;
std::vector<int> A;
std::vector<int> B;
std::vector<int> C;
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  std::cin >> N;

  A = std::vector<int>(N);
  B = std::vector<int>(N);
  C = std::vector<int>(N);

  for (int& e: A)
    std::cin >> e;

  for (int& e: B)
    std::cin >> e;

  for (int& e: C)
    std::cin >> e;
  /* }}} */

  /* {{{ Output */
  std::sort(A.begin(), A.end());
  std::sort(B.begin(), B.end());
  std::sort(C.begin(), C.end());

  long long num_combination = 0;
  int idx_A = 0;
  int idx_C = 0;

  for (int i = 0; i < N; ++i) {
    int b = B.at(i);

    while (idx_A < N) {
      int a = A.at(idx_A);

      if (a >= b) {
        break;
      }

      idx_A++;
    }

    while (idx_C < N) {
      int c = C.at(idx_C);

      if (b < c) {
        break;
      }

      idx_C++;
    }

    long long num_A = idx_A;
    long long num_C = N-idx_C;
    num_combination += num_A*num_C;
  }

  std::cout << num_combination << std::endl;
  /* }}} */

  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#define MAX 101
int main(){
  int i,j,k,n,a,b,A[MAX],B[MAX][MAX];

  scanf("%d",&n);
  for(i=1; i<=n; i++)
    scanf("%d%d",&A[i-1],&A[i]);
 
  for(i=1; i<=n; i++)
    B[i][i] = 0;
 
  for(j=2; j<=n; j++){

    for(i=1; i<=n-j+1; i++){
      a = i + j -1;
      B[i][a] = 1000000;

      for(k=i; k<=a-1; k++){
	b = B[i][k] + B[k+1][a] + A[i-1]*A[k]*A[a];
	if(B[i][a] >= b)
	  B[i][a] = b;
      }
    }
  }
 
  printf("%d\n",B[1][n]);
   
  return 0;
}

Measured memory_bytes: 636
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b,min_w=0;
  cin >> n>> a >> b;
  ll x[n];
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  for(int i=0;i<n-1;i++){
    min_w+= min((x[i+1]-x[i])*a,b);
  }
  cout << min_w<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

ll N;
ll X;

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

int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
    cin >> N >> X;
    ll M = N-X;
    cout << (N-gcd(N,M))*3 << endl;
    
    

    return 0;
}



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

int main(){
  string s;
  cin >> s;
  if (s[s.size() - 1] != 's'){
    cout << s << 's' << endl;
  } else {
    cout << s << "es" << endl;
  }
  return 0;
}

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

using namespace std;

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define EPS 1e-9
#define X real()
#define Y imag()

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

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;

int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string day[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string d;
	int k = 0;
	cin >> d;
	while(k < 7 && day[k] != d) ++k;
	cout << 7 - k << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StreamTokenizer;
import java.util.HashSet;
import java.util.InputMismatchException;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		int n = sc.nextInt();
		HashSet<String> ht = new HashSet<String>();
		
    	for (int i = 0; i < n; i++) {
    		String cmd = sc.next();
    		if (cmd.equals("insert")) {
    			ht.add(sc.next());
    		} else if (cmd.equals("find")) {
    			if (ht.contains(sc.next())) {
    				pr.println("yes");
    			} else {
    				pr.println("no");
    			}
    		}
    	}

    	pr.close();
    	sc.close();
	}

	private static class Scanner {
		InputStreamReader isr;
		BufferedReader br;
		StreamTokenizer st;
		
		Scanner (InputStream in) {
			isr = new InputStreamReader(in);
			br = new BufferedReader(isr);
			st = new StreamTokenizer(br);
		}
		
		String next() throws RuntimeException  {
			try {
				if (st.nextToken() != StreamTokenizer.TT_WORD) {
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}
			
			return st.sval;
		}
		
		int nextInt() throws RuntimeException {
			try {
				if (st.nextToken() != StreamTokenizer.TT_NUMBER) {
					throw new InputMismatchException();
				}
			} catch (IOException e) {
				throw new IllegalStateException();
			}
			
			return (int)st.nval;
		}

		void close() {
		}
	}
	
	private static class Printer {
		OutputStreamWriter osw;
		BufferedWriter bw;

		Printer(OutputStream out) {
			osw = new OutputStreamWriter(out);
			bw = new BufferedWriter(osw);
		}

		void println(String str) {
			try {
				bw.write(str);
				bw.newLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		void close() {
			try {
				bw.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}

Measured memory_bytes: 123752
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

//gcd
long gcd(long num1, long num2){
	if(num2 > num1){
		std::swap(num1, num2);
	}
	if(num2 == 0){
		return num1;
	}else{
		return gcd(num2, num1 % num2);
	}
}

long a, b;
std::set<long> st;

int main(){
    scanf("%ld%ld", &a, &b);
    long g = gcd(a, b);
    long ans = 1;
    for(long d = 2; d*d <= g; d++){
        if(g % d == 0){
            st.insert(d);
            while(g%d == 0){
                g /= d;
            }
        }
    }
    st.insert(1);
    st.insert(g);
    printf("%ld\n", st.size());
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

VI memo;
int dfs(int k, VI& av) {
    if(memo[k] != 0) return memo[k];
    int first_res = -1;
    for(auto a1 : av) {
        if(k - a1 >= 0)
            first_res = max(first_res, dfs(k - a1, av) * -1);
    }
    return memo[k] = first_res;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    VI a(n);
    REP(i, n) cin >> a[i];
    memo.resize(k + 1);
    cout << (dfs(k, a) == 1 ? "First" : "Second") << ln;
    return 0;
}


Measured memory_bytes: 6912
n = int(input())
score = [0] * n
for i in range(n):
    out_count = 0
    runner = 0
    while True:
        data = input()
        if data == "OUT":
            out_count += 1
            if out_count == 3:
                break
        elif data == "HIT":
            runner += 1
            if runner == 4:
                runner = 3
                score[i] += 1
        else:
            score[i] += runner + 1
            runner = 0
print(*score, sep="\n")

Measured memory_bytes: 7616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int n, ans;
VI abc, l;

const int INF = 1<<20;

int f(int x, VI lup, VI ldown){
    int cost = INF;
    int lusz = lup.size(), ldsz = ldown.size();
    rep(i, lusz){
        cost = min(cost, lup[i] - x);
    }
    for(int i = 1; i < (1<<ldsz); i++){
        VI used(ldsz);
        rep(j, ldsz) if (i>>j & 1) used[j] = 1;
        int len = 0;
        int merge = 0;
        rep(j, ldsz){
            if (used[j] == 0) continue;
            if (len != 0) merge += 10;
            len += ldown[j];
            cost = min(cost, abs(len - x) + merge);
        }
    }
    return cost;
}

void dfs(VI nums){
    if ((int)nums.size() == n){
        VI cnts(3);
        for(int j = 0; j < n; j++){
            cnts[nums[j]]++;
        }
        if (cnts[0] == 0 || cnts[1] == 0 || cnts[2] == 0) return;

        int sum = 0;
        for(int j = 0; j < 3; j++){
            int x = abc[j];
            VI lup, ldown;
            for(int k = 0; k < n; k++){
                if (nums[k] == j) {
                    if (l[k] >= x) lup.push_back(l[k]);
                    else ldown.push_back(l[k]);
                }
            }
            sum += f(x, lup, ldown);
        }
        ans = min(ans, sum);
    }else{
        for(int j = 0; j < 3; j++){
            nums.push_back(j);
            dfs(nums);
            nums.pop_back();
        }
    }
}

int main(){
    cin >> n;
    abc.resize(3);
    l.resize(n);
    rep(i,3) cin >> abc[i];
    rep(i,n) cin >> l[i];
    ans = INF;
    dfs(VI(0));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7; 

int main() {
	ll N; cin >> N;
	bitset<60> bs(N);
	vector<vector<long long>> dp(61, vector<long long>(3, 0));
	dp[60][0] = 1;
	for (int i = 60; i >= 1; --i) {
		if (bs[i - 1]) {
			dp[i - 1][0] = dp[i][0];
			dp[i - 1][1] = dp[i][0] + dp[i][1];
			dp[i - 1][2] = 2 * dp[i][1] + 3 * dp[i][2];
		}
		else {
			dp[i - 1][0] = dp[i][0] + dp[i][1];
			dp[i - 1][1] = dp[i][1];
			dp[i - 1][2] = dp[i][1] + 3 * dp[i][2];
		}
		dp[i - 1][0] %= MOD;
		dp[i - 1][1] %= MOD;
		dp[i - 1][2] %= MOD;
	}
	cout << (((dp[0][0] + dp[0][1]) % MOD) + dp[0][2]) % MOD << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  string s;
  cin>>s;
  int path=0;
  int pathb=0;
  for(int i=0;i<n;i++){
    if(s[i]=='c'){
      cout<<"No"<<endl;
    }
    else if(s[i]=='a'){
      if(path>=a+b){
        cout<<"No"<<endl;
        continue;
      }
      cout<<"Yes"<<endl;
      path++;
    }
    else {
      if(path>=a+b||pathb>=b){
        cout<<"No"<<endl;
        continue;
      }
      cout<<"Yes"<<endl;
      path++;
      pathb++;
    }
  }
}

Measured memory_bytes: 896
import math
n = input()
l = map(int, raw_input().strip().split())
m = 0
for x in l:
	m += x
ma = m/float(n)
m = int(math.ceil(ma))
ans = 0
for x in l:
	ans += (m-x)*(m-x)
m = int(math.floor(ma))
ans1 = 0
for x in l:
	ans1 += (m-x)*(m-x)
print(min(ans,ans1))

Measured memory_bytes: 2692
#include <stdio.h>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    int N;
    scanf("%d", &N);
    int A[N], B[N-1];
    int i=0;
    for(i=0;i<N-1;i++) {
        scanf("%d", &B[i]);
    }
    for(i=0;i<N;i++) {
        A[i] = 100001;
    }
    for(i=0;i<N-1;i++) {
        A[i] = MIN(B[i], A[i]);
        A[i+1] = MIN(B[i], A[i+1]);
    }
    int sum = 0;
    for(i=0;i<N;i++) {
        sum += A[i];
    }
    printf("%d", sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}




void test_case()
{
    
    int n;
    cin>>n;

    string s;
    cin >>s;

    string ans = "";
    for(auto it : s) {
        int val = it - 'A';
        val+= n;
        val = val % 26;

        char x = 'A' + val;
        ans += x;
        // <<val<<" ";
    }

    cout<<ans<<endl;

    



}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3704
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

#define int long long

const int maxn=200007;
int n,a[maxn],b[maxn];
int ans=0,spc=-1;

inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}

namespace Number{
	map<int,int> num;
	int cnt=0;

	inline int getnum(int x){
		if (num[x]==0){
			num[x]=++cnt;
			return cnt;
		} else return num[x];
	}
}

namespace UniSet{
	int fa[maxn],sum[maxn];

	inline void init(int n){
		for (int i=1;i<=n;i++) fa[i]=i,sum[i]=1;
	}

	inline int getfa(int x){
		if (fa[x]==x) return x;
		fa[x]=getfa(fa[x]);
		return fa[x];
	}

	inline void merge(int x,int y){
		int fx=getfa(x),fy=getfa(y);
		if (fx!=fy) fa[fx]=fy,sum[fy]+=sum[fx],sum[fx]=0;
	}

	bool vis[maxn];

	inline void count(){
		memset(vis,0,sizeof(vis));
		for (int i=1;i<=Number::cnt;i++){
			int f=getfa(i);
			if (vis[f]) continue;
			vis[f]=true;
			if (sum[f]==1 && f!=spc) continue;
			ans++;
		}
		ans--;
	}
}

inline bool check(){
	sort(a+1,a+1+n+1);
	sort(b+1,b+1+n+1);
	for (int i=1;i<=n+1;i++) if (a[i]!=b[i]) return printf("-1\n"),false;
	return true;
}

signed main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read(),a[n+1]^=a[i];
	for (int i=1;i<=n;i++) b[i]=read(),b[n+1]^=b[i],ans+=a[i]!=b[i];
	spc=Number::getnum(a[n+1]);
	UniSet::init(n+1);
	for (int i=1;i<=n+1;i++) UniSet::merge(Number::getnum(a[i]),Number::getnum(b[i]));
	if (!check()) return 0;
	UniSet::count();
	printf("%lld\n",ans<0?0:ans);
	return 0;
}

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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input();
  int s = 0, m = N;
  while (m) {
    s += m % 10;
    m /= 10;
  }

  cout << (N % s == 0 ? "Yes" : "No") << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N + 1)]
for a, b in X:
    graph[a].append(b)
    graph[b].append(a)

INF = 10 ** 9 + 7
d = [INF] * (N + 1)
ans = [0] * (N + 1)
q = deque([1])
d[1] = 0
while q:
    u = q.popleft()
    for v in graph[u]:
        if d[v] > d[u] + 1:
            d[v] = d[u] + 1
            ans[v] = u
            q.append(v)

print("Yes")
print(*ans[2:], sep="\n")


Measured memory_bytes: 129000
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if((a-b)<=c){
        cout<<c-(a-b)<<endl;
    }
    else if((a-b)>c){
        cout<<"0"<<endl;
    }
}


Measured memory_bytes: 256
data WesternDate = WD Int Int Int deriving (Eq, Ord)
data JapaneseDate = JD Era Int Int Int
type Era = String

instance Show JapaneseDate where
    show (JD e y m d) = unwords (e: map show [y,m,d])

toJapanese :: WesternDate -> Maybe JapaneseDate
toJapanese date@(WD y m d)
    | date <= WD 1868 9 7     = Nothing
    | date <= WD 1912 7 29   = Just (JD "meiji" (y-1867) m d)
    | date <= WD 1926 12 24  = Just (JD "taisho" (y-1911) m d)
    | date <= WD 1989 1 7    = Just (JD "showa" (y-1925) m d)
    | otherwise              = Just (JD "heisei" (y-1988) m d)

readWD :: String -> WesternDate
readWD s = let (y:m:d:_) = map read . words $ s
               in WD y m d

answer :: Maybe JapaneseDate -> IO ()
answer Nothing = putStrLn "pre-meiji"
answer (Just d) = print d

main = getContents
    >>= mapM_ (answer .  toJapanese . readWD) . lines

Measured memory_bytes: 3832
#include<stdio.h>

int main(void){

int n,a,b;
int i;
int max,min;

scanf("%d %d %d",&n,&a,&b);

max = a;
if(a>b) max = b;

min = a+b-n;
if(min<0) min =0;

printf("%d %d\n",max,min);


return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
  	ci(s);
  ll a=s.sz;
  ll l;
  ll r;
  FOR(i,0,a){
    if(s[i]=='A') {
      l=i;
      break;
    }
  }
  rFOR(i,a-1,-1){
    if(s[i]=='Z'){
      r=i;
      break;
    }
  }
  co(r-l+1)
}

Measured memory_bytes: 640
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    ll N;
    cin >> N;

    if (N == 0)
    {
        cout << '0' << endl;
        return 0;
    }

    string s;
    while (N != 0)
    {
        if (N % (-2) != 0)
        {
            s += '1';
            N -= 1;
        }
        else
        {
            s += '0';
        }

        N /= (-2);
    }
    
    reverse(all(s));

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3544
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {

		out.println((nextInt() * 3 + nextInt()) / 2);
	}

	private void solveB() {
		int n = nextInt();

		out.println("");
	}

	private void solveC() {
		int n = nextInt();

		out.println("");
	}

	private void solveD() {
		int n = nextInt();

		out.println("");
	}

	private void solveE() {
		int n = nextInt();

		out.println("");
	}

	private void solveF() {
		int n = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

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

    string s;
    cin >> s;
    int a = 0, b = s.size();
    while (s[a] != 'A') a++;
    while (s[b] != 'Z') b--;
    cout << b - a + 1 << endl;
}


Measured memory_bytes: 720
h = [i for i in range(1,14)]
c = [i for i in range(1,14)]
d = [i for i in range(1,14)]
s = [i for i in range(1,14)]

x = int(input())

for i in range(x):
    ss, nn = map(str, input().split())

    try:
        if ss == "H":
            h.remove(int(nn))
        elif ss == "C":
            c.remove(int(nn))
        elif ss == "D":
            d.remove(int(nn))
        elif ss == "S":
            s.remove(int(nn))
    except ValueError:
        break

for i in range(len(s)):
    print ("S "+ str(s[i]))
    
for i in range(len(h)):
    print ("H "+ str(h[i]))

for i in range(len(c)):
    print ("C "+ str(c[i]))

for i in range(len(d)):
    print ("D "+ str(d[i]))


Measured memory_bytes: 5608
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 100010;
const int MAXP = 10000000;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

struct node
{
	int t, d;
	bool operator < (const node &A) const
	{
		return d < A.d;
	}
};

int n, k;
node p[MAXN];

int used[MAXN];

int main()
{
	
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++ i)
		scanf("%d%d", &p[i].t, &p[i].d);
	sort(p+1, p+n+1);
	ll ans = 0;
	ll types = 0;
	ll sum = 0;
	ll cnt = 0;
	priority_queue<pii, vector<pii>, greater<pii> > Q;
	for (int i = n; i >= 1; -- i)
	{
		if (cnt < k)
		{
			if (!used[p[i].t])
			{
				types ++;
				used[p[i].t] = 1;
			}
			else
				Q.emplace(p[i].d, p[i].t);
			sum += p[i].d;
			cnt ++;
			ans = max(ans, sum+types*types);
		}
		else
		{
			if (used[p[i].t]) continue;
			if (Q.empty()) break;
			sum -= Q.top().X;
			Q.pop();
			types ++;
			used[p[i].t] = 1;
			sum += p[i].d;
			ans = max(ans, sum+types*types);
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  ll n,k;cin>>n>>k;
  VL s(n+1);
  s[0]=0;
  for(int i=1;i<n+1;i++){
    ll tmp;cin>>tmp;
    s[i]=s[i-1]+tmp;
  }
  int start=0;int end=k;
  double max=0;
  while(end<=n){
    ll tmp=s[end]-s[start];
    if(tmp>max){max=tmp;}
    start++;end++;
  }
  double ans=(max+k)/2;
  cout<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 4492
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define MP make_pair
using namespace std;
typedef long long ll;
const int N=20;
const int M=500;
const int P=1<<16;
int n,m,x,y,z,dp[N][P],G[N][N],tot,sum=0,g[P],ans;
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
inline void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
	return;
}
int main()
{
//	freopen("data.in","r",stdin);
	mem(G,-1);
	n=read(),m=read();
	FOR(i,1,m)
	{
		x=read(),y=read(),z=read();
		sum+=z;
		G[x][y]=G[y][x]=z;
	}
	tot=(1<<n)-1;
	FOR(i,1,tot)
		FOR(j,0,n-1) if ((i>>j)&1)
			FOR(k,j,n-1) if ((i>>k)&1)
				if (G[j+1][k+1]!=-1) g[i]+=G[j+1][k+1];
	mem(dp,-1);
	dp[1][1]=0;
	FOR(S,1,tot)
	{
		FOR(i,0,n-1) if (((S>>i)&1)&&dp[i+1][S]!=-1)
		{
			int ss=(tot xor S)|(1<<i);
			for (register int s=ss;s;s=(s-1)&ss)
			{
				if (!((s>>i)&1)) continue;
				dp[i+1][S|s]=max(dp[i+1][S|s],dp[i+1][S]+g[s]);
			}
			FOR(j,0,n-1)
			{
				if ((S>>j)&1) continue;
				if (G[i+1][j+1]==-1) continue;
				dp[j+1][S|(1<<j)]=max(dp[j+1][S|(1<<j)],dp[i+1][S]+G[i+1][j+1]);
			}
		}
	}
	ans=sum-dp[n][tot];
	write(ans);
	return 0;
}

Measured memory_bytes: 5632