akhauriyash/Code-Regression huggingface dataset:
#include <vector>
	#include <list>
	#include <map>
	#include <set>
	#include <queue>
	#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 <cstring>

	using namespace std;

	#define MAX 100000
	#define INF 2140000000
	#define MOD 1000000007

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

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

		long long ans = ceil(w / 2.0) * ceil(h / 2.0) + (w / 2) * (h / 2) ;
		cout << ans << endl;

		return 0;
	}

Measured memory_bytes: 256
steps = input()

i = 1
for step in steps:
    if i % 2 == 0:
        if step in ("L", "U", "D"):
            i = i + 1
            continue
        else:
            print("No")
            exit(0)
    else:
        if step in ("R", "U", "D"):
            i = i + 1
            continue
        else:
            print("No")
            exit(0)

print("Yes")

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




int main(){

  vector<int> v(32);
  v[0] = 1;
  v[1] = 1;
  v[2] = 1;
  v[3] = 2;
  v[4] = 1;
  v[5] = 2;
  v[6] = 1;
  v[7] = 5;
  v[8] = 2;
  v[9] = 2;
  v[10] = 1;
  v[11] = 5;
  v[12] = 1;
  v[13] = 2;
  v[14] = 1;
  v[15] = 14;
  v[16] = 1;
  v[17] = 5;
  v[18] = 1;
  v[19] = 5;
  v[20] = 2;
  v[21] = 2;
  v[22] = 1;
  v[23] = 15;
  v[24] = 2;
  v[25] = 2;
  v[26] = 5;
  v[27] = 4;
  v[28] = 1;
  v[29] = 4;
  v[30] = 1;
  v[31] = 51;
  
  int x;
  cin >> x;
  cout << v[x - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(8, 0);
    int B = 0;
    rep(i, N){
        int a;
        cin >> a;
        if(a < 3200){
            A[a / 400]++;
        }
        else{
            B++;
        }
    }
    int mi = 0;
    rep(i, 8){
        if(A[i] > 0) mi++;
    }
    cout << max(1, mi) << " " << mi + B << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
#define rush             ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll               long long int
#define FOR(a,x,n)       for(ll a=x;a<n;a++)
#define ROF(a,x,n)       for(ll a=x;a>=n;a--)
#define pb               push_back
#define lb               lower_bound
#define ub               upper_bound
#define MOD              1000000007

ll dp[100005];

ll ans(ll a[], ll n, ll index) {
       if(index == n-1) return 0;

       if(dp[index] != -1) return dp[index];
       
       ll left = abs(a[index] - a[index+1]) + ans(a, n, index+1);
       ll right = INT_MAX;

       if(index+2 < n) right = abs(a[index] - a[index+2]) + ans(a, n, index+2);

       return dp[index] = min(left, right);  
}

void solve() {
     ll n;
     cin >> n;

     memset(dp, -1, sizeof dp);

     ll a[n];
     FOR(i,0,n) cin >> a[i];

     cout << ans(a, n, 0);
}
 
int main() {
        rush
        solve();
}

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

int main(){
    int n,x,count;
    
    while(1){
        cin >> n >> x;
        if (n == 0 && x == 0) { break; }
        
        count = 0;
        for (int i = 1; i <= n; i++){
            for (int j = i + 1; j <= n; j++){
                for (int k = j + 1; k <= n; k++){
                    if (i+j+k == x){
                        count += 1;
                    }
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

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

using namespace std;

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

	
	vector<int> p(n);
	for(int i=1;i<=n;i++)
		for(int j=2;j<=i;j++)
		{
			int now=i;
			while(true)
			{
				if(now%j==0)p[j-1]++;
				else break;
				now/=j;
			}
		}

	vector<bool> pflag(n,true);
	for(int i=2;i<n;i++)
		for(int j=2;i*j<=n;j++)
			pflag[i*j-1]=false;

/*
	for(int i=0;i<n;i++)
		cout << i+1 << " " <<  (pflag[i] ? "yes":"no") << " " << p[i] <<  endl;
*/
	long long ans=1;
	for(int i=1;i<n;i++)
		if(pflag[i])ans=ans*(p[i]+1)%1000000007;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void print_array(const int* array, int num) {
	int i;
	for (i = 0; i < num; i++) {
		printf(" %d" + !i, array[i]);
	}
	putchar('\n');
}

int main(void) {
	int N;
	int A[128];
	int i, j;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	print_array(A, N);
	for (i = 1; i < N; i++) {
		int v = A[i];
		for (j = i - 1; j >= 0 && A[j] > v; j--) A[j + 1] = A[j];
		A[j + 1] = v;
		print_array(A, N);
	}
	return 0;
}




Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	long long N, a[200001], b[200001];
	cin >> N;
	for (i = 0; i < N; i++) { cin >> a[i]; a[i] = a[i] - i; }
sort(a,a+N);
	for (i = 0; i < N; i++) {
		ans += llabs(a[i] - a[N / 2]);
	}

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,sum=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        if(i%3==0||i%5==0)
        {
            continue;
        }
        else
        {
            sum+=i;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
cost = [0,2,5,5,4,5,6,3,7,6] 
dp = [-1]*(n+1)
dp[0] = 0

for i in range(2,n+1):
    for j in range(0,m):
        if i-cost[a[j]] <0:
            continue
        if dp[i-cost[a[j]]] == -1:
            continue
        else:
            dp[i] = max(dp[i],dp[i-cost[a[j]]]+1)

ans = list()
read = n
a.sort()
a.reverse()

while read > 0:
    for i in range(0,m):
        if read < cost[a[i]]:
            continue
        if dp[read-cost[a[i]]] == dp[read]-1:
            ans.append(str(a[i]))
            read -= cost[a[i]]
            break
    
print("".join(ans))

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n,m;cin>>n>>m;
  vi a(n);
  rep(i,n) cin>>a.at(i);
  int sum=0;
  rep(i,n) sum+=a.at(i);
  sort(all(a),greater<int>());
  if(a.at(m-1)*4*m>=sum){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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


int main()
{
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
}


Measured memory_bytes: 3556
# your code goes here
#rummy

T=int(input())
for i in range(T):
    n=[int(i) for i in input().split()]
    c=[i for i in input().split()]
    R=[[],[],[]]
    for i in range(9):
        if c[i]=="R":
            R[0].append(n[i])
        elif c[i]=="G":        
            R[1].append(n[i])
        else:
            R[2].append(n[i])
    y=1
    i=0
 #   print(R)
    while y>0 and i<3:
        l=len(R[i])
        if l%3!=0:
            y=0
        else:
            R[i].sort()
            s=l//3
            j=0
            while y>0 and s>0 and j<len(R[i])-2:
                if R[i][j]==R[i][j+1]:
                    if R[i][j+1]==R[i][j+2]:
                        for k in range(3):
                            R[i].pop(j)
                        s-=1
                    elif R[i][j+1]+1==R[i][j+2]:
                        k=j+3
                        while k<len(R[i]) and R[i][k]==R[i][j+2]:
                            k+=1
                        if k>=len(R[i]) or R[i][k]!=R[i][j+2]+1:
                            y=0
                        else:
                            R[i].pop(k)
                            R[i].pop(j+2)
                            R[i].pop(j)
                        s-=1
                    else:
                        y=0
                elif R[i][j]+1==R[i][j+1]:
                    k=j+2
                    while k<len(R[i]) and R[i][k]==R[i][j+1]:
                        k+=1
                    if k>=len(R[i]) or R[i][k]!=R[i][j+1]+1:
                        y=0
                    else:
                        R[i].pop(k)
                        R[i].pop(j+1)
                        R[i].pop(j)
                        s-=1
                else:
                    y=0
        i+=1
    print(y)

Measured memory_bytes: 7744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++)
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)



void reset()
{
}

void input()
{
	bool x;
	cin>>x;
	cout<<(x^1)<<endl;
}

void solve()
{
}

void LetsRock()
{
	solve();
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
		reset();
		input();
		LetsRock();
	
	return 0;
}

Measured memory_bytes: 3648
from itertools import permutations

n,m,r=map(int,input().split())
*R,=map(int,input().split())
INF=float("inf")
dist=[[INF]*n for _ in range(n)]
for i in range(n):
	dist[i][i]=0
for _ in range(m):
	a,b,c=map(int,input().split())
	dist[a-1][b-1]=c
	dist[b-1][a-1]=c
for k in range(n):
	for i in range(n):
		for j in range(n):
			dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])
v=[]
for i in R:
	t=[]
	for j in R:
		t.append(dist[i-1][j-1])
	v.append(t)
mn=INF
for t in permutations(range(r)):
	a=0;f=1
	for i,j in zip(t,t[1:]):
		if v[i][j]==INF:
			f=0
			break
		else:
			a+=v[i][j]
	if f:
		mn=min(mn,a)
print(mn)

Measured memory_bytes: 72408
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int ans=0;
    for(int i=0;i<n/2;i++){
if(s[i]!=s[n-i-1])ans++;
}
        cout<<ans;
}

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

int main() {
  int N; cin >> N;
  // key is number of people. value is i.
  map<int, int> student;
  rep(i,N) {
    int n;
    cin >> n;
    n--;
    student[n] = i+1;
  }

  rep(i,N) {
    cout << student[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    string s;

    cin >> s;

    for (int i = 0; i < s.size(); i+=2) cout << s[i];

    return 0;
}



Measured memory_bytes: 592
#include<stdio.h>

long gcd(long a,long b){
 long i;
 if(a<b){ i=a; a=b; b=i; }
 for(i=a%b;i!=0;i=a%b){
  a=b;
  b=i;
 }
 return b;
}
int main(){
 long a,b,gc;

 while(scanf("%ld %ld",&a,&b)!=EOF){
  gc=gcd(a,b);
  printf("%ld ",gc);
  if(a%gc==0) printf("%ld\n",(a/gc)*b);
  else if(b%gc==0) printf("%ld\n",(b/gc)*a);
  else printf("%ld\n",b*a/gc);
 }
 return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main(){
	
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	
	string a;
	
	cin >> a;
	
	if(a=="Sunny"){
		cout << "Cloudy" << endl;
	}else if(a=="Cloudy"){
		cout << "Rainy" << endl;
	}else{
		cout << "Sunny" << endl;
	}
	
return 0;
}


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

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Map<Long, Long> freqMap = new HashMap<>();
      freqMap.put(1 + sc.nextLong(), 1L);
      long cnt = 0L;
      for(int i = 2; i <= n; i++) {
        long num = sc.nextInt();
        cnt += freqMap.getOrDefault(i - num, 0L);
        freqMap.put(i + num, freqMap.getOrDefault(i + num, 0L) + 1);
      }

      System.out.println(cnt);
  }
}

Measured memory_bytes: 61952
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
 int a;
 cin>>a;
 vector <int> vec(a-1);
 rep(i,a-1){
   cin>>vec[i];
 }
  vector <int> v(a);
  rep(j,a-1){
   v[vec[j]-1]++;
  }
  rep(k,a){
    cout<<v[k]<<endl;
  }
}


Measured memory_bytes: 6372
n = int(input())
l = list(map(int,input().split()))
ans = [0]
cnt = 0
for i in range(n-1):
  if l[i] >= l[i+1]:
    cnt += 1
  else:
    if cnt > 0:
      ans.append(cnt)
    cnt = 0

ans.append(cnt)
print(max(ans))

Measured memory_bytes: 20492
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>

using namespace std;
using ll = long long;

const ll INF = 1e+19;

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

    vector<ll> x(N);
    vector<ll> y(N);

    vector<ll> x_sorted(N);
    vector<ll> y_sorted(N);

    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
        x_sorted[i] = x[i];
        y_sorted[i] = y[i];
    }

    sort(begin(x_sorted), end(x_sorted));
    sort(begin(y_sorted), end(y_sorted));

    ll ans = (x_sorted[N-1] - x_sorted[0]) * (y_sorted[N-1] - y_sorted[0]);

    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            for (int k = 0; k < N; ++k) {
                for (int l = k + 1; l < N; ++l) {
                    ll lx = x_sorted[i];
                    ll rx = x_sorted[j];

                    ll by = y_sorted[k];
                    ll uy = y_sorted[l];

                    int num = 0;

                    for (int m = 0; m < N; ++m) {
                        if (lx <= x[m] && x[m] <= rx && by <= y[m] && y[m] <= uy) {
                            ++num;
                        }
                    }

                    if (num >= K) {
                        ans = min(ans, (rx - lx) * (uy - by));
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int nmax=300000;

bool isprime[nmax+10];

void init(){
	rep(i,nmax+10) isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(int i=2;i*i<=nmax;i++)
		if(isprime[i])
			for(int j=i*i;j<=nmax;j+=i)
				isprime[j]=false;
	return ;
}

int main(void){
	init();
	int n,p;
	while(cin >> n >> p ){
		if(n==-1&&p==-1)
			break;
			
		vi a,b;
		
		int f=0;
		for(int i=n+1;f<p;i++){
			if(isprime[i]){
				a.pb(i);
				f++;
			}
		}
		
		int na=a.size();
		rep(i,na){
			for(int j=i;j<na;j++){
				int sum=a[i]+a[j];
				b.pb(sum);
			}
		}
		sort(b.begin(),b.end());
		cout << b[p-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1568
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int c = sc.nextInt();
		String s = sc.next();
		
		// 計算
		long result = 0;
		int[] forward = new int[n];
		int[] backward = new int[n];
		int cnt = 0;
		for(int i = 0; i < n; i++){
		    if(cnt == k) break;
		    if(s.charAt(i) == 'o'){
		        cnt++;
		        forward[i] = cnt;
		        i += c;
		    }
		}
		cnt = 0;
		for(int i = 0; i < n; i++){
		    if(cnt == k) break;
		    if(s.charAt(n-i-1) == 'o'){
		        cnt++;
		        backward[n-i-1] = k+1 - cnt;
		        i += c;
		    }
		}
		//System.out.println(Arrays.toString(forward));
		//System.out.println(Arrays.toString(backward));

		// 出力
		for(int i = 0; i < n; i++){
		    if(forward[i] != 0 && forward[i] == backward[i]) System.out.println(i+1);
		}
	}
}



Measured memory_bytes: 50880
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var q = int.Parse(line[1]);
        var s = long.Parse(line[2]);
        var t = long.Parse(line[3]);
        var a = new long[n + 1];
        var ap = long.Parse(Console.ReadLine().Trim());
        for (int i = 1; i <= n; i++)
        {
            var w = long.Parse(Console.ReadLine().Trim());
            a[i] = w - ap;
            ap = w;
        }
        var ht = getT(a, s, t);
        for (int i = 0; i < q; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var L = int.Parse(line[0]);
            var r = int.Parse(line[1]);
            var x = long.Parse(line[2]);
            var ret = getAnswer(a, s, t, L, r, x);
            //Console.WriteLine("ret = {0}" , ret);
            Console.WriteLine(ret + ht);
            ht += ret;
        }
    }
    public static long getT(long[] a, long s, long t)
    {
        var pt = 0L; var mt = 0L;
        for (int i = 0; i < a.Length; i++)
            if (a[i] > 0) pt += a[i];
            else mt += a[i];
        return -pt * s - mt * t;
    }
    public static long getAnswer(long[] a, long s, long t, int L, int r, long x)
    {
        var ret = 0L;
        if (r == a.Length - 1)
        {
            ret -= getDt(a[L], s, t);
            a[L] += x;
            ret += getDt(a[L], s, t);
            return ret;
        }
        else
        {
            ret -= getDt(a[L], s, t);
            ret -= getDt(a[r + 1], s, t);
            a[L] += x;
            ret += getDt(a[L], s, t);
            a[r + 1] -= x;
            ret += getDt(a[r + 1], s, t);
            return ret;
        }
    }
    public static long getDt(long targ, long s, long t)
    {
        if (targ > 0) return -targ * s;
        else return -targ * t;
    }
}



Measured memory_bytes: 12464
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> ah(h, 0), aw(w, 0);
    vector<int> mh, mw;
    mh.reserve(h);mw.reserve(w);
    set<pair<int,int>> s;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;y--;
        ah[x]++;aw[y]++;
        s.insert(make_pair(x, y));
    }
    int mmh = 0;
    for (int i = 0; i < h; i++) {
        if (ah[i] > mmh) {
            mmh = ah[i];
        }
    }
    // cout << 'h';
    for (int i = 0; i < h; i++) {
        if (ah[i] == mmh) {
            mh.push_back(i);
            // cout << i << ' ';
        }
    }
    // cout << endl;
    // cout << 'w';
    int mmw = 0;
    for (int i = 0; i < w; i++) {
        if (aw[i] > mmw) {
            mmw = aw[i];
        }
    }
    for (int i = 0; i < w; i++) {
        if (aw[i] == mmw) {
            mw.push_back(i);
            // cout << i << ' ';
        }
    }
    // cout << endl;
    bool ok = false;
    for (auto i: mh) {
        for(auto j: mw) {
            if (s.find(make_pair(i, j)) == s.end()) {
                // cout << "found " << i << ' ' << j << endl;
                ok = true;
                break;
            }
        }
        if (ok) {
            break;
        }
    }
    // cout << ok << " " << mmh << " " << mmw << endl;
    if (ok) {
        cout << mmh + mmw << endl;
    } else {
        cout << mmh + mmw - 1 << endl;
    }
}


Measured memory_bytes: 21832
import collections

n=int(input())

s=[]
for i in range(n):
    s.append(str(input()))

scount=collections.Counter(s)
#print(scount[1][1])
maxc=scount.most_common()[0][1]
#print(maxc)
ans=[]
for k, v in scount.items():
    if v==maxc:
        ans.append(k)


ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 45032
from math import sqrt
def isprime(inlst, i, sq):
    while sq >= i:
    	inlst = [x for x in inlst if x%i > 0 or x == i]
    	i += 2
    return inlst
n = int(input())
inlst = []
for i in range(n):
    inlst.append(int(input()))
inlst = [x for x in inlst if x%2 > 0 or x == 2]
i = 3
maxin = max(inlst)
inlst = isprime(inlst, i, int(sqrt(maxin)) + 1)
print(len(inlst))

Measured memory_bytes: 8084
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>

using namespace std;

void find_primes(vector<int> &primes, int n) {
  vector<int> is_primes(n + 1, 1);
  is_primes[0] = 0;
  is_primes[1] = 0;
  for (int k = 2; k <= n; k++) {
    if (is_primes[k]) {
      for (int l = 2 * k; l <= n; l += k) {
        is_primes[l] = 0;
      }
    }
  }

  for (int k = 2; k <= n; k++) {
    if (is_primes[k]) {
      primes.push_back(k);
    }
  }
}

int main(int argc, char *argv[]) {
  // read inputs
  int N;
  scanf("%d", &N);

  // get list of primes
  vector<int> primes;
  find_primes(primes, 55 * 55555);

  // select primes where p % 5 == 1
  for (int prime : primes) {
    if (prime % 5 == 1) {
      printf("%d ", prime);
      N--;
    }
    if (N == 0) {
      break;
    }
  }
  printf("\n");

  return 0;
}


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

int main(){
  char b;
  cin >> b;

  if(b == 'A')
    cout << "T" << endl;
  else if(b == 'C')
    cout << "G" << endl;
  else if(b == 'G')
    cout << "C" << endl;
  else
    cout << "A" << endl;

  return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
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;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n, m;
	while(cin >> n >> m) {
		vector<vector<int>> dp(n,vector<int>(n,INF));
		REP(i,m){
			int a,b,c;
			cin >> a >> b >> c;
			a--; b--;
			dp[a][b] = c;
			dp[b][a] = c;
		}
		REP(i,n) dp[i][i] = 0;
		using vi = vector<int>;
		// vector<vector<vi>> memo(n,vector<vi>(n,vi(n)));
		vector<vector<int>> memo(n,vector<int>(n,-1));
		REP(k,n) REP(i,n) REP(j,n){
			if(chmin(dp[i][j],dp[i][k]+dp[k][j])){
				memo[i][j] = k;
			}
		}
		int ans = 0;
		REP(i,n) REP(j,n){
			if(memo[i][j] == -1){
				ans++;
			}
		}
		cout << m-(ans-n)/2 << endl;
	}
	return 0;
}


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

std::string printCases(int num, int* pCount);

int main()
{
	int count = 0;

	while (true)
	{
		int num;
		std::cin >> num;

		if (num == 0)
		{
			break;
		}

		std::string output = printCases(num, &count);

		std::cout << output << std::endl;
	}
	return 0;
}

std::string printCases(int num, int* pCount)
{
	(*pCount)++;

	std::string ans = "Case " + std::to_string(*pCount) + ": " + std::to_string(num);

	return ans;
}


Measured memory_bytes: 3192
X = int(input())

def is_prime(x):
  if x == 1:
    return False
  for i in range(2,int(x**0.5)+1):
    if x % i == 0:
      return False
  return True

for x in range(X,X*10):
  if is_prime(x):
    print(x)
    exit()


Measured memory_bytes: 38384
import sys



def solve(n):
    #print(n)
    NCHARS = int(26)
    MAXVAL = NCHARS
    ndigs = 1
    while n > MAXVAL:
        ndigs += 1
        n -= MAXVAL
        MAXVAL *=  NCHARS
    # now have # digs
    #print(n,ndigs,MAXVAL)
    n -= 1
    result = ''
    while n > 0:
        #print(n,MAXVAL,NCHARS)
        #MAXVAL //= NCHARS
        result += chr(n%NCHARS + ord('a'))
        n //= NCHARS
        #d = n // MAXVAL
        #d = n // MAXVAL
        #print(n,MAXVAL,result)
    if len(result) < ndigs:
        result += ''.join(['a' for i in range(ndigs-len(result))])
    print(''.join([c for c in result][::-1]))
        

        


if __name__ == '__main__':
    IN = [x.strip() for x in sys.stdin.readlines()]

    n = int(IN[0])
    solve(n)


Measured memory_bytes: 61956
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
        FastIO

        int x,y,a,b,c,i,j,k,extra=0;
        ll sum=0;
        cin>>x>>y>>a>>b>>c;
        vi p(a),q(b),r(c);
        for(i=0;i<a;i++)
        	cin>>p[i];
        for(i=0;i<b;i++) cin>>q[i];

        for(i=0;i<c;i++) cin>>r[i];

        sort(p.begin(),p.end());
    	sort(q.begin(),q.end());
    	sort(r.begin(),r.end());
    	if(a<=x)
        	extra= x-a;
        if(b<=y)
        	extra+=y-b;

        for(i=a-1;i>=max(0, a-x);i--)
        {
        	sum+=p[i];
        }
        for(i=b-1;i>=max(0, b-y);i--)
        {
        	sum+=q[i];
        }

        for(i=c-1;i>=max(0, c- extra );i--)
        {
        	sum+= r[i];
        }
        k=max(0,a-x);
        j=max(0,b-y);

        for(i= c-1-extra;i>=0;i--)
        {
        	if((k<=a-1 && r[i] >=p[k]) )
        	{
        		if(j>=b ||(j<=b-1 && p[k]<q[j]))
        		{
        			sum-=p[k];
        			sum+=r[i];
        			k++;
        		}
        		else
        		{
        			sum-=q[j];
        			sum+=r[i];
        			j++;
        		}
        	}
        	else if(j<=b-1 && r[i]>=q[j])
        	{
        			sum-=q[j];
        			sum+=r[i];
        			j++;
        	}
        	else
        	{
        		break;
        	}
        }

        cout<<sum;
        return 0;
    }

Measured memory_bytes: 1408
import math

N = int(input())
N2 = int(math.sqrt(N))
ans = 0
for i in range(1, N2 + 1):
    j = int(N/i)
    if (i * j == N):
#        print(i,j)
        ans = i + j - 2
#    else:
#        print(i,j)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  string S;
  cin>>S;
  
  for(int i=0; i<S.size()-8; ++i) cout<<S.at(i);
  cout<<endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
//No change above here

const ll maxi = 2 * 1e5 + 5;
ll mod = 5;
double pi = 3.141592653589793238;

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret = 0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

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

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

ll max_subarray(vector<int>& v)
{
	if (v.empty())
		return 0;
	ll glob = v[0], loc = v[0];
	for (int i = 1; i < v.size(); ++i)
	{
		loc = max(v[i] + 0LL, loc + v[i]);
		glob = max(loc, glob);
	}
	return glob;
}

long long num_digits(long long x)
{
	long long ans = 0;
	while (x)
	{
		++ans;
		x /= 10;
	}
	return ans == 0 ? 1 : ans;
}

vector<int> topological_sort(vector<vector<int>>& graph, int n, vector<int>& indegree)
{
	vector<int> ans;
	stack<int> s;
	for (int i = 0; i < n; ++i)
		if (indegree[i] == 0)
			s.push(i);
	while (!s.empty())
	{
		int x = s.top();
		s.pop();
		ans.push_back(x);
		for (auto& adj : graph[x])
			if (--indegree[adj] == 0)
				s.push(adj);
	}
	return ans;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }


//declare needed things here


int main()
{
	IOS;
	ll d, t, s;
	cin >> d >> t >> s;
	if (t * s >= d)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3648
import java.io.*;
import java.util.*;


class ProgrammingTestDataSet{
	int[] score;
	ProgrammingTestDataSet(int numPersons){
		score = new int[numPersons];
	}
	public void readScore(Scanner scan){
		for(int i=0; i < score.length; i++)
			this.score[i] = scan.nextInt();
	}
	public double StandardDeviation(){
		double mean = calcMean();
		double result = 0.0;
		for(int i=0; i<score.length; i++)
			result += Math.pow(score[i] - mean, 2);
		result /= score.length;
		return Math.pow(result, 0.5);
	}
	double calcMean(){
		double result = 0.0;
		for(int i=0; i<score.length; i++)
			result += score[i];
		return result /= score.length;
	}
}
public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int scannedInt;
		while(true){
			scannedInt = scan.nextInt();
			if(scannedInt==0)
				return;
			ProgrammingTestDataSet dataset = new ProgrammingTestDataSet(scannedInt);
			dataset.readScore(scan);
			System.out.println(dataset.StandardDeviation());
			scan.nextLine();
		}
	}
}

Measured memory_bytes: 24896
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
	LL n;
	cin >> n;
	for (LL i = 1; i <= 3500; i++) {
		for (LL j = 1; j <= 3500; j++) {
			if ((4 * i*j - n*i - n*j) == 0) continue;
			if ((i*j*n) % (4 * i*j - n*i - n*j) == 0 && 0 < (i*j*n) / (4 * i*j - n*i - n*j)) {
				cout << i << " " << j << " " << (i*j*n) / (4 * i*j - n*i - n*j) << endl;
				return 0;
			}
		}
	}
}

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

