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

using namespace std;

int64_t ryuka(int N) {
  vector<int64_t> ryuka_array(N+1);
  ryuka_array.at(0) = 2;
  ryuka_array.at(1) = 1;
  for(int i=2; i<=N; i++) {
    ryuka_array.at(i) = ryuka_array.at(i - 1) + ryuka_array.at(i - 2);
  }
  return ryuka_array.at(N);
}

int main(void) {
  int N;
  cin >> N;
  
  cout << ryuka(N) << endl;
}

Measured memory_bytes: 3628
// Problem : C - Candies
// Contest : AtCoder Regular Contest 090
// URL : https://atcoder.jp/contests/arc090/tasks/arc090_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define size(x) (int)x.size()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int n = 2, m, a[3][N], dp[3][N];

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			dp[i][j] = max(i > 1 ? dp[i - 1][j] : 0, j > 1 ? dp[i][j - 1] : 0);
			dp[i][j] += a[i][j];
		}
	}
	cout << dp[n][m];
}


Measured memory_bytes: 8448
#include<iostream>
#include<cmath>
#include<limits.h>
#define ll long long
using namespace std;
ll int function(ll int arr[],ll int initial,ll int final,ll int memo[])
{
	if(memo[initial]!=-1)
	  return memo[initial];
	if(initial==final)
	  return 0;
	if(initial==final-1)
	{
		return abs(arr[initial]-arr[initial+1]);
	}
	else
	{
		ll int x=abs(arr[initial+2]-arr[initial])+function(arr,initial+2,final,memo);
		ll int y=abs(arr[initial+1]-arr[initial])+function(arr,initial+1,final,memo);
		memo[initial]=x<y?x:y;
		return memo[initial];
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll int n;
	cin>>n;
	ll int arr[n];
	ll int j;
	ll int answer;
	for(j=0;j<n;j++)
	  cin>>arr[j];
	ll int memo[n];
	for(j=0;j<n;j++)
	  memo[j]=-1;
	answer=function(arr,0,n-1,memo);
	cout<<answer<<endl;
}


Measured memory_bytes: 6528
x, k, d = map(int, input().split())
neg = (x < 0)
x = abs(x)
if x // d > k: ans = (x - k * d)
else:
    if (x // d) % 2 == k % 2: ans = x - x // d * d
    else: ans = x - x // d * d - d
print(abs(ans))


Measured memory_bytes: 9124
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int x; cin >> x;
    for(int k = 1; k <= 10000; ++k) {
        if(100 * k <= x && x <= 105 * k) {
            cout << 1 << endl;
            return;
        }
    }
    cout << 0 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===

using Graph = std::vector<std::vector<int>>;

bool topological_sort(std::vector<int>& res, const Graph& g)
{
	const int n = static_cast<int>(g.size());
	res.resize(n);
	int idx = 0;

	int e = 0;
	std::vector<int> indeg(n);
	for (const auto& ch : g) {
		for (const auto& to : ch) {
			++indeg[to];
			++e;
		}
	}

	std::stack<int> st;
	for (int i = 0; i < n; ++i) {
		if (indeg[i] == 0) st.push(i);
	}

	while (!st.empty()) {
		int u = st.top();
		st.pop();
		res[idx++] = u;
		for (const auto& to : g[u]) {
			--indeg[to];
			--e;
			if (indeg[to] == 0) st.push(to);
		}
	}

	if (e > 0) {
		res.clear();
		return false;
	}

	return true;
}


int dp[100100];


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

	int N, M; cin >> N >> M;
	
	Graph g(N);
	
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
	}

	memset(dp, 0, sizeof(dp));

	Vi tp;
	topological_sort(tp, g);

	Vi tp_inv(N);
	for (int i = 0; i < N; ++i) {
		tp_inv[tp[i]] = i;
	}

	for (int i = 1; i <= N; ++i) {
		for (const auto& to : g[tp[i - 1]]) {
			int idx = tp_inv[to];
			dp[idx + 1] = max(dp[idx + 1], dp[i] + 1);
		}
	}
	
	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		ans = max(ans, dp[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

string s;
vector<int> z;

void init(){
	z.resize(s.size());
	z[0] = s.size();
	int i = 1, j = 0;
	while (i < s.size()) {
		while (i + j < s.size() && s[i+j] == s[j]) j++;
		z[i] = j;
		if (j == 0) { i++; continue; }
		int k = 1;
		while (i + k < s.size() && k + z[k] < j) z[i+k] = z[k], k++;
		i += k; j -= k;
	}
}

int main(){
	int n;
	string t;
	cin >> n >> t;
	int ans = 0;
	for(int i = n-1; i >= 0; i--){
		s = t[i] + s;
		init();
		for(int j = 0; j < s.size(); j++){
			ans = max(ans,min(j,z[j]));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
<?php
$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$t = trim(fgets($handle));
$x = trim(fgets($handle));
$a=explode(' ',$x);
$count=0;
$j=0;
if($t==1)echo "1";
else{
    $count=1;
    $te=$a[0];
    for($i=1;$i<$t;$i++)
    {
        if($a[$i]<=$te){
            $te=$a[$i];
            $count++;
        }
    }
    echo $count;

}
?>

Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;

vector<ll> ans(0);

void dfs(ll a){
  if(a > 3234566667) return;
  ans.push_back(a);
  if(a%10 == 0){
    dfs(10*a + 1);
    dfs(10*a);
    return;
  }
  if(a%10 == 9){
    dfs(10*a + 9);
    dfs(10*a + 8);
    return;
  }
  int m = a%10;
  dfs(10*a + m - 1);
  dfs(10*a + m);
  dfs(10*a + m + 1);
}

int main(){
  int n;
  cin >> n;
  rep1(i,9) dfs(i);
  sort(ans);
  cout << ans[n-1] << endl;
}

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

int main() {
  int N;
  cin >> N;
  int s = N%10;
  if (s==2|s==4|s==5|s==7|s==9) {
    cout << "hon" << endl;
  } else if(s==0|s==1|s==6|s==8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n, a, b, ba;
string str;
Int bias;
int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> str;
        for(int j = 0;j < str.size() - 1;j++){
            if(str[j] == 'A' && str[j+1] == 'B')bias++;
        }
        if(str[0] == 'B' && str[str.size()-1] == 'A')ba++;
        if(str[0] == 'B' && str[str.size()-1] != 'A')b++;
        if(str[0] != 'B' && str[str.size()-1] == 'A')a++;
    }
    if(a || b){
        bias += ba;
        bias += min(a, b);
    }
    else{
        bias += max(0LL, ba-1);
    }
    cout << bias << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int x;
            int cou = 1;
            

            while (true)
            {
                string num = Console.ReadLine();
                x = int.Parse(num);
                if (x == 0)
                {
                    break;

                }
                Console.WriteLine("Case " + cou + ": " + x);
                cou++;
            }
        }
    }


Measured memory_bytes: 9308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}



//ll a[]={6,8,4,2,6};

//ll tb=100;
void solve(){
	ll x,n;
	cin>>x>>n;
	vector<ll> v(n);
	unordered_map<ll,ll> m;

	for(ll i=0;i<n;i++){
		cin>>v[i];
		m[v[i]]=1;
	}
	bool check=false;
	ll ans=0;
	ll diff=0;
	while(!check){
		if(m[x-diff]==0){
			ans=x-diff;
			break;
		}
		else if(m[x+diff]==0){
			ans=x+diff;
			break;
		}
		else{
			diff++;

		}
	}
	cout<<ans<<endl;
	



		
}



int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
   // cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3640
/**
 * 2019/02/21
 * 056C
 */
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int sum = 0;
        int i = 0;
        while (true) {
            i++;
            sum += i;
            if (sum >= x) {
                break;
            }
        }
        System.out.println(i);
    }
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	string a = "dream";
	string b = "dreamer";
	string c = "erase";
	string d = "eraser";
	bool h = true;
	while (true) {
		bool hh = true;
		if (s.size() >= 8) {
			string e = s.substr(0, 8);
			if (e == "dreamera") {
				s = s.substr(5);
				hh = false;
			}
		}
		if (hh && s.size() >= 7) {
			string e = s.substr(0, 7);
			if (e == "erasera") {
				s = s.substr(5);
				hh = false;
			}
		}
		if (hh && s.size() >= 7) {
			string e = s.substr(0, 7);
			if (e == "dreamer") {
				s = s.substr(7);
				hh = false;
			}
		}
		if (hh && s.size() >= 6) {
			string e = s.substr(0, 6);
			if (e == "eraser") {
				s = s.substr(6);
				hh = false;
			}
		}
		if (hh && s.size() >= 5) {
			string e = s.substr(0, 5);
			if (e == "dream") {
				s = s.substr(5);
			} else if (e == "erase") {
				s = s.substr(5);
			} else {
				h = false;
				break;
			}
		}
		if (s.size() == 0) {
			break;
		} else if (s.size() < 5) {
			h = false;
			break;
		}
	}
	if (h) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
// In the name of ALlah //
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn = 1e5 * 5 + 10 , inf = 1e9;
string s;
void solve(){
    for (int i = 0; i < s.size(); i ++){
        if (!(i & 1))
            cout << s[i];
    }
}
void in (){
    cin >> s; solve();
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    in();
}


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

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

    int a[n + 1];

    for (int i = 1; i <= n; i++) a[i] = 0;

    int ai, bi;
    for (int i = 0; i < m; i++) {
        cin >> ai >> bi;

        a[ai]++;
        a[bi]++;
    }

    for (int i = 1; i <= n; i++) {
        cout << a[i] << endl;
    };

    return 0;
}


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

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define endl "\n"

const int N = 100005;
bool visited[N];
vector<int> adj[N];
int memo[N];

int traverse(int a) {
	if (visited[a]) return memo[a];
	int ans = 0;
	for (int j : adj[a]) {
		ans = max(ans, 1 + traverse(j));
	}
	visited[a] = true;
	return memo[a] = ans;

}

int main() {

	int e, v, temp1, temp2;
	cin >> v >> e;

	fo(i, e) {
		cin >> temp1 >> temp2;
		adj[temp1].emplace_back(temp2);
	}
	temp2 = 0;

	fo(i, v)
	temp2 = max(temp2, traverse(i + 1));

	cout << temp2;

	return 0;
}

Measured memory_bytes: 11528
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int priority;
    double value;
}data;

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

//降順
int desc(const void* a, const void* b){
    return *(int*)b-*(int*)a;
}

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

    //A[0]~A[N-1]に格納する
    long* A;
    NEW(A,N+2);
    A[0]=0;
    for(int i=1;i<=N;i++){
        scanf("%ld",&A[i]);
    }
    A[N+1]=0;

    long sum=0;
    for(int i=1;i<=N+1;i++){
        sum+=labs(A[i]-A[i-1]);
    }

    for(int i=1;i<=N;i++){
        long ans=sum-labs(A[i]-A[i-1])-labs(A[i+1]-A[i])+labs(A[i+1]-A[i-1]);
        printf("%ld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1920
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    AB = ii2nnn(N)
    AB.sort(key=lambda v: v[1])
    t = 0
    for a, b in AB:
        t += a
        if t > b:
            print('No')
            return
    print('Yes')

main()


Measured memory_bytes: 105564
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    k = int(lines[0])

    return (k, )


def solve(k):
    
    nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]    

    return nums[k-1]
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

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

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

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

	set<ll> s;

	rep(i, n) {
		ll a;
		cin >> a;
		s.insert(a);
	}

	if (n == s.size()) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 9600
L = int(input())
N = int(input())
s = 0
for i in range(N):
    x, w = map(int, input().split())
    s += x * w
if(s == 0):
    print(0)
elif(s < 0):
    print(1)
    print(1, -s)
else:
    print(1)
    print(-1, s)

Measured memory_bytes: 7672
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string.h>
using namespace std;
struct Node {
  int key;
  Node *prev, *next;
};

Node *nil;
void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

Node* listSearch(int key) {
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key ) {
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node *t) {
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

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

  init();

  for ( int i = 0; i < n; i++ ) {
    char str[12];
    int key;
    scanf("%s", str);
    if ( strcmp(str, "insert") == 0 ) {
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(str, "delete") == 0 ) {
      scanf("%d", &key);
      deleteKey(key);
    } else if ( strcmp(str, "deleteFirst") == 0 ) {
      deleteFirst();
    } else if ( strcmp(str, "deleteLast") == 0 ) {
      deleteLast();
    }
  }

  Node *cur = nil->next;
  printf("%d", cur->key);
  cur = cur->next;
  while ( cur != nil ) {
    printf(" %d", cur->key);
    cur = cur->next;
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 33988
N,k = (int(x) for x in input().split())
S = list(input())
if S[k-1] == "A":
  S[k-1] = "a"
elif S[k-1] == "B":
  S[k-1] = "b"
else:
  S[k-1] = "c"
print("".join(S))

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

using namespace std;
typedef long long Int;

#define KIND 26
Int D;
Int c[KIND];
Int s[400][KIND];
Int last[KIND];
Int calc_score(vector<Int> t)
{
    Int score = 0;
    fill(last, last + 26, -1);
    for (int d = 0; d < D; d++) {
        score += s[d][t[d]];
        last[t[d]] = d;
        for (int i = 0; i < KIND; i++) {
            score -= c[i] * (d - last[i]);
        }
        cout << score << endl;
    }
    return score;
}

int main()
{
    cin >> D;
    for (Int i = 0; i < KIND; i++) {
        cin >> c[i];
    }
    for (Int d = 0; d < D; d++) {
        for (Int i = 0; i < KIND; i++) {
            cin >> s[d][i];
        }
    }

    vector<Int> t(D);
    for (auto &elem : t) {
        cin >> elem;
        elem--;
    }
    calc_score(t);
    // cout << score(t) << endl;
    return 0;
}

Measured memory_bytes: 3272
S=input()
T=input()

N=len(S)
TN=len(T)
ans="z"*51
if N<TN:
    print("UNRESTORABLE")
    exit()
for i in range(N-TN+1):
    #始点
    ok=True
    for j in range(TN):
        if S[i+j]==T[j] or S[i+j]=="?":
            continue
        else:
            ok=False
            break
    if ok:
        now=S[:i].replace("?", "a")+T+S[i+TN:].replace("?", "a")
        ans=min(now, ans)

if ans=="z"*51:
    ans="UNRESTORABLE"
print(ans)

Measured memory_bytes: 3064
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define REP1(i,n) for(int i=1;i<=(n);++i)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double


int H, W, K;
int p[256][8];
int a[101][8];

int main() {
  cin >> H >> W >> K;
  if (W == 1) {
    printf("1\n");
    return 0;
  }
  int c = 0;
  REP(i, 1 << (W-1)) {
    if (((i & 3) == 3) ||     // 00000011
        ((i & 6) == 6) ||     // 00000110
        ((i & 12) == 12) ||   // 00001100
        ((i & 24) == 24) ||   // 00011000
        ((i & 48) == 48) ||   // 00110000
        ((i & 96) == 96) ||   // 01100000
        ((i & 192) == 192)) { // 11000000
      continue;
    }
    REP(j, W - 1) {
      p[c][j] = i & 1 << j ? 1 : 0;
      //cout << p[c][j];
    }
    //cout << endl;
    ++c;
  }
  REP(h, H + 1) {
    REP(i, W) {
      a[h][i] = 0;
    }
  }
  a[0][0] = 1;
  FOR(h, 1, H + 1) {
    //cout << "h=" << h << endl;
    REP(i, c) {
      //cout << "i=" << i << endl;
      // REP(k, c) {
      //   REP(j, W - 1) {cout << "(" << k << "," << j << ")=" << p[k][j];} cout << endl;
      // }
      if (W == 1) {
        // pass
      } else if (W == 2) {
        if (p[i][0] == 0) {
          a[h][0] += a[h-1][0];
          a[h][1] += a[h-1][1];
        } else {
          a[h][0] += a[h-1][1];
          a[h][1] += a[h-1][0];
        }
      } else if (W > 2) {
        REP(x, W) {
          if (x == 0) {
            if (p[i][x] == 1) {
              a[h][x] += a[h-1][x+1];
            } else {
              a[h][x] += a[h-1][x];
            }
          } else if (x == (W-1)) {
            if (p[i][x-1] == 1) {
              a[h][x] += a[h-1][x-1];
            } else {
              a[h][x] += a[h-1][x];
            }
          } else {
            if (p[i][x-1] == 1) {
              a[h][x] += a[h-1][x-1];
            } else if (p[i][x] == 1) {
              a[h][x] += a[h-1][x+1];
            } else {
              a[h][x] += a[h-1][x];
            }
          }
        }
      }
      // REP(x, W) {cout << a[h][x] << ",";} cout << endl;
      REP(x, W) {
        a[h][x] = a[h][x] % 1000000007;
        //                  1000000007 
      }
    }
    REP(x, W) {
      a[h][x] = a[h][x] % 1000000007;
      //                  1000000007 
    }
  }
  cout << a[H][K-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int D, N, x[209], a[209], b[209], c[209], dp[209][209];
int main() {
	cin >> D >> N;
	for (int i = 0; i < D; i++) cin >> x[i];
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];
	for (int i = 1; i < D; i++) {
		for (int j = 0; j < N; j++) {
			if (!(a[j] <= x[i] && x[i] <= b[j])) continue;
			for (int k = 0; k < N; k++) {
				if (!(a[k] <= x[i - 1] && x[i - 1] <= b[k])) continue;
				dp[i][j] = max(dp[i][j], dp[i - 1][k] + abs(c[j] - c[k]));
			}
		}
	}
	cout << *max_element(dp[D - 1], dp[D - 1] + N) << endl;
	return 0;
}

Measured memory_bytes: 3292
#include<iostream>
#include<vector>
using namespace std;
 
vector<int> p;
int use[10000];
int ans,n,ansp[10000];
void dfs(int x){
  for(int i=0;i<(int)p.size();i++){
       if(p[x]!=p[i]) ans=p[x]-p[i];
    else continue;
    if(ans<0) ans+=n;
    if(ans>(n-1)/2) ans=n-ans;
    ansp[ans]++;
  }
  if(x+1<(int)p.size())dfs(x+1);
  }
 
int main(){
  while(1){
  cin>>n;
  if(n==0) break;
  int t;
  for(int i=0;i<10000;i++) use[i]=0,ansp[i]=0;
    for(int i=1;i<n;i++)t=(i*i)%n,use[t]=1;
    for(int i=0;i<n;i++) if(use[i]==1) p.push_back(i);
    dfs(0);
    for(int i=1;i<=(n-1)/2;i++) cout<<ansp[i]<<endl;
    p.clear();
  }
  return 0;
}

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

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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<pair<int, int>> A;
  int i = 0;
  while (i < N) {
    int j = i;
    while (i < N && S[i] == S[j]) i++;
    A.push_back({S[j] - '0', i - j});
  }
  int m = A.size();
  vector<int> T(m + 1);
  REP(i, m) T[i + 1] = T[i] + A[i].second;
  int ans = 0;
  REP(i, m) {
    if (A[i].first == 0) {
      int j = min(m, i + 2 * K);
      ans = max(ans, T[j] - T[i]);
    } else {
      int j = min(m, i + 2 * K + 1);
      ans = max(ans, T[j] - T[i]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4668
a, b, x = map(int, input().split())
if a > b * 2:
    m = (x + 499) // 500 * b
elif a < b or ((x - 1) % 1000) >= 500:
    m = (x + 999) // 1000 * a
else:
    m = x // 1000 * a + b
print(m)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define pii pair<ll,ll>
#define piii pair<pii, int>
#define pb push_back
#define fs first
#define sc second
#define ppb pop_back
//#define LOCAL
//#define endl "\n"
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl

#define fifo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(int (i)=(a);(i)<=(b);++(i))
#define fd(i,a,b) for(int i=(a);i>=(b);--i)
const ll mod = 1e9+7;

// x>>1 is x/2  and x<<1 is x*2 



void solve()
{
	double r;
	cin>>r;
	cout<<fixed<<setprecision(5)<<6.28318530717*r<<endl;

}

int main()
{
	fifo
	int total=1;
	//cin>>total;
	for(int testcase=1;testcase<=total;testcase++)
	{
		solve();
	}



}


Measured memory_bytes: 3808
#include <iostream>

using namespace std;

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

    int oddcnt = 0;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        oddcnt += A % 2;
    }

    cout << (oddcnt % 2 == 0 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


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


def read_float():
    return float(input())


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


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B):
    S = sum(B)

    for i in range(0, N):
        ab = min(A[i], B[i])
        A[i] -= ab
        B[i] -= ab

        ab = min(A[i+1], B[i])
        A[i+1] -= ab
        B[i] -= ab
    
    return S - sum(B)


def main():
    N = read_int()
    A = read_int_n()
    B = read_int_n()
    print(slv(N, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 94432
def comb(x, y):
    return math.factorial(x) / (math.factorial(x - y) * math.factorial(y))

def solve(N, AS):
    x = max(AS)
    AS = list(AS)
    AS.remove(x)
    y = min(map(lambda z: [abs(z - x / 2), z] , AS), key=lambda x: x[0])[1]
    return (x, y)

if __name__ == '__main__':
    n = int(input())
    AS  = list(map(lambda x: int(x), input().split()))
    tmp = solve(n, AS)
    print(tmp[0], tmp[1])


Measured memory_bytes: 14420
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
#define REP(i,n) for (int i = 1; i<= (n); i++)
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
const long double PI = acos(-1);
using ll = long long;
using ld = long double;
using namespace std;

int main() {
    int a,b;
    cin >> a >>b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3636
n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
sum = 0
for j in range(k):
  sum += lst[j]
max = sum
for i in range(n-k):
  sum = sum-lst[i]+lst[i+k]
  if max < sum:
    max = sum
print((max+k)/2)

Measured memory_bytes: 24548
#include <stdio.h>

int main(void) {
	int N, K;
	int notomamiko;
	int kugyu;
	int inorinn;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	kugyu = N - 1;
	inorinn = 1;
	notomamiko = 1;
	for (;;) {
		int mizuhasu = (inorinn + K - 1) / K;
		if (mizuhasu > kugyu) break;
		kugyu -= mizuhasu;
		inorinn += mizuhasu;
		notomamiko++;
	}
	printf("%d\n", notomamiko);
	return 0;
}



Measured memory_bytes: 2144
<?php
$N = intval(trim(fgets(STDIN)));
$A = explode(' ', trim(fgets(STDIN)));
$c1=$c2=$c3=0;
foreach($A as $a){
    if($a == '1')$c1++;
    if($a == '2')$c2++;
    if($a == '3')$c3++;
}
$dp = array_fill(0, $N+1, array_fill(0,$N+1, array_fill(0,$N+1,0)));
for($k = 0; $k <= $c3; ++$k){
    $dpk = &$dp[$k];
    if($k>0)$dpkm = $dp[$k-1];
    for($j = 0, $J = $c2 + $c3 - $k; $j <= $J; ++$j){
        $dpkj = &$dpk[$j];
        for($i = 0, $I = $c1+$c2+$c3-$k-$j; $i <= $I ; ++$i){
            if($i==0&&$j==0&&$k==0)continue;
            $tmp = $N;
            if($i>0)$tmp+=$i*$dpkj[$i-1];
            if($j>0)$tmp+=$j*$dpk[$j-1][$i+1];
            if($k>0)$tmp+=$k*$dpkm[$j+1][$i];
            $dpkj[$i] = $tmp/($i+$j+$k);
        }
    }
}
echo $dp[$c3][$c2][$c1];


Measured memory_bytes: 930680
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

int N,K;
string S;

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

    cin>>N>>K;
    cin>>S;
    FOR(i,0,N-1)
    {
        if(i==K-1)cout<<(char)tolower(S[i]);
        else cout<<S[i];
    }
    cout<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define ll long long
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll a, b, c=1;
    std::cin >> a >> b;
    while(a*2<=b){
        c++;
        a*=2;
    }
    std::cout << c << endl;
    return 0;
}

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

using namespace std;

int main() {
    int N, K;
    vector<int> T, t;

    cin >> N >> K;

    for (int i = 0; i < N; i++) {
        int T_;
        cin >> T_;
        T.push_back(T_);
        if (i > 0) t.push_back(T[i] - T[i - 1] - 1);
    }

    int ans = *max_element(T.begin(), T.end()) - *min_element(T.begin(), T.end()) + 1;

    sort(t.begin(), t.end(), greater<>());

    for (int i = 0; i < K - 1; i++) {
        ans -= t[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 3992
#include <stdio.h>

const int Mod = 1000000007;

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

	int i, j, m, n;
	long long dp[2][2][32000] = {}, num[32000], sum;
	for (n = 1; n * n <= N; n++) dp[1][0][n] = 1;
	n--;
	if (n * (n + 1) <= N) m = n;
	else m = n - 1;
	for (j = 1; j <= m; j++) {
		num[j] = N / j - N / (j + 1);
		dp[1][1][j] = num[j];
	}
	for (i = 2; i <= K; i++) {
		for (j = 1, sum = 0; j <= m; j++) {
			sum += dp[1-i%2][0][j];
			if (sum > Mod) sum -= Mod;
			dp[i%2][1][j] = sum * num[j];
			if (dp[i%2][1][j] > Mod) dp[i%2][1][j] %= Mod;
		}
		if (m == n) dp[i%2][0][n] = sum + dp[1-i%2][1][n];
		else dp[i%2][0][n] = sum + dp[1-i%2][0][n];
		if (dp[i%2][0][n] > Mod) dp[i%2][0][n] -= Mod;
		for (j = n - 1; j >= 1; j--) {
			dp[i%2][0][j] = dp[i%2][0][j+1] + dp[1-i%2][1][j];
			if (dp[i%2][0][j] > Mod) dp[i%2][0][j] -= Mod;
		}
	}
	
	long long ans = 0;
	for (j = 1; j <= n; j++) ans += dp[K%2][0][j];
	for (j = 1; j <= m; j++) ans += dp[K%2][1][j];
	printf("%lld\n", ans % Mod);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2948
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%d",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	int x[3] = {0, 0, 0};
	rep(i, 0, n){
		int tmp;
		scanf("%d", &tmp);
		x[(tmp>a)+(tmp>b)]++;
	}
	printf("%d\n", std::min({x[0],x[1],x[2]}));
	return 0;
}


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

int main() {
	int A, B;
	string S;
	cin >> A >> B;
	cin >> S;
	for (int i = 0; i < A+B+1; i++)
		if (i != A && S[i] == '-') {
			cout << "No\n";
			return 0;
		}
	if (S[A] == '-')
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};
struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for ( i = 0; i < n1; ++i) {L[i]=A[left+i];   }
  for ( i = 0; i < n2; ++i) {R[i]=A[mid+i];    }
  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;
  for ( k = left; k < right; ++k) {
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}
void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for ( j = p; j < r; ++j) {
    if(A[j].value<=x.value){
      i++;
      t=A[i];A[i]=A[j];A[j]=t;
    }
  }
  t=A[i+1];A[i+1]=A[r];A[r]=t;
  return i+1;
}
void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;
  scanf("%d",&n);
  for ( i = 0; i < n; ++i) {
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  
  for (i = 0; i < n; ++i) {
    if(A[i].suit!=B[i].suit)stable=0;
  }
  if (stable==1) {printf("Stable\n");
  } else {printf("Not stable\n"); }
  for (i = 0; i < n; ++i) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}



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

  int K = 0;
  int N = 0;
  vector<int> A;
  int sum =0;
  int max = 0;

  cin >> K;
  cin >> N;
  for(int i=0;i<N;i++){
    A.push_back(0);
    cin >> A[i];
  }

for(int i=0;i<N-1;i++){
  sum += A[i+1] - A[i];
    if(max < A[i+1] - A[i]){
      max = A[i+1] - A[i];
  }
}

  sum += K - A[N-1] + A[0];
  if(max < K - A[N-1] + A[0]){
    max = K - A[N-1] + A[0];
  }

 cout << sum - max;

  return 0;

 }

Measured memory_bytes: 1400
#include<stdio.h>

int main () {
  int n,k,id;
  int ary[64];
  int sorted[64];
  bool used[64] = {};
  scanf("%d%d", &n, &k);
  for(int i = 0; i < n; ++i)
    scanf("%d", &ary[i]);
  int maxv = -1e9, premaxv = 1e9;
  for(int i = 0; i < k; ++i) {
    for(int j = 0; j < n; ++j) {
      if(ary[j] >= maxv && ary[j] <= premaxv && !used[j]){
	maxv = ary[j];
	id=j;
      }  
    }
    sorted[i] = premaxv = maxv;
    maxv = -1e9;
    used[id] = true;
  }
  int sum = 0;
  for(int i = 0; i < k; ++i)
    sum += sorted[i];
  printf("%d\n", sum);
}


Measured memory_bytes: 128
#include <stdio.h> 
#define swap(X,Y){int Z;Z = Y;Y = X;X = Z;}

int main(void)
{
	int a, b;

while(scanf("%d %d",&a, &b) && !(a == 0 && b == 0))
{
if(a > b) swap(a,b);
	
	printf("%d %d\n",a, b);
}

return 0;	
}


Measured memory_bytes: 2564
#include<bits/stdc++.h>
using namespace std;
int main(){
    int W, H, N;
    cin >> W >> H >> N;
    vector<vector<int>> A(W, vector<int>(H));
    int x, y, a; 
    for(int i = 0; i < N; i++){
        cin >> x >> y >> a;
        if(a == 1){
            for(int j = 0; j < x; j++){
                for(int k = 0; k < H; k++){
                    A.at(j).at(k)++;
                }
            }
        }
        if(a == 2){
            for(int j = x; j < W; j++){
                for(int k = 0; k < H; k++){
                    A.at(j).at(k)++;
                }
            }
        }
        if(a == 3){
            for(int j = 0; j < W; j++){
                for(int k = 0; k < y; k++){
                    A.at(j).at(k)++;
                }
            }
        }
        if(a == 4){
            for(int j = 0; j < W; j++){
                for(int k = y; k < H; k++){
                    A.at(j).at(k)++;
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < W; i++){
        for(int j = 0; j < H; j++){
            if(A.at(i).at(j) == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
      int tmp,dp[31];
      cin >> tmp;
      do{
            fill(dp,dp+31,0);
            dp[0] = 1;
            for (int i = 0; i<tmp;i++){
                  for(int j = 1;j < 4;j++)
                        dp[i+j] += dp[i];
            }
            cout << dp[tmp]/3650 + 1<<endl;
            cin >> tmp;
      }while(tmp);
}

Measured memory_bytes: 1160
N,M=map(int,input().split())
pos=list(map(int,input().split()))

if N>=M:
	print(0)
else:

	pos=sorted(pos)
	dis=[]
	for i in range(1,M):
		dis.append(pos[i]-pos[i-1])

	dis=sorted(dis)
	ans=0
	for i in range(M-N):
		ans+=dis[i]
	print(ans)


Measured memory_bytes: 13960
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

int dp[100010][2];

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

    string s;
    cin >> s;
    int n = s.size();
    dp[0][0] = 2;
    dp[0][1] = 1;
    Rep(i, 1, n)
    {
        if (s[i] == '0')
        {
            dp[i][0] = dp[i - 1][0];
            dp[i][1] = (dp[i - 1][1] * 3) % mod;
            //cout << dp[i][0] << " " << dp[i][1] << endl;
        }
        else
        {
            dp[i][0] = (dp[i - 1][0] * 2) % mod;
            dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod;
            //cout << dp[i][0] << " " << dp[i][1] << endl;
        }
    }
    int ans = (dp[n - 1][0] + dp[n - 1][1]) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 2000
import math

while True:
  D, E = map(int, input().split())
  if D + E == 0:
    break
  i = 0
  ans = 101
  while True:
    if i > D:
      break
    j = 0
    while True:
      if i + j > D:
        break
      if i + j == D:
        ans = min(ans, abs(math.sqrt(i**2 + j**2) - E))
      j += 1
    i += 1
  print(ans)

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

using namespace std;

int main()
{
  string S;
  cin >> S;
  int notEasy = 0;
  for (int i = 0; i < S.length(); i++){
    if (i % 2){ // 偶数文字目の時
      if (S[i] == 'R') notEasy++;
    } else {
      if (S[i] == 'L') notEasy++;
    }
  }

  if (notEasy) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
from math import sqrt
from collections import defaultdict

N = int(input())

f = defaultdict(int)
for p in [2] + list(range(3, int(sqrt(N)) + 1, 2)):
    while N % p == 0:
        N //= p
        f[p] += 1
    if N == 1:
        break
if N != 1:
    f[N] += 1

ans = 0
for e in f.values():
    ans += int((sqrt(1 + 8 * e) - 1) / 2)
print(ans)


Measured memory_bytes: 32876
n = int(input())
k = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(n):
    if abs(x[i]) <= abs(x[i] - k):
        ans += x[i] * 2
    else:
        ans += abs(x[i] - k) * 2
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	long long ans = 0;
	int n, k;
	scanf("%d %d", &n, &k);
	for (int b = k + 1; b <= n; b++)
	{
		for (int p = 0;; p++)
		{
			if (b*p + k > n)
				break;
			ans += min(p*b + b - 1, n) - max(p*b + k, 1) + 1;
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  ll sum=0;
  map<int,ll> mp;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
    sum+=a[i];
  }
  int q; cin >> q;
  vector<ll> ans(q);
  rep(i,q){
    int b,c;
    cin >> b >> c;
    sum-=b*mp[b];
    sum+=c*mp[b];
    ans[i]=sum;
    mp[c]+=mp[b];
    mp[b]=0;
  }
  rep(i,q){
    cout << ans[i] << endl;
  }
  
}

Measured memory_bytes: 10164
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n;
int a[maxn],vis[maxn];
int pw(int x,int k){
	int ans=1;
	int mo=1e9+7;
	for(;k;k>>=1){
		if(k&1)ans=1ll*ans*x%mo;
		x=1ll*x*x%mo;
	}return ans%mo;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		vis[a[i]]++;
	}
	
	if(n%2==0){
		for(int i=1;i<=n;i+=2)
			if(vis[i]!=2){
				puts("0");
				return 0;
			}
	
	}else{
		if(vis[0]!=1){
			puts("0");
			return 0;
		}
		for(int i=2;i<=n;i+=2)
			if(vis[i]!=2){
				puts("0");
				return 0;
			}
	}
	
	
	if(n%2==0){
		cout<<pw(2,n/2)<<endl;
	}else{
		cout<<pw(2,n/2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
s = input()
num_digits = len(s)


def dfs(index, formula, sum_number):
    if index + 1 == num_digits:
        if sum_number == 7:
            print(formula + "=7")
            exit()
    else:
        dfs(index + 1, formula + "+" + s[index + 1], sum_number + int(s[index + 1]))
        dfs(index + 1, formula + "-" + s[index + 1], sum_number - int(s[index + 1]))


print(dfs(0, s[0], int(s[0])))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1000000007;

//↓combination(ll a, ll b) でaCr計算。
//------------------------------------------------------------------------------------------
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}
//---------------------------------------------------------------------------------------------
//↑combination(ll a, ll b) でaCr計算。

int main(){
    int X;
    cin >> X;
    int big = X/500; //500円玉の枚数
    X -= big*500;
    int small = X/5; //5円玉の枚数
    cout << 5*small + 1000*big;
}

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

long long a, b;

int main() {
  cin >> a >> b;
  if(a * b <= 0)
    cout << "Zero" << endl;
  else if(a > 0 || (b - a + 1) % 2 == 0)
    cout << "Positive" << endl;
  else
    cout << "Negative" << endl;
  return 0;
}

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

//居住者のに人数を管理するプログラム
int main(){
    int n, b, f, r, v, i, j, k;
    int adm_array[4][3][10] = {};
    cin >> n;

    i = 0;
    while(i < n){
        cin >> b >> f >> r >> v;
        adm_array[b-1][f-1][r-1] = adm_array[b-1][f-1][r-1] + v;
        i++;
    }
    i = 0;
    while(i < 4){
        j = 0;
        while(j < 3){
            k = 0;
            while(k < 10){
                cout << " " << adm_array[i][j][k]; 
                k++;
            }
            cout << endl;
            j++;
        }
        i++;
        if (i < 4) cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] x = new int[m];
		for (int i = 0; i < m; i++) {
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);

		int[] dx = new int[m - 1];
		for (int i = 0; i < m - 1; i++) {
			dx[i] = x[i + 1] - x[i];
		}
		Arrays.sort(dx);

		int sum = 0;
		for (int i = 0; i < m - n; i++) {
			sum += dx[i];
		}

		System.out.println(sum);
		sc.close();
	}
}

Measured memory_bytes: 48516