akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const int N = 300+10;
ll f[N][N][N];
int n,k,m;
void add(ll &a,ll b) {a=(ll)(a+b)%m;}
int main() {
	cin>>n>>k>>m;
	f[0][1][0] = 1;
	for (int i = 0; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			for (int k = i; ~k; k--) {
				if (k) add(f[i][j][k-1],f[i][j][k]);
				add(f[i+1][j][k],f[i][j][k] * (k+1));
			}
			add(f[i][j+1][i], f[i][j][0]);
		}
	}
	cout<<f[n][k][0]<<endl;
}

Measured memory_bytes: 226176
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>

using namespace std;

int main() {
  int H,W;
  int h,w;
  cin >> H >> W >> h >> w;
  cout << H*W-H*w-W*h+h*w << endl;
  return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
L = []
for i in range(h):
    L.append(input())
boo = []
for i in range(h):
    F = [False]*w
    boo.append(F)
numlist = []
cnt = 0
tate = 1
yoko = 1
if h == 1:
    if w == 1:
        numlist = [1]
    else:
        if w%2 != 0:
            for i in range(w//2):
                numlist.append(2)
            numlist.append(1)
        else:
            for i in range(w//2):
                numlist.append(2)
elif w == 1:
    if h%2 != 0:
        for i in range(h//2):
            numlist.append(2)
        numlist.append(1)
    else:
        for i in range(h//2):
            numlist.append(2)
else:
    while cnt != h*w:
        if boo[tate-1][yoko-1] == False:
            if h%2 == 1 and tate-1 == h//2:
                if w%2 == 1 and yoko-1 == w//2:
                    boo[tate-1][yoko-1] = True
                    numlist.append(1)
                    cnt += 1
                    yoko += 1
                else:
                    boo[tate-1][yoko-1] = True
                    boo[tate-1][w-yoko] = True
                    numlist.append(2)
                    cnt += 2
                    yoko += 1
            else:
                if w%2 == 1 and yoko-1 == w//2:
                    boo[tate-1][yoko-1] = True
                    boo[h-tate][yoko-1] = True
                    numlist.append(2)
                    cnt += 2
                    yoko += 1
                else:
                    boo[tate-1][yoko-1] = True
                    boo[h-tate][yoko-1] = True
                    boo[tate-1][w-yoko] = True
                    boo[h-tate][w-yoko] = True
                    numlist.append(4)
                    cnt += 4
                    yoko += 1
        else:
            yoko += 1
        if yoko == w:
            if tate != h:
                yoko = 1
                tate += 1
            else:
                break
list_alp = [0]*26
for i in range(h):
    for j in range(w):
        list_alp[ord(L[i][j])-97] += 1
temp = 0
flag = True
list_alp.sort()
list_alp.reverse()
numlist.sort()
numlist.reverse()
for i in range(len(numlist)):
    if list_alp[0] < numlist[temp]:
        flag = False
        break
    else:
        list_alp[0] -= numlist[temp]
        temp += 1
        list_alp.sort()
        list_alp.reverse()
if flag:
    if sum(list_alp) == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 40048
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def check(dic, N):
    if not N % 2:
        for i in range(1, N, 2):
            try:
                if dic[i] ==2:
                    continue
                else:
                    return False
            except:return False
        return True
    else:
        for i in range(0, N, 2):
            if i == 0:
                try:
                    if dic[i] == 1:continue
                    else:return False
                except:
                    return False
            else:
                try:
                    if dic[i]==2:continue
                    else:return False
                except:return False
        return True


def run():
    mod = 10 ** 9 + 7
    N, *A = map(int, read().split())
    dic = {}
    for a in A:
        if not a in dic.keys():
            dic[a] = 1
        else:
            dic[a] += 1

    #print(dic)
    if check(dic, N):
        ans = 1
        for key in dic.keys():
            ans *= dic[key]
            ans %= mod
        print(ans)
    else:
        print(0)




if __name__ == "__main__":
    run()

Measured memory_bytes: 19240
#include <iostream>
#define MAX 10001
using namespace std;
int main() {
    int n = 0;
    int num[MAX];
    int sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> num[i];
        sum += num[i] -1;
    }
    cout << sum;
    return 0;
}

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

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

  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }

  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int moves = min(x[i], k - x[i]) * 2;
    sum += moves;
  }
  cout << sum << "\n";
}


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

int main() 
{
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for(int i = 0; i < n ; i++)
    cin >> a[i];
  int d = a[0] + k;
  a.push_back(d);
  int max = a[0];
  for(int i = 0; i < n; i++)
  {
    if(max < a[i+1] -a[i])
      max = a[i+1] - a[i];
  }
  cout << k - max << endl;
}


Measured memory_bytes: 1792
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

il ll gcd(ll a,ll b){ return b==0 ? a:gcd(b,a%b) ; }
ll a[100023];

int main(){
	int n=ci();
	ll M=ci();
	int o1=0, e1=0;
	rep(i,1,n) a[i]=ci()/2;
	ll g=a[1];
	rep(i,2,n){
		g=gcd(g,a[i]);
	}
	rep(i,1,n) a[i]/=g;
	ll lcm=a[1];
//	printf("lcm %lld\n",lcm);
	if( lcm&1 ) o1=1;
	else e1=1;
	M/=g;
	rep(i,2,n){
		ll x=a[i];
		if( x&1 ) o1=1;
		else e1=1;
		lcm=lcm*x/gcd(lcm,x);
		if( lcm>M || (o1&&e1) ){
			printf("0\n");
			return 0;
		}
	}
	printf("%lld\n",(M-lcm)/(lcm*2)+1);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long ans = 1000000000000;
    string str;
    cin >> str;
    for (int i = 0; i < str.length() - 2; i++){
        int a = (str[i] - '0') * 100 + (str[i + 1] - '0') * 10 + (str[i + 2] - '0');
        ans = min(ans, (long long)abs(753 - a));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long int count1 = 1;
    long long int mod = (1000*1000*1000) + 7;
    for (int i = 1;i <= n;i++) {
        count1 = (count1 * i) % mod;
    }
    cout << count1 << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FASTIO \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr); \
    cout.tie(nullptr);


// ll max_profit(ll w[], ll v[], ll W, ll n) {
//     if(n ==0 or W== 0)
//         return 0;

//     if(dp[n][W]) return dp[n][W];
    
//     if(w[n-1] <= W) {
//         return dp[n][W] = max(max_profit(w, v, W-w[n-1], n-1)+v[n-1], max_profit(w, v, W, n-1));
//     }
//     else
//         return dp[n][W] = max_profit(w, v, W, n-1);
// }


ll max_profit(ll w[], ll v[], ll W, ll n) {

    ll dp[n+1][W+1];

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= W; j++) {
            if( i == 0 or j == 0) {
                dp[i][j] = 0;
                continue;
            }
            if(w[i-1] <= j)
                dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]], dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
        }
        
    }

    return dp[n][W];
    
}