vector<long long> memory;

long long ryuka(int x) {
  if (memory[x] != -1) {
    return memory[x];
  }

  if (x == 0) {
    return 2;
  }
  if (x == 1) {
    return 1;
  }
  memory[x] = ryuka(x - 1) + ryuka(x - 2);
  return memory[x];
}

int main() {
  int N;
  cin >> N;
  memory = vector<long long>(N + 1, -1);
  cout << ryuka(N) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<ctime>
using namespace std;

const int N=370;
const int M=30;

int D,ans,T,d,q,start;
int s[N][M],lst[M],c[M],t[N],cnt[N][M];

bool time_out(){
	return clock()-start>1900;
}

int calc(){
	int sum=0;
	for (int i=1;i<=26;i++) lst[i]=0;
	for (int i=1;i<=D;i++){
		sum+=s[i][t[i]];
		lst[t[i]]=i;
		for (int j=1;j<=26;j++) sum-=c[j]*(i-lst[j]);
	}
	return sum;
}

int argmx(int d){
	int id=1;
	for (int i=2;i<=26;i++)
		if (s[d][i]>s[d][id]) id=i;
	return id;
}

int main(){
	scanf("%d",&D);
	for (int i=1;i<=26;i++) scanf("%d",&c[i]);
	for (int i=1;i<=D;i++)
		for (int j=1;j<=26;j++) scanf("%d",&s[i][j]);
	for (int i=1;i<=D;i++) t[i]=argmx(i);
	ans=calc();
	srand(time(0));
	start=clock();
	while (!time_out()){
		int sum,tmp;
		for (int d=1;d<=D;d++){
			for (int q=1;q<=26;q++){
				tmp=t[d];
				t[d]=q; sum=calc();
				if (sum>ans) ans=sum;
				else t[d]=tmp;
			}
			if (time_out()) break;
		}
	}
	for (int i=1;i<=D;i++) printf("%d\n",t[i]);
	return 0;
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int dp[100300];

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

  dp[0] = 1;
  rep(i,100300) {
    for (int j = 100; j <= 105; ++j) {
      if (i-j < 0) continue;
      if (dp[i-j] == 0) continue;
      dp[i] = dp[i-j];
    }
  }
  //debug(x);
  cout << dp[x] << endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
typedef long long ll;
int main()
{
	ll r,d;
	ll X[11];
	scanf("%lld %lld %lld",&r,&d,&X[0]);
	for(ll i=1;i<11;i++)
	{
		X[i] = r*X[i-1] - d;
	}
	for(ll i =1;i<11;i++)
	{
		printf("%lld\n",X[i]);
	}
	return 0;
}



Measured memory_bytes: 128
#f_listとf_r_listの要素数は状況に応じて変えよう

MOD = 10**9 + 7
list_size = 2000003

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

def f(x, y):
	if x * y == 0:
		return 0
	elif x == 1:
		return y * (y+3) // 2
	else:
		return comb(x+y+2, x+1) - x - y - 2


r1, c1, r2, c2 = list(map(int, input().split()))
ans = (f(r2, c2) + f(r1-1, c1-1) - f(r1-1, c2) - f(r2, c1-1)) % MOD
print(ans)

Measured memory_bytes: 161268
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
vector<int> ans;
//function for dp
int frog1(int i)
{
    int p1 = abs(v[i+1]-v[i])+ans[i+1];
    int p2 = abs(v[i+2]-v[i])+ans[i+2];
    ans[i] = min(p1,p2);
}
int main()
{
    int n ;
    cin >> n;
    ans.resize(n+1);
    for(int i=0;i<n;i++)
    {
        int k;cin>>k;
        v.push_back(k);
    }
    // assign base case values
    ans[n-1] = 0;
    ans[n-2] = abs(v[n-1] - v[n-2]);

    for(int j=n-3;j>=0;j--)
    {
        frog1(j);
    }
    cout << ans[0]<<"\n";

}

Measured memory_bytes: 1276
//#include"stdc++.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define cases ll t;cin>>t;while(t--)
#define f1(a,n) for(int i=a;i<n;i++)
#define f2(b,n) for(int j=b;j<n;j++)
#define INF 1000000000000009
#define pb push_back
ll ar[100005];
#define MAX 1000005
int main() {
    fast
    ll n;
    cin>>n;
    ll ar[n];
    f1(0,n)
        cin>>ar[i];
    ll dp[n+1];
    dp[0]=0;
    dp[1]=llabs(ar[1]-ar[0]);
    f1(2,n)
    {
        ll temp=dp[i-1]+llabs(ar[i]-ar[i-1]);
        dp[i]=min(temp,dp[i-2]+llabs(ar[i]-ar[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b,c;
    cin >> a >> b >> c;
    int d=a+b+c;
    int m=max({a,b,c});
    if(d&1){
        if(m&1){
            print((m*3-d)/2);
        }
        else{
            print(((m+1)*3-d)/2);
        }
    }else{
        if(m&1){
            print(((m+1)*3-d)/2);
        }else{
            print((m*3-d)/2);
        }
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define name(x) #x
using namespace std;


const int INF = INT_MAX-100;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int N;
    cin >> N;
    vector<int> h(N+1);
    for(auto i = 1; i <= N; i++){
        cin >> h[i] ;
    }
    
    vector<int> dp(N+1);
    //残りNステップ
    
    dp[N] = 0;
    dp[N-1] = abs(h[N]-h[N-1]);

    for(auto i = N-2; i>=1; i--){
        
        dp[i] = min(dp[i+1]+abs(h[i]-h[i+1]), dp[i+2]+abs(h[i]-h[i+2]));
        
        
    }
    
    cout << dp[1] << endl;

    return 0;
}




Measured memory_bytes: 1024
a, b = map(int,input().split())
if (a <= 0 and b>= 0) or a==0 or b == 0:
  print('Zero')
elif a < 0 and b < 0 :
  if abs(a - b +1) % 2 == 0:
    print('Positive')
  else:
    print('Negative')
else:
  print('Positive')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,0,n) cin>>a[i];
    rep(i,0,n) a[i]-=(i+1);
    sort(all(a));
    if(n%2==0){
        ll med1=a[n/2];
        ll med2=a[n/2-1];
        ll sum1=0,sum2=0;
        rep(i,0,n){
            sum1+=abs(a[i]-med1);
            sum2+=abs(a[i]-med2);
        }
        cout<<min(sum1,sum2)<<endl;
        return 0;
    }else{
        ll med=a[(n-1)/2];
        ll sum=0;
        rep(i,0,n){
            sum+=abs(a[i]-med);
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
	
	int k, s, x, y, z, ans;
	ans = 0;

	cin >> k >> s;

	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - (x + y);

			if (0 <= z&&z <= k) {
				ans++;
			}
		}

		
	}
	cout << ans << endl;

	return 0;
}


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

typedef long long int64;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SZ(c) ((int)(c).size())

const int MAXN = 1 << 17;

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

  int N, K; cin >> N >> K;

  auto cnt = array<int, 20>();

  for (int i = 1; i <= N; ++i) {
    int x = i;
    int c = 0;
    while (x < K) {
      x *= 2;
      c++;
    }
    cnt[c]++;
  }

  double p = 1;
  double ans = 0;
  for (int i = 0; i < 20; ++i) {
    ans += cnt[i] * p;
    p *= 0.5;
  }

  printf("%.15lf\n", ans / N);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
using P = pair<int,int>;

int main(){
	int X,N;
	cin >> X >> N;
	vector<int> d(102);
	for(int i=0;i < N;++i){
		int p;
		cin >> p;
		d[p] = 1;
	}

	P ans(99999,-1);

	for(int i=0;i <= 101;++i){
		if(d[i] == 1) continue;
		int dif = abs(X - i);
		ans = min(ans,P(dif,i));
	}
	cout << ans.second << endl;
	return 0;
}


Measured memory_bytes: 3156
use std::collections::HashMap;

fn main() {
  
  let n = read::<i64>()[0];
  let a = read::<i64>();
  
  let mut cnts: HashMap<i64, i64> = HashMap::new();
  for x in a {
    if let Some(c) = cnts.get(&x) {
      cnts.insert(x, c+1);
    } else {
      cnts.insert(x, 1);
    }
  }
  let mut sum = 0;
  for (i, c) in cnts.iter() {
    if *c < *i {
      sum += *c
    } else {
      sum += *c - *i;
    }
  }
  println!("{}", sum);
  
}

fn read<T: std::str::FromStr>() -> Vec<T> {
  gets().split_whitespace().filter_map(|s|s.parse().ok()).collect()
}

fn gets() -> String {
  let mut line = String::new();
  std::io::stdin().read_line(&mut line).ok();
  line.trim().to_string()
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,k;cin>>n>>k;
  if(k==1)cout<<0<<endl;
  else
  cout<<max(buf4,n-k)<<endl;
  

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main() {
	string s;
	cin >> s;
	if (s[0] == '1') {
		s[0] = '9';
	}
	else {
		s[0] = '1';
	}
	if (s[1] == '1') {
		s[1] = '9';
	}
	else {
		s[1] = '1';
	}
	if (s[2] == '1') {
		s[2] = '9';
	}
	else {
		s[2] = '1';
	}
	cout << s;
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

Measured memory_bytes: 256