akhauriyash/Code-Regression huggingface dataset:
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a*b)/2 << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    A, B, C, D = IL(int)
    if A + B > C + D:
        print('Left')
    elif A + B == C + D:
        print('Balanced')
    else:
        print('Right')


solve()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main(){
	
	
	string S,T;
	int i,Ts,Ss;
	cin >> S>>T;
	Ts=T.size();
	Ss=S.size();
	if (Ts = Ss+1){
		for (i=0;i<S.size();i++){
			if (S[i]==T[i]){
				
				if (i==Ss-1){
					cout<<"Yes";
				}
				else{
					
					continue;
					
				}
				
			
				
			}
			else{
					cout <<"No";
					break;
				}
			
		}
		
		
	}
	else{
		cout <<"No";
	}
	
	
	return 0;
	
	
	
}

Measured memory_bytes: 3624
import java.util.*;

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

	while(sc.hasNext()){

	    double t = sc.nextDouble()/9.8;
	    double y = 4.9 * t*t;

	    int ans = 0;
	    for(int i=1;; i++){
		int n1 = 5*(i-1)-5;
		int n2 = 5*i-5;
		if(y>n1 && y<=n2){ans = i; break;}
	    }

	    System.out.println(ans);
	}
    }
}

Measured memory_bytes: 12000
using System;
using System.Globalization;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        double D = ScanDouble(), T = ScanDouble(), S = ScanDouble();
        Console.WriteLine(D / S <= T ? "Yes" : "No");
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static string Scan() {
        var sb = new StringBuilder();
        for (var ch = GetChar(); '!' <= ch && ch <= '~'; ch = (char) ConsoleIn()) {
            sb.Append(ch);
        }
        return sb.ToString();
    }
    public static double ScanDouble() => double.Parse(Scan(), CultureInfo.InvariantCulture);
}

Measured memory_bytes: 23864
#include <stdio.h>

int main(void) {
  int a,b;
  scanf("%d%d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }else if(a>b){
printf("a > b\n");
  }else{
printf("a == b\n");
  }
  return 0;
}


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

int n;
int g[105][105];
vector <int> G[105];