void solve() {
    ll n, W;
    cin>>n>>W;
    
    ll w[n];
    ll v[n];

    for (int i = 0; i < n; i++) {
        cin>>w[i]>>v[i];
    }

    cout<<max_profit(w, v, W, n);   
}

int main() {
    FASTIO;
    solve();
    return 0;
}

Measured memory_bytes: 82516
import java.io.PrintWriter;
import java.util.*;
class Main {
    public static void main(String[] args) {
    	 Scanner sc=new Scanner(System.in);
    	 PrintWriter out=new PrintWriter(System.out);
    	 while(sc.hasNext()){
             double [] ax = new double[2];
             double [] ay = new double[2];
             double [] bx = new double[2];
             double [] by = new double[2];
             for(int i=0;i<ax.length;i++){
                 ax[i]=sc.nextDouble();
                 ay[i]=sc.nextDouble();
             }
             for(int i=0;i<bx.length;i++){
                 bx[i] =sc.nextDouble();
                 by[i] =sc.nextDouble();
             }
             boolean judge = true;
             if(bx[1]<ax[0]|ax[1]<bx[0])judge=false;
             if(ay[1]<by[0]|by[1]<ay[0])judge=false;
             if(judge) out.println("YES");
             else out.println("NO");
         }
    	 out.flush();
    	 out.close();
    	 sc.close();
    }
}

