akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int k = sc.nextInt();
		for(int i = 0;i < k;i ++) {
			if(i % 2 == 0) {
				if(a % 2 != 0) {
					a--;
				}
				b += a/2;
				a = a/2;
			}else {
				if(b % 2 != 0) {
					b--;
				}
				a += b/2;
				b = b/2;
			}
		}
		System.out.println(a+" "+b);
	}
}

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

//Longest Common Prefix(s,s.substr(i)) O(|s|)
#include<vector>
vector<int>Zalgo(const string&s)
{
	vector<int>ret(s.size());
	ret[0]=s.size();
	int i=1,j=0;
	while(i<s.size())
	{
		while(i+j<s.size()&&s[j]==s[i+j])j++;
		ret[i]=j;
		if(j==0)
		{
			i++;
			continue;
		}
		int k=1;
		while(i+k<s.size()&&k+ret[k]<j)ret[i+k]=ret[k],k++;
		i+=k;j-=k;
	}
	return ret;
}
int N;
string s;
main()
{
	cin>>N>>s;
	int ans=0;
	for(int i=0;i<N;i++)
	{
		string t=s.substr(i);
		vector<int>A=Zalgo(t);
		for(int j=0;i+j<N;j++)
		{
			ans=max(ans,min(A[j],j));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<iostream>
int R,C,s[10000][10],f[10],N,i,j,n,m;void rec(int k){if(k<R){f[k]=0;rec(k+1);f[k]=1;rec(k+1);}else for(n=i=0;i<C;i++,n+=m>R-m?m:R-m,N=N>n?N:n)for(m=j=0;j<R;j++)m+=s[i][j]^f[j];}main(){for(;std::cin>>R>>C,R;rec(0),std::cout<<N<<"\n")for(j=R;j-->0;)for(i=C;i-->0;)std::cin>>s[i][j];}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll inv[3000000];
ll FactorialInv[3000000];
ll Factorial[3000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    Factorial[0] = 1;
    FactorialInv[0] = 1;
    inv[0] = 1;
    for(ll i = 2; i < 3000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(b < 0) return 0;
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

int main() {
    //cout.precision(10);
    init_combination();
    ll N, M, K;
    ll ans = 0;
    cin >> N >> M >> K;
    for(ll kn = 0; kn <= K; kn++) {
        ll km = K - kn;
        ll nowans = combination(N + M + 2 * K, N + 2 * kn);
        nowans *= combination(N + 2 * kn, kn) - combination(N + 2 * kn, kn - 1);
        nowans %= mod;
        nowans += mod;
        nowans %= mod;
        nowans *= combination(M + 2 * km, km) - combination(M + 2 * km, km - 1);
        nowans %= mod;
        nowans += mod;
        nowans %= mod;
        ans = (ans + nowans) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 73436
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  int bingo[3][3];
  FOR(i,0,2){
    FOR(j,0,2){
      cin >> bingo[i][j];
    }
  }
  int n; cin >> n;
  FOR(i,0,n-1){
    int input; cin >> input;
    FOR(j,0,2){
      FOR(k,0,2){
        if(bingo[j][k]==input) bingo[j][k]=-1;
      }
    }
  }

  FOR(i,0,2){
    int ref = 0;
    FOR(j,0,2){
      ref += bingo[i][j];
    }
    if(ref==-3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  FOR(j,0,2){
    int ref = 0;
    FOR(i,0,2){
      ref += bingo[i][j];
    }
    if(ref==-3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(bingo[0][0] + bingo[1][1] + bingo[2][2]==-3) cout << "Yes" << endl;
  else if(bingo[0][2] + bingo[1][1] + bingo[2][0]==-3) cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

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

    int n = 0;
    long long h = 0;
    long long a_max = 0;
    vector<int> b_list = {};

    cin >> n >> h;

    int i = 0;
    long long a = 0;
    long long b = 0;
    while (i < n && cin >> a >> b)
    {
        if (a > a_max)
        {
            a_max = a;
        }
        b_list.push_back(b);
        ++i;
    }

    long long cnt = 0;
    sort(b_list.begin(), b_list.end(), greater<int>());
    for (auto j = b_list.begin(); j != b_list.end(); ++j)
    {
        if (*j > a_max)
        {
            h -= *j;
            ++cnt;
        }

        if (h <= 0)
        {
            cout << cnt << endl;
            return 0;
        }
    }

    cnt += h / a_max;
    if (h % a_max > 0)
    {
        ++cnt;
    }

    cout << cnt << endl;

    return 0;
}


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

using namespace std;



int main()
{   
    int n;
    cin>>n;
    int a[n];
    for ( int i =0 ; i<= n-1; i++)
    {
        cin>>a[i];
    }
    int dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    for ( int i = 2; i<= n-1; i++)
    {
        dp[i] =  min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]- a[i-2]));
    }
    // for ( int i = 0; i<= n-1; i++)
    //     cout<<dp[i]<<' ';
    cout<<dp[n-1];
}


Measured memory_bytes: 4348
#include<stdio.h>
#include<math.h>

int prime_check(int x){

	for(int i=2;i<=sqrt(x);i++)
		if(x%i == 0)return 0;
	
	return 1;
}


int main(){
	int n,i,x;
	int ans=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&x);
		if(prime_check(x))
			ans++;
	}
	
	printf("%d\n",ans);
	
	return 0;
	
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int I=0;I<n;I++){
    string a=" ";
    string b=" ";
    string c;
    cin >> c;
    a+=c;
    cin >> c;
    b+=c;
  
    int dp[a.size()][b.size()];
    for(int i=0;i<a.size();i++){
      for(int j=0;j<b.size();j++){
	if(i==0||j==0)dp[i][j]=0;
	else if(a[i]==b[j])dp[i][j]=dp[i-1][j-1]+1;
	else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
      }
    }
    cout << dp[a.size()-1][b.size()-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 7056
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<long long> b = a;
  long long count1 = 0;
  long long sum1 = 0;
  for (int i = 0; i < n; i++){
    sum1 += b[i];
    if (i % 2 == 0){
      if (sum1 >= 0){
        long long d = sum1 + 1;
        count1 += d;
        b[i] -= d;
        sum1 -= d;
      }
    } else {
      if (sum1 <= 0){
        long long d = 1 - sum1;
        count1 += d;
        b[i] += d;
        sum1 += d;
      }
    }
  }
  vector<long long> c = a;
  long long count2 = 0;
  long long sum2 = 0;
  for (int i = 0; i < n; i++){
    sum2 += c[i];
    if (i % 2 == 1){
      if (sum2 >= 0){
        long long d = sum2 + 1;
        count2 += d;
        c[i] -= d;
        sum2 -= d;
      }
    } else {
      if (sum2 <= 0){
        long long d = 1 - sum2;
        count2 += d;
        c[i] += d;
        sum2 += d;
      }
    }
  }
  cout << min(count1, count2) << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define PER(i,n,a) for(ll i=n;i>a;i--)
#define REP1(i,a,n) for(ll i=a;i<=n;i++)
#define forit(it,x) for(auto it=(x).begin();it!=(x).end();++it)
#define ull unsigned long long int
#define ld long double
#define prec(n) fixed<<setprecision(n)
#define test ll t; cin>>t; while(t--)
#define re return 0
#define pb push_back
#define PI 3.1415926535897932384626
#define MOD (ll)1000000007
#define fi first
#define se second
#define eb emplace_back
#define vll vector<ll>
#define vi  vector<int>
#define mpll map<ll,ll>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
const ll MAXI = (ll)1e9+7;
int main(){
    IOS;
/*    test{
        int n;
        cin>>n;
        int ar[n];
        REP(i,a,n){
           cin>>ar[i];
        }
    }
    */
    string str;
    cin>>str;
    int l=0,p=0;
    int h=str.size()-1;
    while(h>l){
        if(str[l++]!=str[h--]){
            p++;
        }
    }
    cout<<p<<"\n";
re;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a;
  while(cin>>a){
  	if(a.length()<6){
      cout<<"No"<<endl;
      continue;
    }
    if(a[2]==a[3] && a[4]==a[5]){
      cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
fn main() {
    let (n, m) = {
        let mut b = String::new();
        std::io::stdin().read_line(&mut b).unwrap();
        let vec = b.split_whitespace().map(|i| i.parse().unwrap()).collect::<Vec<i32>>();
        (vec[0], vec[1])
    };
    let mut h = std::collections::HashMap::new();
    for i in 0..n {
        h.insert(i+1, Vec::new());
    }
    for _ in 0..m {
        let (a, b): (i32, i32) = {
            let mut b = String::new();
            std::io::stdin().read_line(&mut b).unwrap();
            let vec = b.split_whitespace().map(|i| i.parse().unwrap()).collect::<Vec<i32>>();
            (std::cmp::min(vec[0], vec[1]), std::cmp::max(vec[0], vec[1]))
        };
        h.get_mut(&a).unwrap().push(b);
        h.get_mut(&b).unwrap().push(a);
    }
    for i in 0..n {
        println!("{}", h[&(i+1)].len());
    }
}

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



int main() {
	

	int x,ans;
	
	cin >> x;
	
	ans = 0;
	
	ans +=1000* (x / 500);
	ans += 5*((x % 500) / 5);


	cout << ans << endl;


	return 0;
}




Measured memory_bytes: 256
N,M = map(int,input().split())
ver = [0] * N
for i in range(M):
    a,b = map(int,input().split())
    ver[a-1] += 1
    ver[b-1] += 1
ans = 'YES'
for i in range(N):
    if ver[i] % 2 != 0:
        ans = 'NO'
print(ans)



Measured memory_bytes: 75328
program nanagoroku
  implicit none
  integer :: n, i, j, m, c(100) = 0, a(5) = 0
  read(*,*) n
  do i = 1, n
    m = i
    j = 2
    do while (j <= m)
      do while (mod(m,j) == 0)
        m = m/j
        c(j) = c(j)+1
      end do
      j = j+1
    end do
  end do
  do i = 1, n
    if (c(i) >= 2) a(1) = a(1)+1
    if (c(i) >= 4) a(2) = a(2)+1
    if (c(i) >= 14) a(3) = a(3)+1
    if (c(i) >= 24) a(4) = a(4)+1
    if (c(i) >= 74) a(5) = a(5)+1
  end do
  write(*,'(i0)') (a(1)-1)*a(4)+(a(1)-2)*a(2)*(a(2)-1)/2+(a(2)-1)*a(3)+a(5)
end program nanagoroku

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

double a[100010];
double v[100010];


int main()
{
	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		scanf("%lf", a + i);
	for(int i = 1; i <= n; i++)
		scanf("%lf", v + i);
	v[n + 1] = 0;
	double ans = 0;
	for(int i = n; i >= 1; i--)
	{
		if(v[i] - a[i] > v[i + 1])
			v[i] = v[i + 1] + a[i];
	}
	double x = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= a[i]; j++)
		{
			int dt = a[i] - j;
			
			if(x - dt > v[i + 1])
				x--, ans += 0.5 + x;
			else if(x + 1 - dt > v[i + 1] && x < v[i])
				ans += 0.25 + x;
			else if(x == v[i])
				ans += x;
			else 
				ans += x + 0.5, x++; 
		}		
	}	
	printf("%.10lf", ans);
	return 0;
} 

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll ans = 1;
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i, n){
        if(a[i] == 0){
            ans = 0;
            break;
        }else if(abs(a[i]) > 1000000000000000000 / abs(ans)){
            ans = -1;
            break;
        }else{
            ans *= a[i];
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 4004
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

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

  ll n;
  std::cin>>n;

  std::vector<std::vector<ll>> graph(n);
  std::vector<ll> size(n,0),inv(n+1,1);

  ll ans=0;

  {
    ll two=pow_mod(2,MOD-2,MOD);
    rep(i,1,n+1)inv[i]=(inv[i-1]*two)%MOD;
    ans=MOD-(two*n%MOD);
  }

  rep(i,0,n-1){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  auto f=[&](auto f,ll now,ll par)->void{
    ll temp=0;
    for(ll next:graph[now]){
      if(next!=par){
        f(f,next,now);
        ans=(ans+(MOD+1-inv[size[next]])*(MOD+1-inv[n-size[next]])%MOD)%MOD;
        temp+=size[next];
      }
    }
    size[now]=temp+1;
  };

  f(f,0,-1);

  ans=(ans+(MOD+1-inv[n])%MOD)%MOD;

  std::cout<<ans<<"\n";

  return 0;
}

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

int main(){
string S;
  cin>>S;
   
 for(int i=0; i<26; i++){
  char key='a'+i; // 'a'にiを足してcharに放り込むと文字'a'自体に足してくれる。
  bool flag=false;
   for(int j=0; j<S.size(); j++){
    if(S[j]==key){flag=true;}
   }
   if(!flag){cout<<key; return 0;} // keyはcharなので'a'+iを文字に変換してくれる。
 }
 cout<<"None"; return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}
class Seg {
private:
    int size;
    vector<int> data;
public:
    int get(int l, int r, int n, int L, int R) {
        if (r <= L || R <= l) return 0;
        if (L <= l && r <= R) return data[n];
        int m = (l + r) / 2;
        return get(l, m, n*2+1, L, R) + get(m, r, n*2+2, L, R);
    }
    int get(int l, int r) {
        return get(0, size, 0, l, r);
    }
    void add(int pos, int val) {
        pos += size-1;
        while (1) {
            data[pos] += val;
            if (pos == 0) break;
            pos = (pos-1)/2;
        }
    }
    Seg(int n) {
        for (size = 1; size < n; size <<= 1);
        data = vector<int>(size*2-1, 0);
    }
};

struct Query {
    ll l, r, e, ans;
};
struct Event {
    ll type, pos, coe, qid;
};

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

    int n; cin >> n;
    vector<int> v(n); cin >> v;
    int q; cin >> q;
    vector<Query> Q;
    map<ll, vector<Event> > E;
    Seg seg(n);
    REP(i, q) {
        int l, r, e; cin >> l >> r >> e; --l;
        Q.push_back({l, r, e, r-l});
        E[min(v[l],v[r-1])-e].push_back({0, 0, 1, i});
        E[max(v[l],v[r-1])+e+1].push_back({0, 0, -1, i});
    }
    REP(i, n) {
        E[v[i]].push_back({1, i, 0, 0});
    }
    set<ll> S;
    for (auto p : E) {
        S.insert(p.first);
    }
    for (auto key : S) {
        vector<Event>& ev = E[key];
        for (auto &e : ev) {
            if (e.type == 1) {
                seg.add(e.pos, 1);
            }
            else {
                int qid = e.qid;
                Q[qid].ans += e.coe * seg.get(Q[qid].l, Q[qid].r);
            }
        }
    }
    REP(i, q) {
        cout << Q[i].ans << endl;
    }
}

Measured memory_bytes: 58876
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;


signed main(){
	int N;
	cin >> N;
	vector<int>dp(N + 1);
	FOR(i,1,N + 1){
		for(int j = i;j <= N;j += i){
			dp[j] += j;
		}
	}
	out(accumulate(ALL(dp),0ll));
}

Measured memory_bytes: 81400
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef pair<lint, pii> plp;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9+7;
const lint INF = mod*mod;
const int MAX = 100010;

int main(){
    int n, K;
    scanf("%d%d", &n, &K);
    if(n+1<2*K){
        printf("-1\n");
        return 0;
    }
    int a[n], b[n], c[n];
    rep(i, n) c[i]=K+2*n+i;
    int m=K+(3*n-1)/2;
    int cur=0;
    rFor(i, m+1, K+n) b[cur++]=i;
    rFor(i, K+2*n, m+1) b[cur++]=i;
    cur=0;
    for(int i=K; i<K+n; i+=2) a[cur++]=i;
    for(int i=K+1; i<K+n; i+=2) a[cur++]=i;
    rep(i, n) printf("%d %d %d\n", a[i], b[i], c[i]);
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main()
 
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,x,total;
	cin>> n;
	if(n>15)
	{
       x=n/15;
       total=n*800;
       cout<<total-x*200<<"\n";

	}
	else
	{
		cout<<n*800<<"\n";
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

import static java.lang.System.in;

public class Main {
    final static int MOD  = (int) 1E9 + 7;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(in);
        int n = Integer.valueOf(scanner.nextLine());
        char[] s = scanner.nextLine().toCharArray();
        long[][] dp = new long[n+1][n+1];
        dp[1][1]=1;
        for (int len = 2; len <= n; len++) {
            for (int i = 1; i <len; i++) {
                dp[len-1][i]  = (dp[len-1][i] + dp[len-1][i-1])%MOD;
            }
            for (int a = 1; a <=len; a++) {
                int  l,r;
                if(s[len-2] == '<'){
                    l = 1;
                    r   = a-1;
                }
                else {
                    l = a;
                    r = len-1;
                }
                if(l <= r)
                    dp[len][a]  =(dp[len][a] + dp[len-1][r] - dp[len-1][l-1] + MOD)%MOD;
//                for (int i = l; i <= r; i++) {
//                    dp[len][a]  = (dp[len][a] + dp[len-1][i])%MOD;
//                }
            }
        }
        long ans = 0;
        for (int i = 0; i <= n  ; i++) {
            ans  =  (ans + dp[n][i]) % MOD;
        }
        System.out.println(ans);


    }
}


Measured memory_bytes: 107272
#include <iostream>
#include<math.h>
#include <limits>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)



int main() {
	string S;
	cin >> S;
	
	int N;
	N = S.size();


	rep(i, N) {
		
		
		if (S[2*i] == 'L' || S[2 * i+1 ] == 'R') {
			cout<< "No" << endl;
			return 0;
		}
		if (2 * i + 1 == N) break;
		
	}
	cout << "Yes" << endl;
return 0;
} 

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << (a - c) * (b - d) << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	long y;
	cin >> n >> y;
	
	for( int a = n ; a >= 0 ; a-- ){
		for( int b = n - a ; b >= 0 ; b-- ){
			int c = n - a - b;
			
			if( y == (a * 10000) + (b*5000) + (c*1000)){
				cout << a << " " << b << " " << c << endl;
				ret 0;
			}
		}
	}
	
	P("-1 -1 -1");
	ret 0;
}

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

int main(){
    int N;
    cin >> N;
    int ans = (N%2==0) ? N/2 : N/2+1;
    cout << ans << endl;
}


Measured memory_bytes: 256
import string
from collections import deque

number = int(input())
q = (number - 1) // 26
r = number % 26

sss = deque()
while True:
    sss.appendleft(string.ascii_lowercase[r - 1])
    if q == 0:
        break
    else:
        r = q % 26
        q = (q - 1) // 26

print(''.join(list(sss)))


Measured memory_bytes: 9976
#include <iostream>
typedef long long ll;
using namespace std;

int N;

void func(ll cur, int use, int &counter){
  if(cur > N) return;
  if(use == 0b111) counter++;
  func(10*cur + 3, use | 0b001, counter);
  func(10*cur + 5, use | 0b010, counter);
  func(10*cur + 7, use | 0b100, counter);
}

int main(){
  cin >> N;
  int res = 0;
  func(0, 0, res);
  cout << res << endl;
}



Measured memory_bytes: 384
#!/usr/bin/python

import os
import sys

A, B, C, X, Y = map(int, raw_input().split())

if A + B < C*2:
    print A * X + B * Y
    sys.exit()

tmp = min(X, Y)
if tmp == X:
    t1 = C*2*tmp+(Y-tmp)*B
else:
    t1 = C*2*tmp+(X-tmp)*A
t2 = max(X, Y)*C*2
print min(t1, t2)


Measured memory_bytes: 2568
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
 
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
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 (a>b) { a=b; return 1; } return 0; }
 
template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
 
const ll INF = 0x3fffffff;
 
 
int main(){
	//ios_base::sync_with_stdio(0);
	ll N, ans=0;
 
	cin >> N;
	ll l=0, r=INF;
	while(r-l>1){
		ll m = (l+r)/2;
		if( m*(m+1) / 2 >= N ){
			r = m;
		}else{
			l = m;
		}
	}
 
	ll sum = r*(r+1)/2;
	rep(i,r) if( i+1 != sum-N ) cout << i+1 << endl;
 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int MAXN = 100005;
const int MOD = 1000000007;

int n, sol=1, moze=1, x;
int l[MAXN];

int main () {
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> x;
		l[x]++;
	}
	if (n&1) {
		if (l[0]!=1) moze=0;
		for (int i=2; i<n; i+=2) {
			if (l[i]!=2) moze=0;
			sol=(sol+sol)%MOD;
		}
		if (!moze) sol=0;
		cout << sol;
	} else {
		for (int i=1; i<n; i+=2) {
			if (l[i]!=2) moze=0;
			sol=(sol+sol)%MOD;
		}
		if (!moze) sol=0;
		cout << sol;
	}
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int n;
		int cou;
		while(scan.hasNext()){
			cou = 0;
			n = scan.nextInt();
			for(int a = 0;a<10;a++){
				for(int b = 0;b<10;b++){
					for(int c = 0;c<10;c++){
						for(int d =0;d<10;d++){
							if(a + b + c + d == n){
								++cou;
							}
						}
					}
				}
			}
			System.out.println(cou);
		}
	}
}

Measured memory_bytes: 18848
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
using Graph = vector<vector<int>>;
int main()
{
	int n, l, sum=0, min=100000, taste, min2;
	cin >> n >> l;
	loop(i, 1, n+1){
		taste = l+i-1;
		sum += taste;
		if(abs(taste) < min){
			min = abs(taste);
			min2 = taste;
		}
	}
	cout << sum - min2 <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int A,B,C;
    while (cin >> A >> B >> C) {
        const int x = C % B;
        int y = 0, vis[1000];
        memset(vis,0,sizeof(vis));        
        string ans = "NO";
        while (true) {
            y += A; y %= B;
            if (y == x) {
                ans = "YES";
                break;
            }
            if (vis[y])
                break;
            vis[y]++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#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>
#include<functional>
#include<assert.h>
#include<numeric>
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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m,w,t;
    cin>>n>>m>>w>>t;
    map<string,int> mp;
    ll v[m],p[m];
    rep(i,m){
        string s;
        cin>>s;
        mp[s]=i;
        cin>>v[i]>>p[i];
    }
    int x[n],y[n];
    vector<pair<int,int>> vec[n];
    rep(i,n){
        int k;
        cin>>k>>x[i]>>y[i];
        rep(j,k){
            string s;
            cin>>s;
            int pp;
            cin>>pp;
            int idx=mp[s];
            pp=p[idx]-pp;
            vec[i].emplace_back(v[idx],pp);
        }
    }
    int all=1<<n;
    ll ti[all], val[all];
    rep(i,all){
        if(i==0){
            ti[i]=val[i]=0;
            continue;
        }
        vector<ll> dp1(3*w);
        vector<int> ord;
        rep(j,n){
            if(((1<<j)&i)==0)continue;
            ord.push_back(j);
            for(auto e : vec[j]){
                rep(l,w+1){
                    dp1[l+e.first]=max(dp1[l+e.first],dp1[l]+e.second);
                }
            }
        }
        int mi=inf;
        do{
            int k=ord.size();
            int d=0;
            rep(l,k-1)d+=abs(x[ord[l+1]]-x[ord[l]])+abs(y[ord[l+1]]-y[ord[l]]);
            d+=abs(x[ord[0]])+abs(y[ord[0]])+abs(x[ord[k-1]])+abs(y[ord[k-1]]);
            mi=min(d,mi);
        }while(next_permutation(ord.begin(), ord.end()));
        ti[i]=mi;
        val[i]=dp1[w];
        
    }
    vector<ll> dp(3*t);
    rep(i,all){
        if(ti[i]>t)continue;
        rep(j,t+1){
            dp[j+ti[i]]=max(dp[j+ti[i]],dp[j]+val[i]);
        }
    }
    cout<<dp[t]<<endl;
    return 0;
}


Measured memory_bytes: 3464
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        s1 += s1;
        if(s1.contains(s2))System.out.println("Yes");
        else System.out.println("No");
    }
}


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

int main() {
    string s;
    ll k;
    char ans;
    
    cin >> s >> k;
    
    for (int i = 0; i < k; i++) {
        if (s[i] != '1') {
            ans = s[i];
            break;
        }
        
        ans = s[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int A,B,C;
	cin>>A>>B>>C;
	if(A==5&&B==5&&C==7)
	cout<<"YES"<<endl;
	else if(A==5&&B==7&&C==5)
	cout<<"YES"<<endl;
	else if(A==7&&B==5&&C==5)
	cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print (lst[K - 1])

Measured memory_bytes: 3060
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c,m, ans=0, count=0, sum=0;
    cin>>n>>m>>a;
    char arr[n][m];
    int cnt = 0;
    for(int i=0;i<n;i++){
        for(int j=0; j<m; j++) {
            cin>>arr[i][j];
            cnt += (arr[i][j] == '#' ? 1  : 0);
        }
    }

    // if(a == cnt){
    //     cout<<1<<endl;
    //     return;
    // }


    for(int i=0; i<power(2 , n); i++) {
        for(int j=0; j<power(2 , m); j++) {
            count = 0;

            for(int row=0; row<n; row++) {

                for(int col=0; col<m; col++) {

                    if((i&(1<<row) && j&(1<<col)) && arr[row][col] == '#'){
                        count++;
                    }
                }
            }


            if(count == a)
                ans++;
        }
    }
    cout<<ans<<endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
   // int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 3624
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
from copy import deepcopy
def main(H, W, K, C):
    def count(matrix):
        return sum(1 for i in range(H) for j in range(W) if matrix[i][j] == '#')

    ans = 0
    for iii in range(1 << H):
        for jjj in range(1 << W):
            I, J = iii, jjj
            mt = deepcopy(C)
            for i in range(H):
                if I & 1:
                    for jj in range(W):
                        mt[i][jj] = 'R'
                I >>= 1
            for j in range(W):
                if J & 1:
                    for ii in range(H):
                        mt[ii][j] = 'R'
                J >>= 1
            if count(mt) == K:
                ans += 1
    print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    H, W, K = map(int, input().split())
    C = [list(input().rstrip()) for _ in range(H)]
    main(H, W, K, C)


Measured memory_bytes: 82816
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII; 
const double eps = 1e-9;
//const double PI = acos(-1);
const LL INFF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;
const int MAX = 2e5+7;
int a[MAX], n;
LL lsum[MAX];
bool ck(int p2, LL v1, LL v2){
	LL buf[5]; MS0(buf);
	buf[0] = v1; buf[1] = v2; 
	buf[2] = lsum[n] - lsum[p2]; 
	buf[3] = lsum[p2] - v1 - v2;
	sort(buf, buf + 4);
	LL buf2[5]; MS0(buf2);
	buf2[0] = v1; buf2[1] = v2; 
	buf2[2] = lsum[n] - lsum[p2+1]; 
	buf2[3] = lsum[p2+1] - v1 - v2;
	sort(buf2, buf2 + 4);
	if(abs(buf[3] - buf[0]) >= abs(buf2[3] - buf2[0])) return 1;
	return 0;
}
int main(void){
	scanf("%d", &n);
	LL ans = INFF;
	rep1(i, 1, n+1) scanf("%d", a + i);
	rep1(i, 1, n+1) lsum[i] = lsum[i-1] + a[i];
	int p1 = 1, p3 = 3;
	for(int p2 = 2; p2 <= n-2; p2++){
		while(p1 + 1 < p2 && 
			  abs(lsum[p2] - 2*lsum[p1]) >= abs(lsum[p2] -2*lsum[p1+1])) p1++;
		while(p3 <= p2) p3++;
		while(p3 < n-1 && 
			  abs(lsum[n] - 2*lsum[p3] + lsum[p2]) >= 
			  abs(lsum[n] - 2*lsum[p3+1] + lsum[p2])) p3++;
		LL buf[5];
		buf[0] = lsum[p1];
		buf[1] = lsum[p2] - lsum[p1];
		buf[2] = lsum[n] - lsum[p3];
		buf[3] = lsum[p3] - lsum[p2];
		sort(buf, buf + 4);
		ans = min(ans, buf[3] - buf[0]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


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

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

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define int long long

using namespace std;

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

const int N = 600000 + 10;
const int MOD = 1000000007;
const int LOG = 20;
const int INF = 1000000010;
const int delta = 11353;

int n, m, l, r, fac[N], inv[N];

int POW(int a, int b){
	 int res = 1;
	 while (b){
		if (b & 1) res = res * 1ll * a % MOD;
		b >>= 1;
		a = a * 1ll * a % MOD;
	 }
	 return res;
}

int nCr(int a, int b){
	if (a < 0 || b < 0 || a < b) return 0;
	int res = fac[a] * 1ll * inv[b] % MOD;
	res = res * 1ll * inv[a - b] % MOD;
	return res;
}

int minu(int a, int b){
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

int Done(int y, int x, int RR){
	int Big = m;
	int Small = n - m;
	int R = RR - x * Big;
	if (R < 0) return 0;
	int res = 0;
	for (int j = 0; j <= Small; j++){
		if (j * y > R) break;
		int RRR = R - j * y;
		int del = nCr(RRR + n, n) * nCr(n - m, j) % MOD;
		if (j % 2 == 0) res = (res + del) % MOD;
		else res = minu(res, del);
	}
	return res;
}

int Solve(int R){
	int res = nCr(R + n, n);
	for (int i = 1; i <= R; i++){
		int Now = minu(Done(i, i, R), Done(i, i + 1, R)) * nCr(n, m) % MOD;
		res = minu(res, Now);
		//cout << i << ' ' << Now << '\n';
	}
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> l >> r;
	fac[0] = 1;
	for (int i = 1; i < N; i++) fac[i] = fac[i - 1] * 1ll * i % MOD;
	inv[N - 1] = POW(fac[N - 1], MOD - 2);
	//cout << nCr(6, 3) << '\n';
	for (int i = N - 2; i >= 0; i--) inv[i] = inv[i + 1] * 1ll * (i + 1) % MOD;
	//cout << nCr(6,3) << '\n';
	int ans = Solve(r) - Solve(l - 1);
	//cout << Solve(r) << ' ' << Solve(l - 1) << '\n';
	ans %= MOD;
	if (ans < 0) ans += MOD;
	cout << ans;

	return 0;
}


Measured memory_bytes: 12968
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define PD(x) printf("%d",x)
#define PL(x) printf("%lld",x)
#define PC(x) printf("%c",x)
#define PS(x) printf("%s",x)
#define PF(x) printf("%f",x)
#define SP printf(" ")
#define BR printf("\n")
#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int32 a[4], b, c;
	int n;
	cin >> n;
	a[0] = n / 1000;
	a[1] = (n / 100) % 10;
	a[2] = (n / 10) % 10;
	a[3] = n % 10;
	if ((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
if a < b:
    a, b = b, a

c = a
d = b
r = c // d
m = c % d

while True:
    if m == 0:
        break
    else:
        c = d
        d = m
        m = c % d

print(int(a * b / d))

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    string S;
    cin >> S;
    int N = S.size();

    for (int i=0; i<N; i++) {
        if (i < N - 1 && S[i] == S[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }

        if (i < N - 2 && S[i] == S[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    cout << "-1 -1" << endl;
}



Measured memory_bytes: 512
def ABC144_20191027_A():    
    a, b = map(int,input().split())

    if a > 0 and a < 10 and b > 0 and b < 10 :
        print(a * b)
    else:
        print(-1)
        
if __name__ == '__main__':
    ABC144_20191027_A()

Measured memory_bytes: 2940
def BellmanFord():
    def BF(s, n, edge, inf=float("inf")):
        d = [inf for i in range(n)]
        d[s] = 0
        for i in range(n):
            for before, after, dist in edge:
                if before != inf:
                    d[after] = min(d[after], d[before] + dist)
            if i == n - 2:
                t = d[:]
            elif i == n - 1:
                for i, j in enumerate(d):
                    if j != t[i]:
                        d[i] = -inf
        return list(map(lambda x: -x, d))
    n, m = map(int, input().split())
    inf = 10 ** 20
    edge = [list(map(int, input().split())) for i in range(m)]
    edge = [[x - 1, y - 1, -z] for x, y, z in edge]
    l = BF(0, n, edge)
    print(l[-1] if l[-1] < inf else "inf")
BellmanFord()

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=max((int)(0),b+c-a);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
string st;
int l;
int main()
{
    cin>>st;
    l=max(st.size(),st.length());
    if(st[0]==st[l-1])
    {
        if(l%2==0)cout<<"First"<<endl;
           else cout<<"Second"<<endl;
    }
    else
    {
        if(l%2==0)cout<<"Second"<<endl;
          else cout<<"First"<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n = ni()
ans = len(make_divisors(n-1))-1
ls = make_divisors(n)[1:]

for i in ls:
    nn = n
    while nn%i == 0:
        nn = nn//i
    if nn%i == 1:
        ans += 1

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

 
    if (abs(a - b) >= 1000000000000000000)
        cout << "Unfair" << endl;
    else if (k % 2 == 1)
        cout << b - a << endl;
    else
        cout << a - b << endl;

    return 0;
}

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

int main() {
    int counter = 1, temp = 0;
    bool count = true;
    for (int i = 0; i < 5; i++) {
        cin >> temp;
        if (count) {
            if (temp == 0) {
                count = false;
            } else {
                counter++;
            }
        }
    }
    cout << counter;
}

Measured memory_bytes: 3580
n,k = map(int,input().split())
x = list(map(int,input().split()))

l = 0
r = k-1
mnm = 1000100010
while r<n:
    a = abs(x[l])+abs(x[l]-x[r])
    b = abs(x[r])+abs(x[r]-x[l])
    if a<=b:
        if a < mnm:
            mnm = a
    else:
        if b < mnm:
            mnm = b
    l += 1
    r += 1
print(mnm)

Measured memory_bytes: 15020