int main()
{
    cin >> n;

    if (n % 2 == 0)
    {
        for (int i = 1; i <= n / 2; i++)
        {
            g[i][n - i + 1] = 1;
            g[n - i + 1][i] = 1;
        }
    }
    else
    {
        for (int i = 1; i <= n / 2; i++)
        {
            g[i][n - i] = 1;
            g[n - i][i] = 1;
        }
        g[n][n] = 1;
    }

    int m = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            if (!g[i][j])
            {
                G[i].push_back(j);
                m++;
            }

    cout << m << "\n";
    for (int i = 1; i <= n; i++)
        for (auto x: G[i])
            cout << i << " " << x << "\n";

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
vector<int> ret;

void solve(int k, int n) {
    if (n % 2 == 0) {
        ret.push_back(n/2);
        for (int i = 0; i < k-1; i++) {
            ret.push_back(n);
        }
        return;
    }
    for (int i = 0; i < k; i++) ret.push_back(n/2+1);
    for (int i = 0; i < k/2; i++) {
        if (ret.back() == 1) {
            ret.pop_back();
            continue;
        }
        ret.back()--;
        while (ret.size() < k) {
            ret.push_back(n);
        }
    }

}
int main() {
//    freopen("test.txt", "r", stdin);
    int n, k;
    cin >> k >> n;
    solve(n, k);
    for (int i = 0; i < ret.size(); i++) {
        printf("%d", ret[i]);
        if (i+1 == ret.size()) printf("\n");
        else printf(" ");
    }
}

Measured memory_bytes: 3568
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        Integer[] mountains = new Integer[10];
        for (int i = 0; i < 10; i++) {
            mountains[i] = sc.nextInt();
        }

        Arrays.sort(mountains, Collections.reverseOrder());

        StringBuilder sb = new StringBuilder("");
        for (int i = 0; i < 3; i++) {
            sb.append(mountains[i]);
            sb.append('\n');
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 26136
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 1005;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    double k = (n-m)*100+m*1900;
    double a = (1<<m);
    double ans = 0,mul = 1;
    rep(i,1,100000){
        ans += mul*k*i/a;
        mul *= (a-1)/a;
    }
    ans = (ll)(ans+0.99)/1;
    PRINT(ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
int h[100010]; // shuugo 
int dp[100010]; // cost at i --> dp[i]
int  INF = INT_MAX;
int INF2 = 10010010;
#define  min(a,b) (a>b? b:a)
int sa(int a, int b){return a>b? a-b:b-a;}
int 
chmin(int  *a, int b) 
{
	 if (*a > b){
		 *a = b; //	printf("%ld\n",*a);
		 return 1; 
	 }
	 return 0;
}
int 
main(){
	int N,i,K;
	scanf("%d %d",&N,&K);
	
	//printf("%d,%d",INF,INF2);
	for(i=0;i<N;i++){
		scanf("%d",&h[i]); //d[i]=100010;
	}
	for(i=0;i<N;i++){
		dp[i] =INF;
	}
	int j;
	dp[0]=0; // cost at 1 // default
	for(i=0;i<=N;i++){
		for(j=1;j<=K;j++){
			if(i+j<=N)dp[i+j] = min(dp[i+j],dp[i]+ sa(h[i+j],h[i]));
			else break;
		}
	}
	printf("%d\n",dp[N-1]);
 return 0;
}

Measured memory_bytes: 896
s = input()

s1 = " ".join(s.split('dreameraser'))

s2 = " ".join(s1.split('dreamerase'))

s3 = " ".join(s2.split('dreamer'))

s4 = " ".join(s3.split('dream'))

s5 = " ".join(s4.split('eraser'))

s6 = " ".join(s5.split('erase'))


if s6.strip() == '':
    print('YES')
else:
    print('NO')

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	map<string, int> conv;
	cout << 0 << endl;
	fflush(stdout);
	string ret; cin >> ret;

	if (ret == "Vacant") return;

	conv["Male"] = (int)(ret == "Female");
	conv["Female"] = (int)(ret == "Male");
	int ng = 0, ok = N;
	while (abs(ok-ng) > 1) {
		int query = (ng+ok)>>1;
		cout << query << endl;
		fflush(stdout);
		cin >> ret;
		if (ret == "Vacant") return;
		if (((query&1) ^ conv[ret]) == 0) ng = query;
		else ok = query;
	}
	cout << ok << endl;
	fflush(stdout);
	cin >> ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define llenar(a,val)   memset(a,val,sizeof(a))
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef long long ll;
typedef vector< pair<pair<int,int>,int> > viii;

char a[1000][1000];

int main(){
    ofstream out("output.txt");
    

    string s;
    cin>>s;
    bool res = true;
    for(int i =0;i<s.size();i+=2){
        res &= (s[i]=='R'||s[i]=='U'||s[i]=='D');
    }
    for(int i =1;i<s.size();i+=2){
        res &= (s[i] == 'L' || s[i] == 'U' || s[i] == 'D');
    }
    if(res) cout<<"Yes\n";
    else    cout<<"No\n";
    
    return 0;
}

 
 







Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);
const int N = 5010;

int ans,n,k,cnt,len,times;
int p[N];
int c[N];
int mx[N];
bool vis[N];
vector<int>path;


void dfs(int now,int x){
    vis[now] = 1;
    int pre = path.back();
    path.pb(pre+c[p[now]]);
    cnt++;
    mx[cnt] = max(mx[cnt-1],path.back());
    if(!vis[p[now]])
        dfs(p[now],x);
}

void solve(){
    ans = (int)-1e18;
    cin >> n >> k;
    rep(i,1,n+1)
        cin >> p[i];
    rep(i,1,n+1)
        cin >> c[i];
    rep(i,1,n+1){
        memset(vis,0,sizeof(vis));
        mx[0] = (int)-1e18;
        cnt = 0;
        path.clear();
        path.pb(0);
        dfs(i,i);
        len = path.size()-1;
        times = k/len;
        if(times)
            ans = max(ans,path[len]*(times-1)+mx[len]);
        if(path[len]>0)
            ans = max(ans,path[len]*times+max(0LL,mx[k%len]));
        ans = max(ans,mx[min(k,len)]);
    }
    cout << ans << '\n';
}

signed main(){
    Rushia_mywife
    solve();
}

Measured memory_bytes: 4148
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int A[] = new int[N+1];//上司マップ
    int B[] = new int[N+1];//部下の数配列
    A[0]=0;
    A[1]=0;
    B[0]=0;
    for(int i=2;i<=N;i++){
      A[i]=sc.nextInt();
      B[A[i]]++;
    }
    for(int i=1;i<=N;i++){
      System.out.println(B[i]);
    }



  }
}
 

Measured memory_bytes: 62860
#include<bits/stdc++.h>
using namespace std;
int main(){
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    cout<<fixed<<setprecision(15)<<sqrt(pow((x2-x1),2)+pow((y2-y1),2))<<endl;
}


Measured memory_bytes: 3288
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
const int maxn = 55;

int D;
vector<int>d;