Measured memory_bytes: 20824
#include <stdio.h>
main(){
  int cur,a[5],i,max,tmp;
  while( scanf("%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4]) !=EOF){
  for(cur=0;cur<5;cur++){
    max=cur;
    for(i=cur;i<5;i++){
      if(a[i]>a[max]){
	max=i;
      }
    }
    tmp=a[cur];
    a[cur]=a[max];
    a[max]=tmp;
  }
    printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
  }
return 0; 
}

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

using namespace std;

const int N = 100001;
int a[N], b[N], c[N];

int main() {
    int n, t;
    cin >> n >> t;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int mx = 0;
    for (int i = n; i >= 1; i--) {
        b[i] = mx;
        mx = max(mx, a[i]);
    }
    for (int i = 1; i <= n; i++) {
        c[i] = b[i] - a[i];
    }
    int maxx = 0;
    for (int i = 1; i <= n; i++) {
        maxx = max(maxx, c[i]);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (c[i] == maxx) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int sumDigits(int num) {
    int total = 0;
    while (num > 0) {
        total += num % 10;
        num /= 10;
    }
    return total;
}

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

    int sum = sumDigits(n);
    if (n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  long X,Y,Z;
  scanf("%ld%ld%ld",&X,&Y,&Z);

  long ans = 0;

  while(Z+(Y+Z)*ans <= X){
    ans++;
  }

  printf("%ld\n",ans-1);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    int answer = a * b;
    if( answer % 2 == 0) {
        cout<<"Even"<<endl;
    }else if(answer % 2 == 1) {
        cout<<"Odd"<<endl;
    }
}

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

int main() {
  string s ,t;
  cin >> s >> t;
  sort (s.begin(), s.end());
  sort (t.begin(), t.end());
  reverse (t.begin(), t.end());
  cout << (s < t ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3604
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N int
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	cnt := 0
	for i := 0; i < N; i++ {
		t := nextInt(sc)
		if t%2 != 0 {
			cnt++
		}
	}
	if cnt%2 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 2176
#include<iostream>
#include<climits>
using namespace std;
int max_arr( int arr[], int size )
{
	int max=INT_MIN;
	for( int i=0; i<size; i++ ){
		max=( arr[i] > max )? arr[i] : max;
	}
	return max;
}
int min_arr( int arr[], int size )
{
	int min=INT_MAX;
	for( int i=0; i<size; i++ ){
		min=( arr[i] < min )? arr[i] : min;
	}
	return min;
}
int sum_arr( int arr[], int size) 
{
	int sum=0;
	for( int i=0; i<size; i++ ){
		sum+= arr[i];
	}
	return sum;
}


int canCarry( int carrylim, int t_num, int w[], int w_num ){

	int w_i=0;
	for( int t_i=0; t_i<t_num; t_i++ ){
			int wsum=0;
		for( ; w_i<w_num; w_i++ ){
			if( wsum + w[w_i] <= carrylim ){
				wsum+= w[w_i];
			}else{
				break;
			}
		}

		if( w_i==w_num ){
			return w_num;
		}
	}
	return w_i;
}
		
int solve(int w[], int w_num, int t_num ){
	int carrylim_left= max_arr(w, w_num)-1, carrylim_middle=sum_arr(w, w_num);
	int carrylim_right=2*carrylim_middle - carrylim_left;


	while( carrylim_right > carrylim_left+1 ){
		carrylim_middle= (carrylim_left + carrylim_right) /2;
		int cancarry= canCarry( carrylim_middle, t_num, w, w_num );

//		cout<<"??????????????§????????? : "<<carrylim_middle<<endl;
//		cout<<"??°?????????????????° : "<<cancarry<<endl;
//		cout<<endl;


		if( cancarry >= w_num ){
			carrylim_right= carrylim_middle;
		}else if( cancarry < w_num ){
			carrylim_left=  carrylim_middle;
		}
	}
	return carrylim_right;
}

		



int main()
{
	int w_num, t_num;
	cin>>w_num>>t_num;
	int *w=new int[w_num];
	for( int i=0; i<w_num; i++ ) cin>>w[i];

	cout<<solve(w, w_num, t_num)<<endl;
}

Measured memory_bytes: 1568
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 212345;

int n, m, k;
ll s[MAXN];
ll sum;

int main (){
	scanf("%d", &n);
    ll res = 0;
    sum = 0;
	for(int a=0;a<n;a++){
        scanf("%lld", s+a);
        res = mod(res + s[a]*sum);
        sum = mod(sum + s[a]);
	}
    printf("%lld\n", res);
}



Measured memory_bytes: 5372
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	ll x,cost;
};
int s[3001]={},m[32]={};
int main() {

	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	s[c]=1;
	s[d]=1;
	for(int i=min(c,d); i<f-100+1; i++){
		if(s[i]==1){
			s[i+c]=1;
			s[i+d]=1;
		}
	}
	int gm=100*a,gs=0;
	double p=0;
	m[a]=1;
	m[b]=1;
	for(int i=1; i<f/100+1; i++){
		if(m[i]==0)continue;
		m[i+a]=1;
		m[i+b]=1;
		for(int j=min(c,d); j<f-100+1; j++){
			if(i*100+j>f||e*i<j)break;
			if(s[j]==1){
				if(p<double((j))/i){
					p=(double(j))/i;
					gm=j+i*100;
					gs=j;
				}
			}
		}
	}
	cout<<gm<<" "<<gs<<endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[] dx = {1,0,-1,0};
		int[] dy = {0,1,0,-1};
		int max = 0;
		String[][] maze = new String[h][w];
		for(int i = 0; i < h; i++) maze[i] = sc.next().split("");
		for (int sx = 0; sx < h; sx++) {
			for (int sy = 0; sy < w; sy++) {
				if(maze[sx][sy].equals("#")) continue;
				int[][] d = new int[h][w];
				for (int i = 0; i < h*w; i++) d[i%h][i/h] = 1000;
				d[sx][sy] = 0;
				Queue<point> que = new ArrayDeque<point>();
				que.add(new point(sx, sy));
				while(0 != que.size()) {
					point p = que.poll();
					for(int i = 0; i < 4; i++) {
						int cx = p.x + dx[i];
						int cy = p.y + dy[i];
						if(cx >= 0 && cx <= h-1 && cy >= 0 && cy <= w-1 && !maze[cx][cy].equals("#")  && d[cx][cy] == 1000) {
							d[cx][cy] = d[p.x][p.y] + 1;
							que.add(new point(cx, cy));
						}
					}
				}
				for (int i = 0; i < h*w; i++) {
					if(d[i%h][i/h] < 1000) max = Math.max(max,d[i%h][i/h]);
				}
			}
		}
		System.out.println(max);
		sc.close();
	}
	public static class point{
		int x; int y;
		point(int x, int y){
			this.x = x; this.y = y;
		}
	}
}

Measured memory_bytes: 28168
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

uint32_t dfs(std::vector<uint32_t>& array, uint32_t N, uint32_t min,
             uint32_t max,
             const std::vector<std::pair<uint32_t, uint32_t>>& pair,
             const std::vector<uint32_t>& diff,
             const std::vector<uint32_t>& score) {
  if (array.size() == N) {
    uint32_t sum = 0;
    for (size_t i = 0; i < pair.size(); i++) {
      if (array[pair[i].second - 1] - array[pair[i].first - 1] == diff[i])
        sum += score[i];
    }
    return sum;
  }

  uint32_t max_score = 0;
  for (size_t i = min; i <= max; i++) {
    array.push_back(i);
    max_score = std::max(max_score, dfs(array, N, i, max, pair, diff, score));
    array.pop_back();
  }

  return max_score;
}

int main() {
  uint32_t N = 0, M = 0, Q = 0;
  std::cin >> N >> M >> Q;
  std::vector<std::pair<uint32_t, uint32_t>> pair(Q);
  std::vector<uint32_t> diff(Q), score(Q);
  for (size_t i = 0; i < Q; i++)
    std::cin >> pair[i].first >> pair[i].second >> diff[i] >> score[i];

  std::vector<uint32_t> temp;
  std::cout << dfs(temp, N, 1, M, pair, diff, score) << std::endl;

  return 0;
}

Measured memory_bytes: 3576
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll R,C,k; cin>>R>>C>>k;
    vector<vector<ll>> m(R,vector<ll>(C,-1));
    rep(i,k){
        ll r,c,v; cin>>r>>c>>v;
        r--; c--;
        m[r][c]=v;
    }
    vector<vector<vector<ll>>> dp(4,vector<vector<ll>>(R+1,vector<ll>(C,-1)));
    dp[0][0][0]=0;
    rep(i,R)rep(j,C)for(int K=3;K>=0;K--){
        if(K>0 && m[i][j]>-1){
            if(dp[K-1][i][j]>-1)
            dp[K][i][j]=max(dp[K][i][j],dp[K-1][i][j]+m[i][j]);
        }
        if(j!=C-1) dp[K][i][j+1]=max(dp[K][i][j+1],dp[K][i][j]);
         dp[0][i+1][j]=max(dp[0][i+1][j],dp[K][i][j]);
    }
    ll ans=0;
    rep(i,4)rep(j,C) ans=max(ans,dp[i][R][j]);
    cout<<ans<<endl;
}


Measured memory_bytes: 425696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N;
  cin>>N;
  
  vector<ll>a(N);
  rep(i,N){
    cin>>a[i];
  }
  
  ll X=-100;
  ll mini=INF;
  rep(i,201){
    X+=i;
    ll sum=0;
    rep(j,N){
      sum+=power((a[j]-X),2);
    }

    X-=i;
    
    mini=min(sum,mini);
  }

  cout<<mini<<endl;
}

  


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  char a, b;
  cin >> a >> b;
  if (a == b) cout << 'H' << endl;
  else cout << 'D' << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    val x = readLine()!!.split(" ").map(String::toInt)
    var ans = 1 shl 29
    for (i in 0 until N-K+1) {
        val l = Math.abs(x[i])
        val r = Math.abs(x[i+K-1])
        val d = Math.abs(x[i+K-1] - x[i])
        ans = Math.min(ans, l + d)
        ans = Math.min(ans, r + d)
    }
    println(ans)
}

