akhauriyash/Code-Regression huggingface dataset:
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    n=length(s)
    cnt=0
    for i in 2:n+1
        if i==n+1 || s[i]!=s[i-1]
            cnt+=1
        end
    end
    println(cnt-1)
end
main()

Measured memory_bytes: 174112
import java.util.Scanner;

public class Main {

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

			for (char c : n.toCharArray()) {
				if (c == '1') {
					System.out.print("9");
				} else {
					System.out.print("1");
				}
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 100010

int main(){
    
    ld a,b;cin>>a>>b;
    ld c=a*b;
    cout<<(ll)c;
    
    
    return 0;
}

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

struct UnionFind{
	vector<int> par,gsize;
	int sz;
	
	UnionFind(int N) : par(N) ,gsize(N), sz(N) {
		for(int i=0;i<N;i++) {
			par[i]=i;
			gsize[i]=1;
		}
	}
	
    //root:子xの根を返す
	int root(int x){
		if(par[x]==x) return x;
		else{
			return par[x]=root(par[x]); 
		}
	}
	
    //unite:要素xとyを結ぶ
	void unite(int x,int y){
		int rx=root(x);
		int ry=root(y);
		if(rx==ry) return;
		else {
			if(gsi(rx)>gsi(ry))swap(rx,ry);
			par[ry]=rx; sz--; 
			gsize[rx]+=gsize[ry];
		}
	}
	
    //same:要素xとyの親が同じか判定する
	bool same(int x,int y){
		int rx=root(x);
		int ry=root(y);
		return rx==ry;
	}
	
    //size　全体のグループの数を返す
	int size() { return sz; }

	//gsize 要素xが属するグループの大きさを返す
	int gsi(int x) {return gsize[root(x)]; }
};

long long nCr(long long n, long long r) {
    long long ans = 1;
    for (long long i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (long long i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

signed main(){
	int N,M; cin>>N>>M;
	UnionFind island(N);
	vector<pair<int,int>> bridge(M);
	for(int i=0;i<M;i++){
		int a,b; cin>>a>>b; a--; b--;
		bridge[i].first=a;
		bridge[i].second=b;
	}
	vector<int> ans(M);
	ans[M-1]=nCr(N,2);
	for(int i=M-1;i>0;i--){
		if(island.root(bridge[i].first)==island.root(bridge[i].second)){
			ans[i-1]=ans[i];
			continue;
		}
		ans[i-1]=ans[i]-island.gsi(bridge[i].first)*island.gsi(bridge[i].second);
		island.unite(bridge[i].first,bridge[i].second);
	}
	for(int i=0;i<M;i++)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {
    ll M, K;
    cin >> M >> K;

    if (K >= pow(2, M)){
        cout << -1 << endl;
        return 0;
    }else if (M < 2 && K != 0){
        cout << -1 << endl;
        return 0;
    }else if (M == 1) {
        cout << "0 0 1 1" << endl;
        return 0;
    }
    vector<ll> v;
    v.push_back(K);
    REP(i, 1 << M) if (i != K) v.push_back(i);
    v.push_back(K);
    for(ll i = (1 << M) - 1; i >= 0; i--) if (i != K) v.push_back(i);
    for(auto tmp : v) cout << tmp << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3952
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			if(n == -1)
			{
				break;
			}
			if(n == 0)
			{
				System.out.println("0");
				continue;
			}
			StringBuffer fourDigits = new StringBuffer();
			while(n != 0)
			{
				fourDigits.append((char)(n % 4 + '0'));
				n /= 4;
			}
			fourDigits = fourDigits.reverse();
			System.out.println(fourDigits);
		}
	}
}

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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(ll i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)
using namespace std;

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

const ll K=998244353;
ll n,A,B,k;
ll mu(ll a , ll n){
    if (n==0) return 1;
    ll q=mu(a,n/2);
    if (n%2==0) return q*q%K;
    return q*q%K*a%K;
}
ll gt[300005],rev[300005];
ll Combi(ll n, ll k){
    if (n<k) return 0;
    return gt[n]*rev[k]%K*rev[n-k]%K;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    gt[0]=rev[0]=1;
    FOR (i,1,300001){
        gt[i]=gt[i-1]*i%K;
        rev[i]=mu(gt[i],K-2);
    }
    cin>>n>>A>>B>>k;
    ll res=0;
    FOR (a,0,n){
        if ((k-a*A)<0) break;
        if ((k-a*A)%B) continue;
        ll b=(k-a*A)/B;
        res=(res+Combi(n,a)*Combi(n,b)%K)%K;
    }
    cout<<res<<endl;

         return 0;
}


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

int main() {
  int x, a, b; cin >> x >> a >> b;
  if(b - a <= 0) cout << "delicious" << endl;
  else if(b-a > 0 && b-a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long MAX_N = 1000000000000000000;
int main(){
  int n; cin >> n;
  vector<long long> v(n);
  bool zero = false;
  for(long long &a: v){
    cin >> a;
    if(a == 0) zero = true;
  }
  if(zero){
    cout << 0 << endl;
  } else{
    bool overflow = false;
    long long ans = 1;
    for(int i = 0; i < n; ++i){
      if(ans > MAX_N / v[i]){
        overflow = true;
        break;
      } else {
        ans *= v[i];
      }
    }
    if(overflow) cout << -1 << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 4060
#include<stdio.h>

int main(){
	int dat[100];
	int A,B;
	B=0;
	for(A=0;A<100;A++)
		dat[A]=0;
	while(scanf("%d",&A)!=EOF){
		dat[A-1]++;
		if(B<dat[A-1])
			B=dat[A-1];
	}
	for(A=0;A<100;A++)
		if(dat[A]==B)
			printf("%d\n",A+1);
 	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int input,s1,s2,s3;
  cin >> input;
  
  s1 = input / 100;
  s2 = (input - s1 * 100) / 10;
  s3 = (input - s1 * 100 - s2 * 10) / 1;
  
   cout << s1 + s2 + s3 << endl;
  // ここにプログラムを追記
}

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

#define ll long long


bool ask(ll x){
	printf("? %lld\n", x);
	fflush(stdout);
	char ans[5];
	scanf("%s", ans);
	return ans[0] == 'Y';
}

void answer(ll x){
	printf("! %lld\n", x);
	exit(0);
}

void solve(int len){
	ll now = 0;
	for(int i = 0; i < len - 1; ++ i){
		int left = 0, right = 9, ans = -1;
		while(left <= right){
			int mid = left + right >> 1;
			if(ask(now * 10 + mid)){
				ans = mid;
				left = mid + 1;
			}
			else{
				right = mid - 1;
			}
		}
		assert(ans != -1);
		now = now * 10 + ans;
	}
	
	int left = len == 1, right = 9, ans = -1;
	while(left <= right){
		int mid = left + right >> 1;
		if(ask((now * 10 + mid) * 10)){
			ans = mid;
			right = mid - 1;
		}
		else{
			left = mid + 1;
		}
	}
	assert(ans != -1);
	now = now * 10 + ans;
	answer(now);
}

ll power[50]; 

int main(){
	power[0] = 1;
	for(int i = 1; i < 20; ++ i){
		power[i] = power[i - 1] * 10;
	}
	bool flag = ask(power[12]);
	int sit = 0;
	for(int i = 1; i < 12; ++ i){
		if(flag && sit){
			break;
		}
		if(ask(power[i - 1]) && ask(power[i] - 1)){
			sit = i;
		}
	}
	//printf("sit = %d\n", sit); 
	solve(sit);
	return 0;
}

Measured memory_bytes: 596
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();
        N *= 2;
        int[] arr = new int[N];
        for(int i = 0; i<N; i++) arr[i] = sc.nextInt();
        Arrays.sort(arr);
        int total = 0;
        for(int i = 0; i<N; i+=2){
            total += arr[i];
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 9684
#include <stdio.h>
void pr(int A[],int n)
{
  int i;
  for(i=0;i<n;i++)
  {
    if(i!=0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
void insertionSort(int A[],int n)
{
  int i,j,v;
  for(i=1;i<n;i++)
  {
    v = A[i];
    j = i-1;
    while(j>=0&&A[j]>v)
    {
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    pr(A,n);
  }
}
int main()
{
  int n,A[100],i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&A[i]);
  }
  pr(A,n);
  insertionSort(A,n);
  return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
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<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
#define pii pair<int,int> 
#define mii map<int,int>
#define vi vector<int>
#define umii unordered_map<int,int>
#define mod 998244353
#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 repo(i,o,e) for(int i = o ; i < e ; i++)
#define rep(n) for(int i = 0 ; i < n ; i++)
const ll sz = 2e5+5;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

void solve(){
    ll r , d , x;
    cin >> r >> d >> x;
    ll arr[100];
    arr[0] = x;
    repo(i,1,11){
        arr[i] = arr[i-1]*r - d;
    }
    repo(i,1,11)cout << arr[i] << endl;
}

int main(){
    FIO;
    int t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iX = int.Parse(sS[0]);
            int iA = int.Parse(sS[1]);
            int iB = int.Parse(sS[2]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "A";
            if (Math.Abs(iA - iX) > Math.Abs(iB - iX)) { sOut = "B"; }

            //出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;
import java.util.TreeSet;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			int k = scanner.nextInt();
			TreeSet<String> set = new TreeSet<>();
			int n = s.length();
			IntStream.range(0, n).forEach(
					i -> IntStream.rangeClosed(i + 1, Math.min(i + k, n)).forEach(j -> set.add(s.substring(i, j))));
			String answer = "";
			for (int i = 0; i < k; i++) {
				answer = set.pollFirst();
			}
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 40704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int H, W;
    cin >> H >> W;
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw; ch--; cw--; dh--; dw--;
    vector<string> G(H);
    for (int i = 0; i < H; i++) {
        cin >> G[i];
    }

    deque<iint> q;
    q.push_back(make_pair(ch, cw));

    int x[4] = {1,-1,0,0};
    int y[4] = {0,0,1,-1};
    vector<vector<int>> d(H, vector<int> (W, -1));
    vector<vector<bool>> used(H, vector<bool> (W, false));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if(G[i][j] == '#'){
                used[i][j] = true;
            }
        }
    }
    d[ch][cw] = 0;

    int h, w;
    while(!q.empty()){
        auto v = q.front(); q.pop_front();
        h = v.first; w = v.second;
        used[h][w] = true;

        for (int i = 0; i < 4; i++) {
            if(h+x[i]>=H || h+x[i]<0 || w+y[i]>=W || w+y[i]<0) continue;
            if(used[h+x[i]][w+y[i]]) continue;
            if(d[h+x[i]][w+y[i]] != -1 && d[h+x[i]][w+y[i]] <= d[h][w]) continue;
            d[h+x[i]][w+y[i]] = d[h][w];
            q.push_front(make_pair(h+x[i], w+y[i]));
        }

        for (int i = -2; i < 3; i++) {
            for (int j = -2; j < 3; j++) {
                if(h+i>=H || h+i<0 || w+j>=W || w+j<0) continue;
                if(used[h+i][w+j]) continue;
                if(d[h+i][w+j] != -1 && d[h+i][w+j] <= d[h][w] + 1) continue;
                d[h+i][w+j] = d[h][w] + 1;
                q.push_back(make_pair(h+i, w+j));
            }
        }

    }

    printf("%d\n", d[dh][dw]);

}

Measured memory_bytes: 9716
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
    { 
        if (y == 0) 
            return 1; 
        int p = power(x, y/2, m) % m; 
        p = (p * p) % m; 
  
        return (y%2 == 0)? p : (x * p) % m; 
    } 
    int modInverse(int a, int m) 
    {   
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p) 
    { 
           if (r==0) 
              return 1; 
  
        int fac[n+1]; 
        fac[0] = 1; 
        for (int i=1 ; i<=n; i++) 
            fac[i] = fac[i-1]*i%p; 
  
        return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
    } 
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        // cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            ll d=0,t=0,s=0;
            cin>>d>>t>>s;
            double x=((double)d)/s;
            if(x<=t)
                cout<<"Yes";
            else
                cout<<"No";
        }
        return 0;
    }

Measured memory_bytes: 3644
X = gets.to_i
l = [*2..100003]
t = Math.sqrt(100003)
(2..t.ceil).each{|i|
  l.reject! {|item| item % i == 0 && item != i}  
}
l.each{|i|
  if X <= i
    puts i
    exit
  end
}

Measured memory_bytes: 3452
#include <cstdio>
#include <utility>
#include <vector>

using namespace std;

enum class Direction { North, East, South, West, Stop, Invalid };

Direction ToDirection(char sym) {
  switch (sym) {
    case '^':
      return Direction::North;
    case '>':
      return Direction::East;
    case 'v':
      return Direction::South;
    case '<':
      return Direction::West;
    case '.':
      return Direction::Stop;
    default:
      return Direction::Invalid;
  }
}

int main() {
  while (true) {
    int h, w;
    scanf("%d %d", &h, &w);
    if (h == 0 && w == 0) { break; }

    vector<vector<bool>> visited(h);
    vector<vector<Direction>> map(h);
    for (int y = 0; y < h; ++y) {
      visited[y] = std::move(vector<bool>(w));
      map[y] = std::move(vector<Direction>(w));
      for (int x = 0; x < w; ++x) {
     REDO:
        Direction d = ToDirection(getchar());
        if (d == Direction::Invalid) { goto REDO; }
        map[y][x] = d;
      }
      getchar(); // Drops newline
    }
    typedef pair<int, int> Position;
    Position position(0, 0);
    Direction next_direction = map[0][0];
    while (next_direction != Direction::Stop) {
      if (visited[position.first][position.second]) {
        puts("LOOP");
        goto NEXT_DATA;
      }
      visited[position.first][position.second] = true;
      switch (next_direction) {
        case Direction::North:
          position.first -= 1;
          break;
        case Direction::East:
          position.second += 1;
          break;
        case Direction::South:
          position.first += 1;
          break;
        case Direction::West:
          position.second -= 1;
          break;
        case Direction::Stop:
          puts("not reached");
          break;
      }
      next_direction = map[position.first][position.second];
    }
    printf("%d %d\n", position.second, position.first);
 NEXT_DATA:
    ;
  }

  return 0;
}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	string str;
	cin >> str;
	printf("%s\n", str.substr(0,4) == "YAKI" ? "Yes" : "No");
	return 0;
}






Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,lint> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint sum[5140],ns[5140];
//set<pint> s[252];
pint ha[252][5140];int hs[252];
int a[5140];lint x[5140];
int b[252][5140];
void cal(int id,int pos,lint num){
	sum[pos]+=num;sum[pos+1]-=num;
	//hs[id]++;ha[id][hs[id]]=mp(pos,num);
	/*if(1){
		//cout<<id<<' '<<pos<<endl;
		rep(i,hs[id]+1){
			pint p=ha[id][hs[id]];
			//cout<<p.fi<<'a'<<p.se<<endl;
		}
	}*/
	while(hs[id]>0){
		pint p=ha[id][hs[id]],q=ha[id][hs[id]-1];
		if(p.se>num) break;
		//if(id==1 && pos==1) cout<<q.fi+1<<' '<<p.fi+1<<endl;
		sum[q.fi+1]+=num-p.se;sum[p.fi+1]-=num-p.se;
		hs[id]--;
	}
	hs[id]++;
	//if(hs[id]<1) cout<<id<<' '<<pos<<endl;
	ha[id][hs[id]]=mp(pos,num);
}
int main()
{
	int n,m;lint out=0;
	scanf("%d %d",&n,&m);
	x[0]=0;
	rep(i,n-1){
		scanf("%d",&a[i]);x[i+1]=x[i]+a[i];
	}
	//rep(i,n) cout<<x[i]<<endl;
	rep(i,n) rep(j,m) scanf("%d",&b[j][i]);
	
	memset(sum,0,sizeof(sum));
	memset(ns,0,sizeof(ns));
	memset(hs,0,sizeof(hs));
	rep(i,m) ha[i][0]=mp(-1,1145141919810364364LL);
	rep(i,n){
		memset(sum,0,sizeof(sum));
		rep(j,m) cal(j,i,b[j][i]);
		REP(j,1,n+4) sum[j]+=sum[j-1];
		rep(j,n+4) ns[j]+=sum[j];
		rep(j,i+1) out=max(out,ns[j]-x[i]+x[j]);
		
		//rep(j,n) cout<<ns[j]<<' ';cout<<endl;
	}
	cout<<out<<endl;
}


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

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
return q;
}

int main() {
  int N;
  cin >> N;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  long x = A[0];
  for (int i = 1; i < N; i++) x = gcd(x, A[i]);
  cout << x << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int r;

int main(int argc, char **argv) {
    std::cin >> r;
    
    std::cout << r*r*3 << std::endl;
    
    return 0;
}

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

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using usize = std::size_t;
using namespace std;

#define rep(i, max) for(i32 i = 0; i < (i32)max; ++i)
#define loop while(true)
#define allOf(collection) collection.begin(), collection.end()

unique_ptr<string> readLine() { unique_ptr<string> line(new string()); getline(cin, *line); return line; }
template<typename T1, typename T2> pair<T1, T2> readPair() { T1 res1; cin >> res1; T2 res2; cin >> res2; readLine(); return make_pair(res1, res2);}
template<typename T> unique_ptr<vector<T>> readVector(usize num, bool isForIndex = false) { unique_ptr<vector<T>> list(new vector<T>(num)); rep(i, num) { cin >> (*list)[i]; if(isForIndex) --(*list)[i]; } readLine(); return list; }
void readValues() { readLine(); }
template<typename H, typename... T> void readValues(H& head, T&&... tails){ H a; cin >> a; head = a; readValues(forward<T>(tails)...); }
void writeLine() { cout << endl; }
template<typename T> void write(const T& arg) { cout << arg; }
template<typename T> void writeLine(const vector<T>& arg){ if(arg.empty()) { writeLine(); return; } write(arg[0]); for(int i = 1; i < arg.size(); ++i){ write(" "); write(arg[i]); } writeLine(); }
template<typename T> void writeLine(const T& arg) { cout << arg << endl; }
void recursiveCombination(vector<i32>& indexes, i32 s, i32 rest, function<void(vector<i32>&)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursiveCombination(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursiveCombination(indexes, s - 1, rest - 1, f); } }
void foreachWithCombination(i32 n, i32 k, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(k); recursiveCombination(indexes, n - 1, k, f); }
void foreachWithPermutaton(i32 n, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(); indexes.reserve(n); rep(i, (usize)n) indexes.push_back(i); do f(indexes); while (next_permutation(allOf(indexes))); }
void foreachWithPermutaton(i32 n, i32 k, function<void(vector<i32>&)> f){ foreachWithCombination(n, k, [=](vector<i32>& combIndexes){ foreachWithPermutaton(k, [=](vector<i32>& permIndexes){ auto indexes = vector<i32>(); indexes.reserve(k); rep(i, (usize)k){ indexes.push_back(combIndexes[permIndexes[i]]); } f(indexes); }); }); }
void program();
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    program();
}

void program() {
    i32 n;
    readValues(n);
    auto a = *readVector<i32>(n);
    sort(allOf(a));
    reverse(allOf(a));
    i64 score = 0;
    score += a[0];
    
    queue<i32> que = queue<i32>();
    que.push(a[1]);
    que.push(a[1]);
    for(i32 i = 2; i < n; ++i) {
        score += que.front();
        que.pop();
        que.push(a[i]);
        que.push(a[i]);
    }

    writeLine(score);
}

Measured memory_bytes: 4948
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define endl "\n"
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define F(i,a,b) for(int i = a; i < b; i++)
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define inf 1e18
const double pi = 3.141592653589793238460;
#define debug false
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define mod 1000000007 

double maxvolume(double s) 
{ 
    double length = (double)s / 3; 
  
    s -= length; 

    double breadth = (double)s / 2; 
  
    double height = (double)(s - breadth); 
  
    return (double)length * breadth * height*1.0; 
} 

void solve()
{
    double l;
    cin>>l;
    cout<<fixed<<setprecision(12)<<maxvolume(l)<<"\n";   
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("Test.txt","r",stdin);
        // freopen("Output.txt","w",stdout);
    #endif
    
     // if(debug){watch_is();}
    solve();   
    return 0;
}

Measured memory_bytes: 256
l=[0]*10001
1.upto(99) do |x|
  1.upto([x,10000-x**2].min) do |y|
    1.upto([y,10000-x**2-y**2].min) do |z|
      n=x**2+y**2+z**2+x*y+y*z+z*x
      if n<=10000
        if x==y&&y==z
          l[n]+=1
        elsif x==y||y==z
          l[n]+=3
        else
          l[n]+=6
        end
      end
    end
  end
end
puts l[1..gets.to_i]

Measured memory_bytes: 14452
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll A, B, K; cin >> A >> B >> K;

	repe(i, A, B) {
		if (i < A + K || B - K < i) {
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p1 = p2 = p3 = pi = 0
for i in range(n):
    p1 += abs(a[i] - b[i])
    p2 += (abs(a[i] - b[i]))**2
    p3 += (abs(a[i] - b[i]))**3
    if pi < abs(a[i] - b[i]):
        pi = abs(a[i] - b[i])

print("%f" % (p1))
print("%f" % (p2**(1/2)))
print("%f" % (p3**(1/3)))
print("%f" % (pi))

Measured memory_bytes: 7816
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll S, C;
  cin >> S >> C;

  if (2 * S == C) {
    RETURN(S);
  }

  if (2 * S > C) {
    RETURN(C / 2);
  }

  if (2 * S < C) {
    ll ans = S;
    C -= (S * 2);
    ans += (C / 4);
    ANS;
  }

  return 0;
}

Measured memory_bytes: 3492
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 30 , 2019
 * 
 */

#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(i,x) for(auto (i)=0 ; (i)<(x); ++(i))
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;






auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 

    ivv(a);ivv(p);
    cout<<((3*a)+p)/2<<endl;


    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

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

int main(void){
    int n;
    scanf("%d",&n);
    int i,t;
    double sum=0,num[n];
    for(i=0;i<n;i++){
        scanf("%lf",&num[i]);
        num[i]=1/num[i];
        sum+=num[i];
    }
    printf("%lf",1/sum);
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{
string s ; cin>>s;
if(s.length()<5)
{
    cout<<"No";
    return 0;
}
if(s[2]==s[3]&&s[4]==s[5])
{
    cout<<"Yes";
    return 0 ;
}
cout<<"No";
       return 0;
}


Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
    int H, A;
    cin >> H >> A;
    if (H % A == 0)
    {
        cout << H / A << endl;
    }
    else
    {
        cout << H / A + 1 << endl;
    }
}


Measured memory_bytes: 256
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#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 itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
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;
const ll lnf=1ll<<60;

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans=-llmax;
  chmax(ans,a*c);
  chmax(ans,a*d);
  chmax(ans,b*c);
  chmax(ans,b*d);
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int main() {
	long long int n;
	cin >> n;
	if (n == 2) {
		cout << 1 << endl;
		return 0;
	}
	set<long long int> s;
	s.insert(n);
	for (long long int i = 2; i * i <= n; i++) {
		long long int tmp = n;
		while (tmp % i == 0) tmp /= i;
		if (tmp % i == 1) s.insert(i);
	}
	long long int tmp = n - 1;
	for (long long int i = 2; i * i <= n; i++) {
		if (tmp % i == 0) {
			s.insert(i);
			s.insert(tmp / i);
		}
	}
	s.insert(n - 1);
	cout << s.size() << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e5+5;
int a[N];

void fileIO()
{
        #ifndef ONLINE_JUDGE
        freopen("int.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
}
int main()
{
	IOS;
        //fileIO();
        int n,k;
        cin >> n >> k;
        string s;
        cin >> s;
        s[k-1] = s[k-1] - 'A'+'a';
        cout << s;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<double> p(n);
    for(int i=0;i<n;i++) cin >> p[i];
 
    vector<vector<double>> dp(n+1,vector<double>(n+1,0));
    dp[0][0] = 1.0;
 
    for(int i=0;i<n;i++) {
      for(int j=0;j<n;j++){
        dp[i+1][j] += dp[i][j] * (1.0-p[i]);
        dp[i+1][j+1] += dp[i][j] * p[i];}
    }
 
    double ans = 0;
    for(int i=n/2+1; i <= n; i++) ans += dp[n][i];
 
    cout << std::setprecision(10) << ans << endl;
 
    return 0;
}

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

int main(){
  int N,count = 0;
  cin >> N;
  
  for(int i = 1;i <= N;i++){
    
    if(i >= 1 && i <= 9){
      count++;
    }
    
    if(i >= 100 && i <= 999){
      count++;
    }
    
    if(i >= 10000 && i <= 99999){
      count++;
    }
  }
  
  cout << count << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n;
map<string,int> mp;
int main(){
cin>>n;
for(int k=1;k<=n;k++){
    string s;
    cin>>s;
    mp[s]++;
}
cout<<"AC"<<" x "<<mp["AC"]<<endl;
cout<<"WA"<<" x "<<mp["WA"]<<endl;
cout<<"TLE"<<" x "<<mp["TLE"]<<endl;
cout<<"RE"<<" x "<<mp["RE"];
return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>=0&&a<=100&&b>=2&&b<=1000&&b%2==0)
	{
		if(a<=5)
			printf("0\n");
		else if(a<=12)
			printf("%d",b/2);
		else if(a>12)
			printf("%d",b);
	}
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n){ int ret = 1; for(int i = 1; i < n + 1; ++i) { ret = ret * i; } return ret; }

/* 最大公約数 */
template <typename T>T gcd(T x, T y){ return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>T lcm_n(vector<T> &numbers) { T l; l = numbers[0]; for(int i = 1; i < numbers.size(); ++i) { l = lcm(l, numbers[i]); } return l; }

/*
 * DP向け
 */
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; }

/*
 * グラフ
 */
class Graph {
   public:
    vector<vector<int>> G;
    vector<int> Trans;
    vector<int> inDeg;
    int numV;
 
    Graph(int numV) {
        this->numV = numV;
        inDeg.assign(numV, 0);
        Trans.assign(numV, 0);
        G.assign(numV, vector<int>());
    }
 
    int topologicalSort(int v, vector<int> &dp) {
        if (dp[v] != -1) {
            return dp[v];
        }
 
        int res = 0;
 
        for (auto to : G[v]) {
            chmax(res, topologicalSort(to, dp) + 1);
        }
 
        return dp[v] = res;
    }
};

int main(){
  ll h, w;
  cin >> h >> w;

  ll cnt1 = w%2 == 0 ? w/2 : (w+1)/2;
  ll cnt2 = w%2 == 0 ? cnt1 : cnt1-1;
  ll ans = 0;

  if(h == 1 || w == 1){
    cout << 1 << endl;
    return 0;
  }

  for(int i = 0; i < h; ++i){
    if(i%2 == 0){
      ans += cnt1;
    }else{
      ans += cnt2;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#define N 100010
ll n,i,f[N],g[N],a[N];
int main()
{
	scanf("%lld",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for (i=1;i<=n;i++) f[i]=f[i-1]+abs(a[i]-a[i-1]);
	for (i=n;i>=1;i--) g[i]=g[i+1]+abs(a[i]-a[i+1]);
	for (i=1;i<=n;i++)
	{
		printf("%lld\n",f[i-1]+g[i+1]+abs(a[i-1]-a[i+1]));
	}
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
  ll A,B,N;
  cin >> A >> B >> N;
  
  if(N>(B-2)){
    cout << A * (B-1) / B << endl;
  }
  else{
    cout << (A*N/B)-A*(N/B) << endl;
  }
  
}
    

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <string>
#include <deque>
#include <stack>
#include <cmath>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (LL i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<LL> VI;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 400040	;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL * 1000 * 1000 + 7;

int n,k;
LL arr[21][21];
LL dpT[21][(1<<21)];
LL dp(int pos, int womans)
{
	if(pos==n)
		return womans==0;
	if(dpT[pos][womans]!=-1LL)
		return dpT[pos][womans];
	LL ans=0;
	FOR(i,0,n)
	{
		if(arr[pos][i] && (womans&(1<<i)))
		{
			ans=(ans+dp(pos+1,womans^(1<<i)))%mod;
		}
	}

	return dpT[pos][womans]=ans;
}



int main()
{
	//freopen("input.tXXt", "r", stdin);
	ios_base::sync_with_stdio(0);
	FILL(dpT,-1);
	cin >> n;
	FOR(i,0,n)
		FOR(j,0,n)
			cin >> arr[i][j];
	cout<<dp(0,(1<<n)-1);
	return 0;
}


Measured memory_bytes: 344320
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const ll mod = 1000000007;
int d, w, e[11][11], ans;

map<P, int> mp;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

ll gcd(ll x, ll y)
{
	if (y == 0)
	{
		return x;
	}
	else
	{
		return gcd(y, x % y);
	}
}

int main(void)
{
	while (true)
	{
		cin >> d >> w;
		if (d == 0 && w == 0) break;
		for (int i = 1; i <= d; i++)
		{
			for (int j = 1; j <= w; j++)
			{
				cin >> e[i][j];
			}
		}
		ans = 0;
		for (int i = 1; i <= d - 2; i++)
		{
			for (int j = i + 2; j <= d; j++)
			{
				for (int k = 1; k <= w - 2; k++)
				{
					for (int l = k + 2; l <= w; l++)
					{
						int hei = 20;
						bool jud = true;
						int wat = 0;
						for (int m = k; m <= l; m++)
						{
							hei = min(hei, e[i][m]);
							hei = min(hei, e[j][m]);
						}
						for (int m = i; m <= j; m++)
						{
							hei = min(hei, e[m][k]);
							hei = min(hei, e[m][l]);
						}
						for (int m = i + 1; m < j; m++)
						{
							for (int o = k + 1; o < l; o++)
							{
								if (hei <= e[m][o]) jud = false;
								wat += hei - e[m][o];
							}
						}
						if (jud)
						{
							ans = max(ans, wat);
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	int www;
	cin >> www;
}



Measured memory_bytes: 3088
X,N = map(int,input().split())
if N>0:
    p_set = set(map(int,input().split()))
else:
    p_set = set()
min_dist_xp = 1000
for p in reversed(range(0,102)):
    if p not in p_set:
        dist_xp = abs(X-p)
        if dist_xp<=min_dist_xp:
            min_dist_xp = dist_xp
            ans = p
print(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
bool vis[101010];
int main()
{
    int K; scanf("%d", &K);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q;
    Q.emplace(0, K);
    while(!Q.empty())
    {
        int dist, node; tie(dist, node) = Q.top(); Q.pop();
        if(vis[node]) continue; vis[node] = true;
        if(node == 0)
        {
            printf("%d\n", dist);
            return 0;
        }
        for(int i=0; i<=9; ++i)
        {
            int targ = K*i+node;
            Q.emplace(dist+targ%10, targ/10);
        }
    }
}

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

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);++(i))
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define ppb(x) pop_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int check(string s, int l, int r) {
  while (l<r) {
    if (s[l] != s[r]) return 0;
    l++;
    r--;
  }
  return 1;
}

int main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  int res = check(s, 0, n-1);
  res &= check(s, 0, (n-1)/2-1);
  res &= check(s, (n+3)/2-1, n-1);
  puts(res ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256