int getD(int idx) {
  idx--;
  if(idx>=d.size())return 0;
  return d[idx];
}
ll f[maxn][2][2];
ll solve(int len) {
  memset(f,0,sizeof(f));
  f[0][0][0]=1;
  int m=(len+1)>>1;
  for(int i=0; i<m; i++)
    for(int j=0; j<2; j++)
      for(int k=0; k<2; k++) {
        if(f[i][j][k]==0)continue;
        if(i+1==m&&(len&1)) {
          for(int r=0; r<10; r++) {
            int tmp=r+j+getD(i+1);
            if(tmp%10==r&&tmp/10==k)f[i+1][tmp/10][j]+=f[i][j][k];
          }
        } else {
          for(int r=0; r<10; r++) {
            int tmp=r+getD(i+1)+j;
            int bit=tmp%10;
            if(i==0&&tmp%10==0)continue;
            int tmp2=bit+getD(len-i);
            if(tmp2%10==r&&tmp2/10==k) {
              f[i+1][tmp/10][0]+=f[i][j][k];
            } else if((tmp2+1)%10==r&&(tmp2+1)/10==k) {
           //   if(len==2)cout<<"dfs"<<r<<endl;
              f[i+1][tmp/10][1]+=f[i][j][k];
            }
          }
        }
      }
  ll ret=0;
  if(len&1) {
    for(int i=0; i<2; i++)
      for(int j=0; j<2; j++)
        ret+=f[m][i][j];
  } else {
    for(int i=0; i<2; i++)
      ret+=f[m][i][i];
    //if(len==2)cout<<f[1][1][1]<<endl;
  }
 // cout<<len<<":"<<ret<<endl;
  return ret;
}

int main() {
#ifdef suiyuan2009
  freopen("in.cpp","r",stdin);
#endif
  cin>>D;
  while(D) {
    d.push_back(D%10);
    D/=10;
  }
  ll ret=0;
  for(int i=d.size(); i<maxn; i++)ret+=solve(i);
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define ll long long
#define vi vector<long long>
#define pi pair<long long, long long>
#define mp make_pair
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)123456789;
const ll N = (1<<12);


ll n, m, dp[N], ans=0;
pair<ll, ll> k[1001];
vector<ll> pos;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("C.txt", "r", stdin);
    #endif
    for(int i=0; i<N; i++) dp[i] = INF;
    cin >> n >> m;
    ans = pow(2, n) - 1;
    for(int i=0, x, in; i<m; i++){
        int mask = 0;
        cin >> k[i].F >> x;
        for(int j=0; j<x; j++){
            cin >> in;
            mask |= (1<<(in-1));
        }
        k[i].S = mask;
    }
    pos.pb(0); dp[0] = 0;
    for(int i=0; i<m; i++){
        int s = sz(pos);
        for(int j=0; j<s; j++){
            if(dp[ pos[j] | k[i].S ]  == INF) pos.pb((pos[j] | k[i].S));
            dp[ pos[j] | k[i].S ] = min(dp[ pos[j] | k[i].S ], dp[pos[j]] + k[i].F);
        }
    }
    cout << (dp[ans]==INF?-1:dp[ans]);

}




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


int main(){
                                                                     

    long long n, i, k;

    long long x = 0;


    cin >> n;


    vector<long long> a(n);

    vector<long long> b(n);


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

         cin >> a.at(i);

         b.at(i) = a.at(i) - i;

         }


    sort( b.begin(), b.end() );

    if( n % 2 == 1 ) k = b.at( n / 2 );

    else k = ( b.at( n / 2 ) + b.at( n / 2 - 1 ) ) / 2;


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

         x += abs( b.at(i) - k );

         }
         

    cout << x << endl;
    

    return 0;

    }

Measured memory_bytes: 3328
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj

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

#define ll long long

const int N   = 2e5 + 5;

int main(){

	int n;
	cin>>n;
	cout<<(n*n)*3<<endl;
	return 0;
}