Measured memory_bytes: 50012
import java.util.Scanner;

public class Main{

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

	private Scanner scan;

	private void mainrun() {
		scan = new Scanner(System.in);

		while(scan.hasNext()) {
			looprun();
		}

		scan.close();
	}

	private double x1,y1,x2,y2,x3,y3,xp,yp;
	private boolean x12,x23,x31;

	private void looprun() {
		x1 = scan.nextDouble();
		y1 = scan.nextDouble();
		x2 = scan.nextDouble();
		y2 = scan.nextDouble();
		x3 = scan.nextDouble();
		y3 = scan.nextDouble();
		xp = scan.nextDouble();
		yp = scan.nextDouble();

		x12 = (xp - x2) * (y1 - y2) - (x1 - x2) * (yp - y2) < 0;
		x23 = (xp - x3) * (y2 - y3) - (x2 - x3) * (yp - y3) < 0;
		x31 = (xp - x1) * (y3 - y1) - (x3 - x1) * (yp - y1) < 0;

		System.out.println(x12 == x23 && x23 == x31  ? "YES" : "NO" );
	}
}


Measured memory_bytes: 31416
import java.util.Scanner;

public class Main {
    
    static boolean yes;
    
    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        yes = false;
        rec(a, b, c, k);
        
        if(yes){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
    
    static void rec(int a, int b, int c, int k){
        
        if(k < 0 || yes){
            return;
        }
        if(b > a && c > b){
            yes = true;
            return;
        }
        
        rec(a*2, b, c, k-1);
        rec(a, b*2, c, k-1);
        rec(a, b, c*2, k-1);
    }
}

Measured memory_bytes: 35612
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int r, d, x;
	cin >> r >> d >> x;
    REP(i, 10) {
		x = x*r - d;
		cout << x << endl;
	}
}

Measured memory_bytes: 256
"""
Problem B: 月曜土曜素因数
https://onlinejudge.u-aizu.ac.jp/problems/1154
1 <= n <= 300000
"""
def solve(n, mspf):
    ans = []
    for i in mspf:
        if n < i: break
        if n % i == 0:
            ans.append(i)
    return ans

if __name__ == '__main__':
    """
    1. 1~300000までの月曜土曜素数を取得
    2. if n ％(月曜土曜素数) == 0: appendで月曜土曜素因数を取得
    """
    MAX = 300001
    check = [True]*MAX
    mspf = []

    for i in range(7,MAX,7):
        for j in [i-1, i+1]:
            if check[j]:
                mspf.append(j)
            for k in range(2*j, MAX, j):
                check[k] = False

    while(True):
        n = int(input())
        if n == 1:
            exit()
        ans = solve(n, mspf)
        ans_txt = " ".join(list(map(str,ans)))
        print("{0}: {1}".format(n, ans_txt))



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

long long int Euculid(long long int a,long long int b){
    if (a < b){
        long long int temp = b;
        b = a;
        a = temp;
    }
    long long int r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a%b;
    }
    return b;
}
//範囲を指定してできないか？
// int main(){
//     long long int a,b,c,d;
//     cin >> a >> b >> c >> d;
//     long long int range = b-a+1;
//     long long int cd = range / c;
//     long long int dd = range / d;
//     long long int lcm = c * d / Euculid(c,d);
//     long long int cdd = range / lcm;
//     long long int ans = range - cd - dd + cdd;
//     cout << ans << endl;
// }

int main(){
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;
    long long int range[2];
    range[0] = b;
    range[1] = a-1;
    long long int ans[2];
    for (int i = 0;i < 2;i++){
        long long int cd = range[i] / c;
        long long int dd = range[i] / d;
        long long int lcm = c * d / Euculid(c,d);
        long long int cdd = range[i] / lcm;
        ans[i] = range[i] - cd - dd + cdd;
    }

    cout << ans[0] - ans[1] << endl;
}

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

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size()>k) cout << s.erase(k) << "..." << endl;
    else cout << s << endl;
}

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

int main(void) {
  long long N,A,B;
  cin >> N >> A >> B;
  if(A==0){
    cout << 0 << endl;
    return 0;
  }
  long long ans;
  ans = A*(N/(B+A));
  if(N%(A+B)>0) ans += min(A,N%(A+B));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long li;

bool Solve(li a, li b, li c, li d) {
  if (b > d) return false;
  if (a < b) return false;
  if (c >= b) return true;
  li g = __gcd(b, d);
  a -= (a - c - 1) / g * g;
  if (a < b) return false;
  return true;
}

int main(void) {
  int t;
  scanf("%d", &t);
  while (t--) {
    li a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    puts(Solve(a, b, c, d) ? "Yes" : "No");
  }
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

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


void Main()
{
	int N, W;
	cin >> N >> W;
	vi weight(N, 0), value(N, 0);
	rep(i, 0, N)	cin >> weight[i] >> value[i];

	vvi dp(N + 10, vi(W + 10, 0));

	rep(i, 0, N) {
		rep(w, 0, W + 1) {
			if (w - weight[i] >= 0)
				chmax(dp[i + 1][w], dp[i][w - weight[i]] + value[i]);
			chmax(dp[i + 1][w], dp[i][w]);
		}
	}
	cout << dp[N][W] << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 87296
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  string s, t;cin>>s>>t;
  int n=(int)s.size(), m=(int)t.size();
  if(n<m){cout<<"UNRESTORABLE"<<endl;return 0;}
  int start=-1;
  for(int i=n-m;i>=0;i--){
  	string trimmed_s = s.substr(i, m);
    bool match=true;
    for(int j=0;j<m;j++){
      if(trimmed_s[j]!='?'&&trimmed_s[j]!=t[j]){match=false;break;}
    }
    if(match){start=i;break;}
  }
  if(start==-1)cout<<"UNRESTORABLE"<<endl;
  else{
    string ans = s.substr(0, start)+t+s.substr(start+m);
  	for(int i=0;i<n;i++){
      cout<<(ans[i]=='?'?'a':ans[i]);
    }
    cout<<endl;
  }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int,pair<int,int> > iii;
#define PI 3.141592653589793
#define mod 1000000009
# define N 100005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
# define INF (ll)1e18
# define LG 20
typedef pair<int,pair<int,int> > pii;
# define INF_D 10000000000.00

map<ll,ll>m;

int main()
{
	int n;
	cin >> n;
	ll a[n+1];
	ll sum=0;
	m[0]++;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		sum+=a[i];
		m[sum]++;
	}
	ll ans=0;
	for( map<ll,ll>::iterator it=m.begin();it!=m.end();it++)
	{
		ans+=((it->second)-1)*(it->second)/2;
	}
	cout << ans;

}


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

const int INF = 1e9;

int n;
int d[102][102];

void WarshallFloyd(){
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[j][k]);
            }
        }
    }
}