Measured memory_bytes: 256
def f(a,b):
    return max(len(str(a)),len(str(b)))

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    n=int(input())
    m=make_divisors(n)
    a=10**10
    for i in m:
        if n//i < i:
            break
        else:
            a=min(a, f(i, n//i))
    print(a)
                
if __name__ == "__main__":
    main()

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

struct town{
    ll x,y,id;
};

struct edge{
    ll u, v, cost;
};

bool comp_c(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}
bool comp_x(const town& t1, const town& t2){
    return t1.x < t2.x;
}
bool comp_y(const town& t1, const town& t2){
    return t1.y < t2.y;
}

int n,k;
ll a[16];

ll solve(ll ans, int knum, int cou, ll max_hight){
    ll mem1, mem2;
    if(knum == k)   return ans;
    if(cou == n)    return LL_INF;
    mem1 = solve(ans + maxll(max_hight-a[cou]+1, 0), knum+1, cou+1, maxll(max_hight+1, a[cou]));
    mem2 = solve(ans, knum, cou+1, maxll(max_hight, a[cou]));
    return minll(mem1, mem2);
    
}

int main(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    cout << solve(0, 0, 0, 0) << endl;
    
}

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



#define MAX 100002
int n;

vector<long long int> v;


vector<pair<int, int> > V;


int belong[MAX];
long long int len[MAX];

inline int root(int b){
	if (belong[b] == -1){
		return b;
	}
	belong[b] = root(belong[b]);
	return belong[b];
}
void merge(int a, int b){
	a = root(a);
	b = root(b);
	if (a > b){
		swap(a, b);
	}
	belong[b] = a;
	len[a] += len[b];
}

vector<int> ope;


int main(){
	memset(belong, -1, sizeof(belong));

	cin >> n;
	int l;
	cin >> l;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	for (int i = 0; i < v.size(); i++){
		if (v[i] >= l){
			for (int j = i-1; j >= 0; j--){
				ope.push_back(j);
			}
			for (int j = i; j < n - 1; j++){
				ope.push_back(j);
			}
			reverse(ope.begin(), ope.end());
			puts("Possible");
			for (int j = 0; j < ope.size(); j++){
				printf("%d\n", ope[j]+1);
			}
			return 0;
		}
	}
	for (int i = 0; i + 1 < v.size(); i++){
		if (v[i] + v[i + 1] >= l){
			ope.push_back(i);
			for (int j = i - 1; j >= 0; j--){
				ope.push_back(j);
			}
			for (int j = i + 1; j < n - 1; j++){
				ope.push_back(j);
			}
			reverse(ope.begin(), ope.end());
			puts("Possible");
			for (int j = 0; j < ope.size(); j++){
				printf("%d\n", ope[j] + 1);
			}
			return 0;
		}
	}
	puts("Impossible");
	return 0;
}

Measured memory_bytes: 2932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scan = new Scanner(System.in)) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			int c = scan.nextInt();

			if(a < b && b < c) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

}

Measured memory_bytes: 26124
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	
	int W, A, B;
	scanf("%d%d%d", &W, &A, &B);

	if (B > A + W ) {
		printf("%d", abs(B - A - W));
	}
	else if (B + W < A) {
		printf("%d", abs(A - B - W));

	}
	else {
		printf("0");
	}











}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef signed long long ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < n; i++)
#define all(x) x.begin(),x,end()

#define __INT_MAX__ 2147483647

//#define DEBUG