int main()
{
    int m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        fill(d[i], d[i] + n, INF);
    }
    int a[1005], b[1005], c[1005];
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }
    WarshallFloyd();
    int ans = 0;
    for(int i = 0; i < m; i++){
        if(d[a[i]][b[i]] < c[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

struct TTree {
  vector<ll> t;
  ll n;
  
  void init (ll nn)
  {
      n = nn;
        t.assign (n, 0);
  }
  
  ll sum (ll r)
  {
      ll result = 0;
        for (; r >= 0; r = (r & (r+1)) - 1)
              result += t[r];
          return result;
  }
  
  void inc (ll i, ll delta)
  {
      for (; i < n; i = (i | (i+1)))
            t[i] += delta;
  }
  
  ll sum (ll l, ll r)
  {
      return sum (r) - sum (l-1);
  }
  
  void init (vector<ll> a)
  {
      init ((ll) a.size());
        for (unsigned i = 0; i < a.size(); i++)
              inc (i, a[i]);
  }
};

ll NumInversions(vector<ll> a) {
  ll result = 0;
//  for (int l = 0; l < a.size(); ++l) {
//    for (int r = l + 1; r < a.size(); ++r) {
//      if (a[l] <= a[r]) result++;
//    }
//  }
  ll mi = *min_element(a.begin(), a.end());
  for (int i = 0; i < a.size(); ++i) {
    a[i] -= mi;
  }
  ll ma = *max_element(a.begin(), a.end());
  TTree tree;
  tree.init(ma + 1);
  for (ll x : a) {
    result += tree.sum(0, x);
    tree.inc(x, 1);
  }
  return result;
}



int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  ll l = 0;
  ll r = 1000 * 1000 * 1000 + 1;
  while (r - l > 1) {
    ll m = (l + r) / 2;
    vector<ll> A(n + 1);
    for (int i = 0; i < n; ++i) {
      A[i + 1] = a[i] >= m;
      A[i + 1] += A[i];
    }
    for (int i = 0; i <= n; ++i) {
      A[i] = 2 * A[i] - i;
    }
    if (NumInversions(A) * 2 >= n * (n + 1) / 2) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << l << endl;
  return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 2e5 + 5;
const int inf = 1e16 + 2;


void solve(int Case) {
    string s , t;
    cin >> s >> t;
    int cnt = 0;
    for(int i = 0 ; i < s.size() ; i ++) if(s[i] != t[i]) cnt ++;
    cout << cnt << '\n';
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int Case = 1;
    while(testcase --) {
        solve(Case ++);
    }
    return 0;
}
 



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

int main()
{
    int N, D, X;
    std::cin >> N >> D >> X;

    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }

    int ans = 0;
    for (int i = 1; i <= D; i++) {
        for (int j = 0; j < N; j++) {
            if ((i - 1) % A[j] == 0) ans++;
        }
    }

    std::cout << ans + X << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    int x,zyo,amari;
    cin>>x;
    zyo=x/100;
    amari=x%100;
    if(zyo*5>=amari){
        cout<<"1"<<endl;
    }
    else{
        cout<<"0"<<endl;
    }
    return(0);
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
//#include<bits/stdc++.h>
#define int long long
#define all(x) begin(x), end(x)
#define SZ(x) ((int)(x).size())
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ls node + node
#define rs node + node + 1
#define de(x) if(x && x == MODE)
#define MODE 1

using namespace std;

typedef pair<int, int> pii;

const int INF = 1e18;
const int maxn = 4e5 + 7;

int R = 4e5;
struct SegMent_Tree {
	int seg[maxn * 4];
	
	void upd(int node,int l,int r,int x,int val) {
		if (x == l && r == x) {
			seg[node] = max(seg[node], val);
		}
		else {
			int m = (l + r) >> 1;
			if (x <= m) upd(ls, l, m, x, val);
			else upd(rs, m + 1, r, x, val);
			seg[node] = max(seg[ls], seg[rs]);
		}
	}
	
	int qry(int node,int l,int r,int ql,int qr) {
		if (ql <= l && r <= qr) {
			return seg[node];
		}
		else {
			int ret = 0, m = (l + r) >> 1;
			if (ql <= m) ret = max(ret, qry(ls, l, m, ql, qr));
			if (qr > m) ret = max(ret, qry(rs, m + 1, r, ql, qr));
			return ret;
 		}
	}
} Seg; 

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		x++;
		Seg.upd(1, 1, R, x, Seg.qry(1, 1, R, max(1ll, x - k), min(R, x + k)) + 1);	
	}
	cout << Seg.seg[1] << "\n";
	
}


Measured memory_bytes: 9812
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main() {
	int num,a=0,b=0,draw;
	cin >> num;
	int *line = new int[num];
	for (int w = 0; w < num; w++) {
		line[w] = w + 1;
	}
		cin >> draw;
		for (int w = 0; w < draw; w++) {
			scanf("%d,%d", &a, &b);
			swap(line[a-1], line[b-1]);
		}
		for (int w = 0; w < num; w++) {
			cout<<line[w]<<endl;
		}
	return 0;
}


Measured memory_bytes: 3236
N = int(input())
K = int(input())
X = list(map(int, input().split()))
Total_dist = 0

#iterate through number of bals
for i in range(N):
	dist = []
	for Rtype in ['A','B']:
		if Rtype == 'A':
			dist.append(abs(X[i] - 0)*2)
		if Rtype == 'B':
			dist.append(abs(X[i] - K)*2)
	Total_dist += min(dist)

print(Total_dist)

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

int main(void) {
	int x, y, z;
	char buf[64], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	x = atoi(ch);
	ch = strtok(NULL, " ");
	y = atoi(ch);
	ch = strtok(NULL, " ");
	z = atoi(ch);

	printf("%d %d %d\n", z, x, y);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
vector<string> s;
vector<vector<long long> > m;
int H,W;
long long call(int i,int j){
	if((i==H-1)&&(j==W-1)){
		return 1;
	}
	if(m[i][j]!=-1){
		return m[i][j];
	}
	m[i][j]=0;
	if(i<H-1){
		if(s[i+1][j]=='.'){
			m[i][j]=(m[i][j]+((call(i+1,j))%(1000000007)))%(1000000007);
		}
	}
	if(j<W-1){
		if(s[i][j+1]=='.'){
			m[i][j]=(m[i][j]+((call(i,j+1))%(1000000007)))%(1000000007);
		}
	}
	return m[i][j];
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);	
  int h,w;
  cin>>h>>w;
  H=h;
  W=w;
  s.resize(h);	
  for(int i=0;i<h;i++){
  	cin>>s[i];
  }
  m.resize(h,vector<long long>(w));
  for(int i=0;i<h;i++){
  	for(int j=0;j<w;j++){
  		m[i][j]=-1;
	  }
  }
  cout<<call(0,0);
}



Measured memory_bytes: 9344
def enq(a,x)
  b = a[i=-1]
  until b.frozen?
    return a << x  if x >= (a=b)[-1]
    return a.unshift x  if x <= a[0]
    i = a.bsearch_index {|y| x <= (y.frozen? ? y: y[0])}
    b = a[i-=1]  if (b=a[i]).frozen? ? x<b: x<b[0]
  end  if b && b=a
  return a.insert(i+1, x)  unless a[i+9]
  i > 0 ? a[i] = [b,x] : a.unshift(a.shift,x)
end
def deq(a) r=a.shift; a.unshift *a.shift if !a[0].frozen?; r end
def poq(a) r=a.pop; a.push *a.pop if !a[-1].frozen?; r end
N,M,*A = $<.read.split.map{|x| x.to_i}
A.sort!
M.times { break if A[-1]==0; enq A, (poq A)/2 }
p A.flatten.inject(0,:+)

Measured memory_bytes: 15464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;
class Node{
    Node prev;
    Node next;
    int value;
    public Node(Node p,Node n,int v){
        prev=p;
        next=n;
        value=v;
    }
}
class DoublyLinkedList{
    Node dummy;
    public DoublyLinkedList(){
        this.dummy=new Node(null,null,0);
        this.dummy.next=this.dummy;
        this.dummy.prev=this.dummy;
    }
    public void insert(int v){
        Node node=new Node(this.dummy,this.dummy.next,v);
        this.dummy.next.prev=node;
        this.dummy.next=node;
        if(node.next==dummy)
            dummy.prev=node;
    }
    public void delete(int v){
        Node search=dummy.next;
        boolean done=false;
        while(!done && search!=dummy){
            if(search.value==v){
                search.prev.next=search.next;
                search.next.prev=search.prev;
                done=true;
            }
            else
                search=search.next;
        }
    }
    public void deleteFirst(){
        dummy.next.next.prev=dummy;
        dummy.next=dummy.next.next;
    }
    public void deleteLast(){
        dummy.prev.prev.next=dummy;
        dummy.prev=dummy.prev.prev;
    }
    public void printlist(){
        PrintWriter out = new PrintWriter(System.out);
        Node output=dummy.next;
        while(output.next!=dummy){
            out.print(output.value+" ");
            output=output.next;
        }
        out.print(output.value);
        out.println();
        out.flush();
    }
}
public class Main {
    public static void main(String[] args){
        DoublyLinkedList dll=new DoublyLinkedList();
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.next());
        String[] commands={"insert","delete","deleteFirst","deleteLast"};
        String command;
        int value;
        for(int i=0;i<n;i++){
            command=sc.next();
            if(command.equals(commands[0])){
                value=Integer.parseInt(sc.next());
                dll.insert(value);
            }
            else if(command.equals(commands[1])){
                value=Integer.parseInt(sc.next());
                dll.delete(value);
            }
            else if(command.equals(commands[2])){
                dll.deleteFirst();
            }
            else if(command.equals(commands[3])){
                dll.deleteLast();
            }
        }
        dll.printlist();
    }
}




Measured memory_bytes: 324448
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,v,w;
  long long int t;
  cin>>a>>v>>b>>w>>t;
  a=abs(a-b);
  b=(v-w)*t;
  if(a<=b)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}

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

#define N_MAX 200000

using namespace std;

int main(){
    int N;
    vector<long> a;
    long score = 0;
    cin >> N;
    
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp - (i+1));
    }
    sort(a.begin(), a.end());
    if(N%2 == 0){
        for(int i = 0; i < N; i++){
            score += abs(a[i] -a[N/2]);
        }
    }else{
        for(int i = 0; i < N; i++){
            score += abs(a[i] -a[(N - 1)/2]);
        }
    }
    cout << score << '\n';
}

Measured memory_bytes: 2420
#include <iostream> // {{{
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cstdio> // }}}

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

using namespace std;

const int N = 50;

int n, m;
int a[N],b[N];
bool graph[N][N]={false};
bool visited[N];

void dfs(int v) {
    if(visited[v])return;
    visited[v] = true;
    rep(i,n) {
        if(graph[v][i])dfs(i);
    }
}

int main() {
    cin >> n >> m;
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    int ans = 0;
    rep(i,m){
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        rep(j,n) visited[j]=false;
        bool connected = true;
        dfs(0);
        rep(j,n) {
            if(!visited[j]) {
                connected=false;
                break;
            }
        }
        if(!connected)ans++;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;
const int mod = 1000000007;
ll N,M;
vector<vector<ll>> v;
vector<bool> reach;
ll res;
void dfs(ll cur,ll par){
    if(reach[cur])return;
    reach[cur]=true;
    for(ll i=0;i<v[cur].size();i++){
        ll nxt = v[cur][i];
        if(nxt==cur)continue; 
        dfs(nxt,cur);
    }
    return;
}
int main(){
    cin>>N>>M;
    v.resize(N);
    reach.resize(N);
    for(ll i=0;i<M;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }   
    for(ll i=0;i<N;i++){
        if(!reach[i]){
            res++;
            dfs(i,-1);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define SQ 320
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,r,timer,mx,l;
ll a[100500];
int main() {
    //freopen("input.txt","r",stdin);
    string s;
    cin >> s;
    for (int i = 0; i+1 < s.size(); i++)
        if (s.substr(i,2) == "AC") {
            cout << "Yes" << endl;
            return 0;
        }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,k=LI()
  l=LS()

  for i in range(n,100001):
    f=True
    for j in str(i):
      if j not in l:
        pass
      else:
        f=False
    if f:
      return i

print(main())


Measured memory_bytes: 5456
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main(){
  int n;
  std::vector<int> a;
  int x;
  int min, max;
  long sum;

  cin>>n;

  min=1000000;
  max=-1000000;
  sum=0;

  for(int i=0; i<n; i++){
    cin>>x;
    a.push_back(x);
    sum=sum+a[i];
    if(a[i]<min){
      min=a[i];
    }
    if(a[i]>max){
      max=a[i];
    }
  }

  cout<<min<<" "<<max<<" "<<sum<<endl;

  return 0;




}

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

typedef long long ll;
ll MOD = 1e7 + 7 ;

int main()
{
  ll n ;
  string s ;
  cin >> n >> s ;
  if(n % 2 != 0)  cout << "No" << endl ;
  else {
    for(int i = 0, j = n / 2 ; i < n / 2, j < n; i++, j++) {
      if(s[i] != s[j]) {
        cout << "No" << endl ;
        return 0 ;
      }
    }
    cout << "Yes" << endl ;
  }

}


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

int N;

int ans = 0;

vector<int> shift(11);

void dfs(int v = 0, int d = 1, int b = 0){
    if(b == 7) ans++;
    if(d >= 10) return;
    if(v + 3 * shift[d] <= N) dfs(v + 3 * shift[d], d + 1, b | 1);
    if(v + 5 * shift[d] <= N) dfs(v + 5 * shift[d], d + 1, b | 2);
    if(v + 7 * shift[d] <= N) dfs(v + 7 * shift[d], d + 1, b | 4);
}

void solve(){
    shift[1] = 1;
    for(int i = 2; i <= 10; ++i){
        shift[i] = shift[i - 1] * 10;
    }
    dfs();
    cout << ans;
}
int main(){
    cin >> N;
    solve();
    return 0;
}

Measured memory_bytes: 256