int main()
{
	string s;
	cin >> s;
	int l = (int)(s.length());
	bool ans = true;

	for(int i = 1; i <= l; i++)
	{
		if(i % 2 == 1)
		{
			if(s[i-1] == 'L')
			{
				ans = false;
				break;
			}
		#ifdef DEBUG
			cout << s[i-1] << ' ';
		#endif
		} 
		if(i % 2 == 0)
		{
			if(s[i-1] == 'R')
			{
				ans = false;
				break;
			}
		}
	}
	#ifdef DEBUG
		cout << endl;
	#endif

	if(ans == true)
	{
		cout << "Yes" << endl;
	}
	if(ans == false)
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
char s[N];
int ans,n,k;
int main()
{
	scanf("%d%d",&n,&k);
	scanf("%s",s);
	for (int i=1;i<n;i++) if (s[i]==s[i-1]) ans++;
	ans=min(ans+k*2,n-1);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  double w, h, x, y;
  cin >> w >> h >> x >>y;
  cout << setprecision(9) <<  w * h / 2 << " ";
  if (x == w / 2 && y == h /2){
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#define NIL -1
typedef struct{
  int p;
  int l;
  int r;
  int id;
} Tree;
Tree T[30];

void init(int n){
  for(int i = 0; i < n; ++i){
    T[i].id = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
    T[i].p = NIL;
  }
}
int getRoot(int n){
  for(int i = 0; i < n; ++i){
    if(T[i].p == NIL)
      return i;
  }

}
void printPreorder(int u){
  if(u == NIL)
    return;
  printf(" %d", T[u].id);
  printPreorder(T[u].l);
  printPreorder(T[u].r);
}
void printInorder(int u){
  if(u == NIL)
    return;
  printInorder(T[u].l);
  printf(" %d", T[u].id);
  printInorder(T[u].r);
}
void printPostorder(int u){
  if(u == NIL)
    return;
  printPostorder(T[u].l);
  printPostorder(T[u].r);
  printf(" %d", T[u].id);
}
int main(){
  int n, id, l, r;

  scanf("%d", &n);
  init(n);
  for(int i = 0; i < n; ++i){
    scanf("%d%d%d", &id, &l, &r);
    T[id].id = id;
    if(l != NIL){
      T[id].l = l;
      T[l].p = id;
    }
    if(r != NIL){
      T[id].r = r;
      T[r].p = id;
    }
  }
  int root = getRoot(n);
  printf("Preorder\n");
  printPreorder(root);
  printf("\nInorder\n");
  printInorder(root);
  printf("\nPostorder\n");
  printPostorder(root);
  printf("\n");
  return 0;
}



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

vector<long double>gravs(200);
struct carry {
	int id;
	double l;
	double r;
};

pair<long double,int> getans(const vector<vector<carry>>&carrys,const int now) {
	int weightsum = 4;
	long double posisum = weightsum*gravs[now];
	for (auto i : carrys[now]) {
		auto ans(getans(carrys, i.id));
		if (ans.first > i.l&&ans.first < i.r) {
			const int plusweightsum = ans.second;
			const long double plusposisum = plusweightsum*ans.first;
			weightsum += plusweightsum;
			posisum += plusposisum;
		}
		else {
			throw(0);
		}
	}
	return make_pair(posisum / weightsum, weightsum);
}
int X, Y;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

void check(vector<vector<int>>&nums, const int y, const int x,const int id,const int from) {
	nums[y][x] = id;
	for (int i = 0; i < 4; ++i) {
		const int ny = y + dy[i];
		const int nx = x + dx[i];
		if (ny < Y && ny >= 0 && nx < X && nx >= 0&& nums[ny][nx] == from) {
			check(nums, ny, nx,id, from);
		}
	}
	return;
}

int main() {
	while (1) {
		cin >> X >> Y;
		if (!X)break;
		vector<vector<pair<int,int>>>places(200);
		vector<vector<carry>>carrys(200);
		vector<vector<int>>nums(Y);
		gravs.clear();
		gravs.resize(200);
		for (int i = 0; i < Y; ++i) {
			string st; cin >> st;
			for (int j = 0; j < X; ++j) {
				if (st[j] == '.')
					nums[i].push_back(0);
				else 
					nums[i].push_back(st[j] - '0');
			}
		}
		int num = 11;
		for (int i = 0; i < Y; ++i) {
			for (int j = 0; j < X; ++j) {
				if (nums[i][j] >= 1 && nums[i][j] <= 9) {
					check(nums, i, j, num,nums[i][j]);
					num++;
				}
			}
		}
		for (int i = 0; i < Y; ++i) {
			for (int j = 0; j < X; ++j) {
				if (nums[i][j]) {
					places[nums[i][j]].push_back(make_pair(i, j));
				}
			}
		}
		for (int i = 0; i < 200; ++i) {
			if (!places[i].empty()) {
				long double x_sum = 2;
				for (int j = 0; j < 4; ++j) {
					x_sum += places[i][j].second;
				}
				gravs[i] = x_sum / 4;
			}
		}
		for (int i = 0; i < Y; ++i) {
			for (int j = 0; j < X; ++j) {
				if ((i==Y-1&&nums[i][j])||(nums[i][j] && nums[i + 1][j]&&nums[i][j]!=nums[i+1][j])) {
					const int up = nums[i][j];
					const int down = i==Y-1?0:nums[i + 1][j];
					auto it=find_if(carrys[down].begin(), carrys[down].end(), [=](const carry&c) {return c.id == up; });
					if (it == carrys[down].end()) {
						carrys[down].push_back(carry{ up,j+ 0.001,j + 1- 0.001 });
					}
					else {
						it->l = min(it->l, j + 0.001);
						it->r = max(it->r, j + 1 - 0.001);
					}
				}
			}
		}

		bool stable = true;
		try {
			getans(carrys, 0);
		}
		catch (...) {
			stable = false;
		}
		if (stable) {
			cout << "STABLE" << endl;
		}
		else {
			cout << "UNSTABLE" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long A, long long B, long long N)
{

  LL ans = 0;
  if (N >= B - 1)
  {
    ans = A * (B - 1) / B;
  }

  else
    chmax(ans, A * N / B);
  cout << ans << endl;
}

int main()
{
  cout << setprecision(10);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long N;
  scanf("%lld", &N);
  solve(A, B, N);
  return 0;
}


Measured memory_bytes: 3736
N=int(input())
S1=input()
S2=input()
mod=10**9+7
ans=1
i=0
pretwo=False
while i<N:
    if i==0:
        if S1[i]!=S2[i]:
            ans*=6
            i+=2
            pretwo=True
        else:
            ans*=3
            i+=1
            pretwo=False
    else:
        if pretwo:
            if S1[i]!=S2[i]:
                ans*=3
                ans%=mod
                i+=2
                pretwo=True
            else:
                i+=1
                ans%=mod
                pretwo=False
        else:
            if S1[i]!=S2[i]:
                ans*=2
                ans%=mod
                i+=2
                pretwo=True
            else:
                ans*=2
                i+=1
                ans%=mod
                pretwo=False
print(ans)

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

int main()
{
    int t;
//    cin >> t;
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            a[i] -= (i+1);
//            cout <<  a[i] << " ";
        }
        sort(a,a+n);
        ll med, ans = 0;
        med = a[n/2];
        for (int i =0; i <n; i++) {
            ans += abs(a[i]-med);
        }
        cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

ll n, a, b;
ll h[1000000];

bool isOk(ll k) {
    ll tmp = 0;
    for (int i = 0; i < n; i++) {
        if (h[i] - b * k > 0)
            tmp += (h[i] - b * k + a - b - 1) / (a - b);
    }
    return tmp <= k;
}

ll bs(ll ok, ll ng) {
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isOk(mid))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

int main() {
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    OUT(bs(10000000000, 0));
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        int ans = 0;

        if(X < A)   ans = 0;
        else    ans = 10;

        System.out.print(ans);
    }
}

Measured memory_bytes: 21844
/*input
abcdab
*/

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;
  int n = s.length(), ans = 0;
  for (int l = 0, r = n - 1; l < r; ++l, --r) {
    ans += (s[l] != s[r]);
  }
  cout << ans;

  return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    vll c(n);
    rep(i, n) cin >> c[i];
    ll ans = -1e18;
    rep(i, n) {
        vll sum;
        vi pass(n, -1);
        sum.pb(0);
        int j = 0;
        pass[i] = j;
        int v = i;
        int rl = -1, rbi = -1;
        while (1) {
            ++j;
            v = p[v];
            ll val = sum.back();
            sum.pb(val+c[v]);
            if (pass[v] != -1) {
                rl = j - pass[v];
                rbi = pass[v];
                break;
            }
            pass[v] = j;
        }
        ll mx = -1e18;
        int rps = (k - rbi) / rl, rpr = (k - rbi) % rl;
        if (k <= rbi + rl) {
            rep1(i2, k) mx = max(mx, sum[i2]);
        }
        else if (sum.back()-sum[rbi]>=0) {
            rep1(i2, rbi) mx = max(mx, sum[i2]);
            rep1(i2, rpr) mx = max(mx, sum[rbi]+(sum.back()-sum[rbi])*rps+(sum[rbi+i2]-sum[rbi]));
            for (int i2=rpr+1; i2<=rl; ++i2) {
                mx = max(mx, sum[rbi]+(sum.back()-sum[rbi])*(rps-1)+(sum[rbi+i2]-sum[rbi]));
            }
        }
        else {
            rep1(i2, sz(sum)) mx = max(mx, sum[i2]);
        }
        ans = max(ans, mx);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3808
#include<stdio.h>
int main(){
int a[101],b[101],dp[101][10001],n,w,i,j;
scanf("%d %d\n",&n,&w);
for(i=0;i<n;i++){
scanf("%d %d\n",&a[i],&b[i]);
}
for(i=0;i<w;i++){
dp[0][i]=0;
}
for(i=0;i<n;i++){
for(j=0;j<=w;j++){
if(j<b[i]){
dp[i+1][j]=dp[i][j];
}
else{
if(dp[i][j]<dp[i+1][j-b[i]]+a[i]){
dp[i+1][j]=dp[i+1][j-b[i]]+a[i];
}
else{
dp[i+1][j]=dp[i][j];
}
}
}
}
printf("%d\n",dp[n][w]);
return 0;
}



Measured memory_bytes: 5728
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int x =0;
		
		for(int i=0;i<S.length();i++) {
			if(T.charAt(i)!=S.charAt(i)) {
				x ++;
			}
		}
		System.out.println(x);
		sc.close();

	}

}

Measured memory_bytes: 41208
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
int data_size;
cin >>data_size;
int r[data_size];
for(int i=0;i<data_size;i++)
    cin>> r[i];
     
int min_value=r[0];
int diff_max=-1e9;
for(int j=1;j<data_size;j++){
    if(diff_max<=r[j]-min_value) diff_max=r[j]-min_value;
    if(r[j]<=min_value) min_value=r[j];
}
 
cout<<diff_max<<endl;
return 0;
}

Measured memory_bytes: 1940
#include<bits/stdc++.h>	
#define int long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second 
#define mod 1000000007     
using namespace std;

main()
{	
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	string s;

	cin >> s;
	if(s == "AAA" or s == "BBB")
		cout << "No";
	else cout << "Yes";
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100010
#define ll long long
using namespace std;
int a[N];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	if(n%3==0){
		sort(a+1,a+n+1);
		int num=1,sum=a[1]^a[n/3+1]^a[n/3*2+1];
		if(sum)return 0*printf("No\n");
		for(int i=2;i<=n;i++){
			if(a[i]!=a[i-1]){
				if(num!=n/3)return 0*printf("No\n");
				num=1;
			}
			else num++;
		}
		printf("Yes\n");
	}
	else {
		for(int i=1;i<=n;i++)if(a[i]!=0)return 0*printf("No\n");
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

fn main() {
    let k:i32 = read();
    let x:i32 = read();

    for i in 0..1+(k-1)*2 {
        print!("{} ", x-k+1+i);
    }
    println!("");
    
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

using R = long double;
constexpr R pi = acos((R)-1), eps = 1e-10;

int sgn(R a) { return (a > eps) - (a < -eps); }
int sgn(R a, R b) { return sgn(a - b); }
using P = complex<R>;
istream& operator>>(istream& i, P& p) { R x, y; i >> x >> y; p = P(x, y); return i; }
ostream& operator<<(ostream& o, P p) { return o << fixed << setprecision(15) << real(p) << ' ' << imag(p); }
bool cmp(P p, P q) { return 2 * sgn(real(p), real(q)) + sgn(imag(p), imag(q)) < 0; }
bool eql(P p, P q) { return !cmp(p, q) and !cmp(q, p); }
R dot(P p, P q) { return real(conj(p) * q); }
R crs(P p, P q) { return imag(conj(p) * q); }
// -2: back, -1: cw, 0: on, 1: ccw, 2: front
int ccw(P p, P q) {
  int s = sgn(crs(p, q));
  if (s) return s;
  if (dot(p, q) < 0) return -2;
  if (dot(p, q - p) > 0) return 2;
  return 0;
}
int ccw(P o, P p, P q) { return ccw(p - o, q - o); }
struct L {
  P s, t;
  P vec() const { return t - s; }
  R abs() const { return std::abs(vec()); }
  R arg() const { return std::arg(vec()); }
};
int ccw(L s, P p) { return ccw(s.s, s.t, p); }

P proj(P p, L l) {
  P e = l.vec() / l.abs();
  return l.s + dot(p - l.s, e) * e;
}
P refl(P p, L l) { return (R)2 * proj(p, l) - p; }
R distPP(P p, P q) { return abs(q - p); }
R distPL(P p, L l) { return distPP(p, proj(p, l)); }
R distPS(P p, L s) {
  P q = proj(p, s);
  if (!ccw(s, q)) return distPP(p, q);
  return min(distPP(p, s.s), distPP(p, s.t));
}
R distLL(L l, L m) {
  if (sgn(crs(l.vec(), m.vec()))) return 0;
  return distPL(l.s, m);
}
R distLS(L l, L s) {
  if (ccw(l, s.s) * ccw(l, s.t) != 1) return 0;
  return min(distPL(s.s, l), distPL(s.t, l));
}
R distSS(L s, L t) {
  if (ccw(s, t.s) * ccw(s, t.t) <= 0 and ccw(t, s.s) * ccw(t, s.t) <= 0) return 0;
  return min({distPS(s.s, t), distPS(s.t, t), distPS(t.s, s), distPS(t.t, s)});
}
P intxn(L l, L m) {
  assert(sgn(crs(l.vec(), m.vec())));
  return l.s + crs(m.s - l.s, m.vec()) / crs(l.vec(), m.vec()) * l.vec();
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    V<P> ps(n);
    for (auto&& e : ps) {
      int x, y; cin >> x >> y;
      e = P(x + 2000, y + 2000);
    }
    int res = 0;
    for (int x = 0; x < 4000; ++x) {
      V<R> l, r;
      for (int i = 0; i < n; ++i) {
        P p = ps[i], q = ps[(i + 1) % n];
        if (cmp(q, p)) swap(p, q);
        if (sgn(real(q), x) <= 0 or sgn(real(p), x + 1) >= 0) continue;
        l.push_back(imag(intxn({p, q}, {P(x, 0), P(x, 1)})));
        r.push_back(imag(intxn({p, q}, {P(x + 1, 0), P(x + 1, 1)})));
      }
      sort(begin(l), end(l));
      sort(begin(r), end(r));
      int m = l.size();
      assert((int)r.size() == m and ~m & 1);
      bitset<4000> bs;
      for (int j = 0; j < m; j += 2) {
        int a = min(l[j], r[j]) + eps;
        int b = max(l[j + 1], r[j + 1]) + 1 - eps;
        for (int k = a; k < b; ++k) bs[k] = true;
      }
      res += bs.count();
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll N,M;
  cin >> N >> M;
  pair<ll,ll> p[N];
  for(int i=0;i<N;i++) cin >> p[i].first >> p[i].second;
  sort(p,p+N);

  ll yensum = 0LL;
  ll sum = 0LL;

  for(int i=0;i<N;i++){
    if(M-sum >= p[i].second){
      yensum += p[i].first * p[i].second;
      sum += p[i].second;
    }
    else if(M-sum < p[i].second){
      yensum += p[i].first * (M-sum);
      break;
    }
  }

  cout << yensum << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define M 1000000007
#define ll long long
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll t{0};
	cin>>t;
	ll c0{0};
	ll c1{0};
	ll c2{0};
	ll c3{0};
	while(t--){
		string str;
		cin>>str;
		if(str=="AC")
			c0++;
		else if(str=="WA")
			c1++;
		else if(str=="TLE")
			c2++;
		else
			c3++;
	}
	cout<<"AC x "<<c0<<endl;
	cout<<"WA x "<<c1<<endl;
	cout<<"TLE x "<<c2<<endl;
	cout<<"RE x "<<c3<<endl;
	return 0;
}



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

int main() {
  int n, d[110];

  cin >> n;
  for (int i = 0; i < n; i++) cin >> d[i];

  sort(d, d+n);

  int prev = d[0];
  int ans = 1;
  for (int i = 0; i < n; i++) {
    if (d[i] != prev) ans++;
    prev = d[i];
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int ans[] = new int[n];
		

		for(int j=1;j<=100;j++) {
			for(int k=1;k<=100;k++) {
				for(int l=1;l<=100;l++) {
					int oppai =  (int)Math.pow(j, 2)+(int)Math.pow(k, 2)+(int)Math.pow(l, 2)+j*k+k*l+l*j;
					if(oppai <= n) {
						ans[oppai-1] ++;
					}
				}
			}
		}
		
		for(int i=0;i<n;i++) {
			System.out.println(ans[i]);
		}
		
			

		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 


Measured memory_bytes: 39280
#include <iostream>

using namespace std;

int main()
{
    int i, a, b, c, x;
    cin >> a >> b >> c;
    x = 0;
    for(i=a; i<=b; i++)
    {
        if(c%i == 0)    
            x = x + 1;
    }
    cout << x << endl;
}


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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

#define F first
#define S second

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

	LL cnt = 0;

	for (LL i = 1; i < n; ++i) {
		LL poss = n/i;
		cnt += poss;
		if (n%i == 0) cnt--;
	}
	cout << cnt << "\n";
}

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

int main(){
    string s;

    while(cin>>s){
        if(s[0]=='0') break;

        int sum=0;
        int len=s.size();
        for(int i=0; i<len; i++){
            sum+=s[i]-'0';
        }
        printf("%d\n",sum);
    }

    return 0;
}



Measured memory_bytes: 3352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

    using namespace std;

    int main(){     
      ll n;
      cin >> n;
      ll a[n];
      rep(i,n)cin >> a[i];
      sort(a,a+n);
      ll ans2=a[0];
      if(a[n-1]%2==0){
        rep(i,n){
         if(abs(a[n-1]/2-a[i])<abs(a[n-1]/2-ans2)){
          ans2=a[i]; 
         }
        }
      }else{
       rep(i,n){
        if(min(abs(a[n-1]/2-a[i]),abs(a[n-1]/2+1-a[i]))<min(abs(a[n-1]/2-ans2),abs(a[n-1]/2+1-ans2))){
          ans2=a[i];
        }
       }
      }
      cout << a[n-1] << ' ' << ans2 << endl;
      return 0;}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int W,a,b;

int main(){
    cin>>W>>a>>b;
    out(max(0,abs(b-a)-W));
}


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

int n, l;

int main(int argc, char *argv[])
{
    cin >> n >> l;
    int sum = (l + l + n - 1) * n / 2;
    if (l >= 0)
    {
        cout << sum - l << endl;
    }
    else
    {
        cout << sum - min(0, l + n - 1);
    }
}

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

int main() {
	int N;
  int m=0;
    cin >> N;
    for(int i=0;i<15;i++){
      for(int j=0;j<26;j++){
        if((i*7+j*4)==N){
          m++;
        }
      }
    }
  if(m>0) cout << "Yes" << endl;
  else cout << "No" << endl;
          
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

ll f(ll b, ll n) {
    ll sum = 0;

    while (n >= b) {
        sum += n % b;
        n /= b;
    }

    sum += n;

    return sum;
}

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

    ll ans = -1;

    if (n == s) {
        ans = n + 1;
    }

    for (ll i = 2; i * i <= n; ++i) {
        if (f(i, n) == s) {
            ans = i;
            break;
        }
    }

    for (ll i = 1; i * i < n; ++i) {
        ll b = (n - s) / i + 1;

        if (b < 2) continue;
        if (f(b, n) == s && (ans == -1 || ans > b)) {
            ans = b;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256