akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int mod = 1000000007;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
vector<int> f = {1},fi = {1};
int fact(int x){
    while((int)f.size() <=x)f.push_back((f.back()*f.size())%mod);
    return f[x];
}
int ifact(int x){
    return modpow(fact(x),mod-2,mod);
}
int C(int x,int y){
    if(x < y)return 0;
    return fact(x)*ifact(y)%mod*ifact(x-y)%mod;
}
signed main(){
    int n;cin >> n;
    int a[n];rep(i,n)cin >> a[i];
    vector<int> cnt(n);
    rep(i,n){
        cnt[a[i]]++;
    }
    bool ok = true;
    if(n%2 == 0){
        for(int i = 1;i < n;i += 2){
            if(cnt[i] != 2){
                ok = false;
                break;
            }

        }
    }
    else{
        for(int i = 2;i <n;i+= 2 ){
            if(cnt[i] != 2){
                ok = false;
                break;
            }
        }
    }
    if(ok){
        cout << modpow(2,n/2,mod) << endl;

    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 4636
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string a;cin>>a;
    for(int i = 0;i<a.length();i++){
      if(a[i] == '1') cout<<"9";
      else cout<<"1";
    }
    return 0;
}

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

int main(void){

	int a,b;
	cin >> a >> b;
	if(a == b) cout << "a == b" << endl;
	else if( a > b ) cout << "a > b" << endl;
	else if( a < b ) cout << "a < b" << endl;
	
	return 0;

}

Measured memory_bytes: 1156
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  s <- readLn :: IO Int
  print $collatz [s] 1

collatz l@(x:xs) n
  |elem x xs = n
  |otherwise = if mod x 2==0
    then collatz (div x 2:l) (n+1)
    else collatz (x*3+1:l) (n+1)

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
   int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  int ans=a.at(0),p=ans;
  rep(i,n-1){
    if(p<=a.at(i+1)){
      ans+=a.at(i+1)-p;
      p=a.at(i+1);
    }else{
      p=a.at(i+1);
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int arr[100];
	int max;
	int i,j;
	int count;
	int temp;
	while(1) {
		scanf("%d",&max);
		if(max==0)break;
		for(i=0;i<max;i++) {
			scanf("%d",&arr[i]);
		}
		count=0;
		for(i=max-1;i>0;i--) {
			for(j=0;j<i;j++) {
				if(arr[j]>arr[j+1]) {
					temp=arr[j];
					arr[j]=arr[j+1];
					arr[j+1]=temp;
					count++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String tmp;
		String[] a;
		int[] ABO = {0, 0, 0, 0};
		while(sc.hasNext()) {
			a = sc.next().split(",");
			if(a[1].equals("A"))		ABO[0]++;
			else if(a[1].equals("B"))	ABO[1]++;
			else if(a[1].equals("AB"))	ABO[2]++;
			else 						ABO[3]++;
		}
		
		for(int i : ABO) {
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 25812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define inf 1000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back

ll n, m , ans ;

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

cin >> n >> m;

if(n>=m/2){
    cout << m/2 << endl;
}
else {
    m-= 2*n;
    ans+= n+ (m/4);
    cout << ans << endl;
}




return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1000000007;
const Int MAX = 200000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    COMinit();
    int N, K; cin >> N >> K;
    vector<int> A(N); for (auto &a : A) cin >> a;
    sort(begin(A), end(A));
    Int ans = 0;
    for (int i = K - 1; i < N; i++) {
        ans = (ans + A[i] * COM(i, K - 1)) % MOD;
    }
    for (int i = 0; i <= N - K; i++) {
        ans = (ans + MOD - A[i] * COM(N - 1 - i, K - 1) % MOD) % MOD;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>

int main(){
	int a, b, sum = 0;
	scanf("%d %d", &a, &b);
	if( a >= b) {
		sum += a;
		a--;
	}
	else {
		sum += b;
		b--;
	}

	if( a >= b) {
		sum += a;
		a--;
	}
	else {
		sum += b;
		b--;
	}

	printf("%d", sum);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  
  int A;
  int B;
  int C;
  
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  
  int K = B/A;
  
  if(K >= C){
    printf("%d",C);
  }
  else{
    printf("%d",K);
  }
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,a,b,c,d[101][101];
bool t[101][101];
main(){
  while(cin>>n>>m,n){
    int ans=1e9;
    r(i,n)r(j,n)d[i][j]=i==j?0:1e8;
    memset(t,0,sizeof(t));
    r(i,m){
      cin>>a>>b>>c;a--;b--;
      d[a][b]=d[b][a]=c;
      t[a][b]=t[b][a]=1;
    }
    r(o,n)r(i,n)r(j,n)d[i][j]=min(d[i][j],d[i][o]+d[o][j]);
    r(o,n)r(i,n)r(j,n)if(t[i][o]&&t[o][j])ans=min(ans,d[0][i]+d[j][n-1]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
char s[1000001];
long long a=0,b=0;
int main()
{
	cin>>s;
	a=strlen(s)-2;
	for (int i=0,j=strlen(s)-1;i<j;i++,j--)
	{
		if (s[i]==s[j])
		b++;
	}
	if (b==(a+2)/2)
	cout<<"Second"<<endl;
	else
	{
	if (s[0]==s[strlen(s)-1])
	{
		a=a-1;
		if (a%2==0)
		cout<<"Second"<<endl;
		else
		cout<<"First"<<endl;
	}
	else
	{
	if (a%2==0)
	cout<<"Second"<<endl;
	else
	cout<<"First"<<endl;	
	}
	}
	return 0;
}

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

int N, M;

int main() {
  cin >> N >> M;
  vector<long long> a[3];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 3; ++j) {
      long long num;
      cin >> num;
      a[j].push_back(num);
    }
  }
  long long res = 0;
  for (int bit = 0; bit < (1 << 3); ++bit) {
    vector<long long> b;
    for (int i = 0; i < N; ++i) {
      long long tmp = 0;
      for (int j = 0; j < 3; ++j) {
        if (bit & (1 << j))
          tmp += a[j][i];
        else
          tmp -= a[j][i];
      }
      b.push_back(tmp);
    }
    sort(b.begin(), b.end(), greater<long long>());
    long long sum = 0;
    for (int i = 0; i < M; ++i) {
      sum += b[i];
    }
    res = max(res, sum);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  long long x;
  cin >> x;
  long long pro = x / 11;
  if(x % 11 <= 6 && x % 11 != 0){
    cout << pro * 2 + 1 << endl;
    return 0;
  }
  if(x % 11 == 0){
    cout << pro * 2 << endl;
    return 0;
  }
    cout << pro * 2 + 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
	  ll n, d;
	  cin >> n >> d;
		vector<ll> x(n), y(n);
		rep(i, n){
			cin >> x[i] >> y[i];
		}

		int ct = 0;
		rep(i, n){
			if((d*d - x[i]*x[i] - y[i]*y[i])>=0) ct++;
		}
    cout << ct << endl;
    return 0;
}


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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long A = sc.nextLong();
        long B = sc.nextLong();
        long[] x = new long[n];
        for(int i=0;i<n;i++) x[i]=sc.nextLong();
        long ans= 0;
        for(int i=0;i<n-1;i++){
            ans += Math.min(A*(x[i+1]-x[i]),B);
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
    }
}


Measured memory_bytes: 64092
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        String s = sc.next();
        int ans=s.length();
        for (char i = 'a'; i <= 'z'; i++) {
            ans = min(ans, solve(s,i,0));
        }
        out.println(ans);
    }
    static boolean d(String s){
        int c=0;
        for (int i = 0; i < s.length()-1; i++) {
            if(s.charAt(i)!=s.charAt(i+1)){
                c++;
                break;
            }
        }
        return c==0;
    }
    static int solve(String s,char c,int ans){
        if(d(s))return ans;
        else {
            return solve(DaikuStr(s,c),c,ans+1);
        }
    }
    static String DaikuStr(String s,char c){
        String t="";
        for (int i = 0; i < s.length() - 1; i++) {
            t+=s.charAt(i+1)==c?c:s.charAt(i);
        }
        return t;
    }
}

Measured memory_bytes: 40788
//
// Created by PIIMUU on 8/22/2020.
//
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> row(h + 1), col(w + 1);
    map<pair<int, int>, int> mp;
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        row[x]++;
        col[y]++;
        mp[{x, y}]++;
    }
    int mark_row, mx_row = 0;
    for (int i = 1; i <= h; i++) {
        if (row[i] > mx_row) {
            mx_row = row[i];
            mark_row = i;
        }
    }
    int mark_col, mx_col = 0;
    for (int i = 1; i <= w; i++) {
        if (col[i] - mp[{mark_row, i}] > mx_col) {
            mx_col = col[i] - mp[{mark_row, i}];
            mark_col = i;
        }
    }
    int answer = mx_row + mx_col;
    mx_row = 0, mx_col = 0;
    for (int i = 1; i <= w; i++) {
        if (col[i] > mx_col) {
            mx_col = col[i];
            mark_col = i;
        }
    }
    for (int i = 1; i <= h; i++) {
        if (row[i] - mp[{i, mark_col}] > mx_row) {
            mx_row = row[i] - mp[{i, mark_col}];
            mark_row = i;
        }
    }
    answer = max(answer, mx_row + mx_col);
    cout << answer;
}



Measured memory_bytes: 61780
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

struct edge {
  ll from, to, cost;
};

void solve() {
  inl(N, M);

  vector<edge> edges;
  rep(i, M) {
    inl(a, b, c);
    a--, b--;
    edges.push_back(edge{a, b, -c});
  }

  vll d(N, 1LL << 60);
  d[0] = 0LL;

  ll memo = 0;
  rep(i, 2 * N) {
    bool update = false;
    for (auto e : edges) {
      if (d[e.from] != (1LL << 60) && d[e.to] > d[e.from] + e.cost)
        d[e.to] = d[e.from] + e.cost;
    }

    if (i == N - 1)
      memo = d[N - 1];
  }
  if (memo != d[N - 1])
    out("inf");
  else
    out(-d[N - 1]);
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  int n;
  cin >> n;
  REP(i, 9) REP(j, 9) {
    if((i+1) * (j+1) == n) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  int a,b;
  int tmp;
  
  cin >> a >> b;
  tmp=a+b;

  cout << (((a+b)%2) ? (a+b)/2+1 :(a+b)/2) << endl;
  
  return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

#define int long long

signed main(){
	int n, m;
	cin >> n >> m;

	vector<long long> a(n);
	rep(i,n){
		cin >> a[i];
		a[i]--;
	}

	long long sum = 0;
	rep(i,n - 1){
		int dif = a[i + 1] - a[i];
		//show(dif)
		sum += dif < 0 ? dif + m : dif;
	}

	//show(sum)

	vector<int> cSum(m * 2,0);
	rep(i,n - 1){
		if(a[i + 1] - a[i] == 1) continue;
		int from = a[i];
		int to = a[i + 1];
		if(from > to) to += m;
		cSum[from + 2]--;
		cSum[to + 1]++;
		//cout << from + 2 << ' ' << to + 1 << endl;
	}

	//for(auto i : cSum){ cout << i << ' '; } cout << endl;

	rep(i,m * 2 - 1){
		cSum[i + 1] += cSum[i];
	}
	//for(auto i : cSum){ cout << i << ' '; } cout << endl;

	rep(i, n - 1){
		if(a[i + 1] - a[i] == 1) continue;
		int from = a[i];
		int to = a[i + 1];
		if(from > to) to += m;
		cSum[to + 1] += to - from - 1;
		//cout << to + 1 << ' ' << to - from - 1 << endl;
	}

	//for(auto i : cSum){ cout << i << ' '; } cout << endl;
	rep(i,m * 2 - 1){
		cSum[i + 1] += cSum[i];
	}
	//for(auto i : cSum){ cout << i << ' '; } cout << endl;

	rep(i, m){
		cSum[i] += cSum[i + m];
	}
	//for(auto i : cSum){ cout << i << ' '; } cout << endl;

	cout << sum + *min_element(all(cSum)) << endl;
}


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

class dice{
public:
	int d[7];
	int setd();
	int M(int*,int*,int*,int*);
};
int dice::setd(){
	for(int i=1;i<=6;i++){
		cin>>d[i];
	}
	return 0;
}
int dice::M(int *A,int *B,int *C,int *D){
	int s,t;
	s=*B;
	*B=*A;
	t=*C;
	*C=s;
	s=*D;
	*D=t;
	*A=s;
	return 0;
}
int main(void){
	dice a;
	a.setd();
	char c[110];
	cin>>c;
	for(int j=0;;j++){
		if(c[j]=='E'){
			a.M(&a.d[1],&a.d[3],&a.d[6],&a.d[4]);
			continue;
		}
		if(c[j]=='W'){
			a.M(&a.d[1],&a.d[4],&a.d[6],&a.d[3]);
			continue;
		}
		if(c[j]=='N'){
			a.M(&a.d[1],&a.d[5],&a.d[6],&a.d[2]);
			continue;
		}
		if(c[j]=='S'){
			a.M(&a.d[1],&a.d[2],&a.d[6],&a.d[5]);
			continue;
		}
		break;
	}
	cout<<a.d[1]<<endl;
	return 0;
}

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

int N;
int A[MAX], B[MAX], T[MAX], Asum, Bsum;
int hoge, con;

signed main(){
	cout<<fixed<<setprecision(7);
	
	cin>>N;
	
	rep(i,N){
		cin>>A[i];
		Asum += A[i];
	}
	
	rep(i,N){
		cin>>B[i];
		T[i] = A[i]-B[i];
		if(A[i]<B[i]) hoge += B[i]-A[i], con++;
		Bsum += B[i];
	}
	
	if(Bsum > Asum) cout<<-1<<endl;
	else {
		sort(T,T+N);
		for(int i = N-1, sum = 0; i >= 0; i--){
			if(sum >= hoge) break;
			sum += T[i];
			con++;
		}
		cout<<con<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;


int main() {

	ll N, M, K;
	cin >> N >> M >> K;

	ll tmp = 0;
	bool ans = false;

	rep(i, N + 1) {
		rep(j, M + 1) {
			ll z = 0;
			tmp = i * (M - j) + j * (N - i);
			if (tmp == K) {
				ans = true;
				break;
			}
		}
	}

	if (ans) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


	return 0;
}


Measured memory_bytes: 3496
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define int long long
#define endl "\n"
 
 
 
signed main()
{
    FAST;
    int t;
    t=1;
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        cin>>n;
        vector<int> vect(n+1 , 0);
        
        for(i=1;i<=n;i++)
        {
            for(j=1;j*i<=n;j++)
            {
                vect[i*j]++;
            }
        }
        
        for(i=1;i<=n;i++)
        {
            ans += (i*vect[i]);
        }
    cout<<ans<<endl;
    
        
    }
        
    
    
    
    
}

Measured memory_bytes: 81324
import java.util.Scanner;
public class Main { 
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
      	int D = reader.nextInt();
		String result = "Christmas";
		while (D < 25) {
          result += " Eve";
        	D++;
        } 
      	System.out.print(result);
    }
}

Measured memory_bytes: 21716
import sys
from heapq import heapify,heappop,heappush
from collections import defaultdict
read=sys.stdin.read
readline=sys.stdin.readline

def main():
    n=int(readline())
    a,b,c=(list(map(int,lst.split())) for lst in read().splitlines())
    a.sort()
    b.sort()
    c=[-x for x in c]
    c.sort()

    def bise(x,lst):
        left=0
        right=len(lst)
        while right-left>0:
            mid=(right+left)//2
            if lst[mid]>=x:
                right=mid
            else:
                left=mid+1
        return left
    print(sum(bise(x,a)*bise(-x,c) for x in b))

if __name__=='__main__':
    main()
      
      


Measured memory_bytes: 31688
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = []
f = []
z = 0
for ai in a:
  if ai > 0:
    s.append(ai)
  elif ai < 0:
    f.append(-ai)
  else:
    z += 1
p = len(s)
q = len(f)
l = max(0,k-p)
h = min(k,q)
mod = 10**9+7
if l > h:
  print(0)
  exit()
if l%2 == 0 or h-l >= 1:
  if l%2 == 0:
    c = l
  else:
    c = l+1
  s.sort(reverse=True)
  f.sort(reverse=True)
  while c+2 <= h:
    if f[c]*f[c+1] > s[k-c-1]*s[k-c-2]:
      c += 2
    else:
      break
  ans = 1
  for i in range(c):
    ans =(ans*f[i])%mod
  for i in range(k-c):
    ans = (ans*s[i])%mod
  print(ans)
  exit()
if z > 0:
  print(0)
  exit()
m = s + f
m.sort()
ans = 1
for i in range(k):
  ans = (ans*(m[i]))%mod
ans = (-ans)%mod
print(ans)

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long start=1;
		for(int i=1;i<=n;i++) {
			start=(start*i)%1000000007;
		}
		System.out.println(start);

	}

}


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


void solve() {
  char s;
   cin >> s;

   if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }
}

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


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


int main()
{	
	int a,b,c,d,sum=0;
	cin>>a>>b>>c>>d;
	if(a&&d)
	{
		sum+=min(a,d);
		d-=min(a,d);
	}
	if(b&&d)
	{
		d-=min(b,d);
	}
	if(c&&d)
	{
		sum-=min(c,d);
		d-=min(c,d);
	}
	cout<<sum<<endl;
	return 0;
}

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

int main() {
  int N,M;
  cin>>N;
  bool ans=false;
  for(int i=1; i<10; i++){
    if(N%i==0 && N/i<10){
      ans=true;
      break;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    long a, b;
    cin >> a >> b;

    long x8 = a / 0.08;
    long x10 = b / 0.1;
    long x = 0;
    long loo = 0;
    if ( x8 < x10)
    {
        loo = 13;
        x = x10;
    }
    else
    {
        loo = 10;
        x = x8;
    }
    long res = -1;
    for(int i = 0;i < loo; ++i)
    {
        long tmp1 = ((x + i) * 0.08);
        long tmp2 = ((x + i) * 0.1);
        if ( tmp1 == a && tmp2 == b )
        {
            res = x + i;
            break;
        }
    }

    cout << res << endl;    
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  arr = input.split("");
  var s = 0;
  if(arr[0] == "1"){ ++s; }
  if(arr[1] == "1"){ ++s; }
  if(arr[2] == "1"){ ++s; }
  console.log('%d',s);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

struct union_find{
  vector<int> par,r;

  union_find(int n){
  	par.resize(n);
  	r.resize(n);
  	init(n);
  }

  void init(int n){
    for(int i = 0; i < n; i++) par[i] = i;
    for(int i = 0; i < n; i++) r[i] = 0;
  }

  int find(int x){
    if(par[x] == x) return x;
    else return find(par[x]);
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(r[x] < r[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(r[x] == r[y]) r[x]++;
    }
  }

  bool same(int x,int y){
  	return find(x) == find(y);
  }
};

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

	vector<pair<int,int> > e(m);

	for(int i = 0; i < m; i++){
		cin >> e[i].first >> e[i].second;
		e[i].first--;
		e[i].second--;
	}

	int ans = 0;
	for(int i = 0; i < m; i++){
		union_find uf(n);

		for(int j = 0; j < m; j++){
			if(i!=j && !uf.same(e[j].first,e[j].second)){
				uf.unite(e[j].first,e[j].second);
			}
		}
		set<int> s;
		for(int j = 0; j < n; j++){
			if(uf.par[j]==j) s.insert(uf.par[j]);
		}
		if(s.size()>1) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
#define N 19
#define LL long long
#define INF 0x3f3f3f3f3f3f3f3f
int n,a[N];map<pair<int,int>,LL>f[N][N];
LL dfs(int l,int r,int v1,int v2)
{
	if(r-l<=1)return 0;pair<int,int>p1=make_pair(v1,v2);if(f[l][r].count(p1))return f[l][r][p1];LL &v=f[l][r][p1];v=INF;
	for(int i=l+1;i<r;i++)v=min(v,dfs(l,i,v1,v1+v2)+dfs(i,r,v1+v2,v2)+1ll*(v1+v2)*a[i]);return v;
}
int main(){
	scanf("%d",&n);int i;
	for(i=1;i<=n;i++)scanf("%d",&a[i]);printf("%lld",dfs(1,n,1,1)+a[1]+a[n]);return 0;
}

Measured memory_bytes: 16512
a, b, c = map(int,input().split())
count = 0
def exchange(a, b, c, count):
    a, b, c = int((b+c)/2), int((a+c)/2), int((a+b)/2)
    count += 1
    if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
        return a, b, c, count
    else:
        return exchange(a, b, c, count)
if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
    print(0) 
elif a == b == c:
    print(-1)
else:
    aa, bb, cc, count = exchange(a, b, c, count)
    print(count)

Measured memory_bytes: 9216
using System;
using System.Collections.Generic;

    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int num = input.Length;
            int acnt = 0;
            int bcnt = 0;

            for (int i = 0; i < num; i++)
            {
                if(i % 2 == 1)
                {
                    if(input.Substring(i,1).Equals("0"))
                    {
                        acnt++;
                    }
                    else
                    {
                        bcnt++;
                    }
                }
                else
                {
                    if (input.Substring(i, 1).Equals("1"))
                    {
                        acnt++;
                    }
                    else
                    {
                        bcnt++;
                    }
                }
            }
            if(acnt < bcnt)
            {
                Console.WriteLine(acnt);
            }
            else
            {
                Console.WriteLine(bcnt);
            }
            
            Console.ReadLine();
        }
    }



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

int main () {
  int N;
  cin >> N;
  
  vector<int>A(N);
  for (int i=0; i<N; i++) cin>>A.at(i);
  
  int count=0;
  
  while(true) {
    bool exit=false;
    for (int i=0; i<N; i++) {
      if (A.at(i) %2 != 0) exit = true;
    }
    if (exit) break;
    
    for (int i=0; i<N; i++) {
      A.at(i) /= 2;
    } count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
/*
Created by Rishu Sahu @ covid 20-20
*/
/*
*****************************************************************
*/

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

#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pai pair<int,int>
#define pal pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,a,b) for(int i=a;i<=b;i++)
#define ff first 
#define ss second
#define sz(x) (int)x.size()
#define vi vector<int>
#define vl vector<ll>
#define mpl map<ll,ll>
#define mpi map<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()

const int mod = 1e9+7;
const int INF = INT_MAX;

void prime(int &temp,int fa,vi &vec){
    while(temp%fa==0){
        vec.pb(fa);
        temp=temp/fa;
        break;
    }
}

void factor(int n,vi &vec){
    
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            vec.pb(i);
            if(i*i!=n)
            vec.pb(n/i);
            
        }
    }
}

void solve(){
     ll n,x,t;
     cin>>n>>x>>t;
     cout<<(int)ceil(n/(1.0*x))*t<<endl;
}


int main(){
    /*int t;
    cin>>t;
    while(t--){*/
        solve();
    //}
}

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

vector<int> Prev(4200000), Next(4200000);

string field[505];

int main() {
    while(true) {
        int n, m;
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        for(int i = 1; i <= n; i++) cin >> field[i];
        if(m <= 22) {
            for(int i = 0; i < (1 << m); i++) {
                Prev[i] = -1e9;
                Next[i] = 1e9;
            }
            Prev[0] = 0;
            for(int i = 1; i <= n; i++) {
                int now = 0;
                for(int j = 0; j < m; j++) {
                    now *= 2;
                    if(field[i][j] == '1') now++;
                }
                //cerr << n << " " << m << " " << now << endl;
                for(int bit = 0; bit < (1 << m); bit++) {
                    Next[bit] = max(Prev[bit], Prev[bit ^ now] + 1);
                    //cerr << n << " " << bit << " " << Next[bit] << endl;
                }
                swap(Prev, Next);
            }
            cout << max(Prev[0], 0) << endl;
        } else {
            int res = 0;
            vector< bitset<500> > bs(n);
            for (int i = 0; i < n; ++i) bs[i] = bitset<500>(field[i + 1]);
            for (int bit = 0; bit < 1 << n; ++bit) {
                bitset<500> s;
                for (int i = 0; i < n; ++i) if (bit >> i & 1) {
                    s ^= bs[i];
                }
                if (!s.count()) {
                    res = max(res, __builtin_popcount(bit));
                }
            }
            cout << res << '\n';
        }
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, M;
    cin >> N >> M;
    
    ll ans = 0;
    if(abs(N - M) <= 1) {
        ans = 1;
        REP(i,1,N+1) ans = (ans * i) % MOD;
        REP(i,1,M+1) ans = (ans * i) % MOD;
        if(N == M) ans = (ans * 2) % MOD;
    }
    PR(ans);

    return 0;
}

/*



*/

Measured memory_bytes: 3636
N,K=map(int, input().split())
A=list(map(int, input().split()))
check=[0]*(N)
check[0]=1
D=[]
C=[0]
p=0
for i in range(N):
  pp=A[p]-1
  if check[pp]==0:
    check[pp]=1
    C.append(pp)
    p=pp
  else:
    roop=pp
    break
rs=C.index(roop)
if K<=rs-1:
  print(C[K]+1)
else:
  K-=(rs-1)
  F=C[rs:]
  e=K%(len(F))
  print(F[e-1]+1)

Measured memory_bytes: 32372
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
int main()
{
ll x,k,d;
cin>>x>>k>>d;
x=abs(x);
if(x/d>=k)
    x-=k*d;
else
{
    ll c=x/d;
    k-=c;
    x-=c*d;
       if(k&1)
        x=min(abs(x+d),abs(x-d));
}
cout<<x<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
    x %= m;
    int res = 1;
    while(n > 0) {
        if(n & 1)
            res = res * x % m;
        x = x * x % m;
        n >>= 1;
    }
    return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());

    int n, r;
    cin >> n >> r;
    if(n >= 10) {
        cout << r;
    }
    else {
        int ans = r + 100 * (10 - n);
        cout << ans;
    }

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	llong x;
	cin>>x;
	
	llong ans=0;
	ans+=x/500*1000;
	x%=500;
	ans+=x/5*5;
	
	cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N; cin >> N;
    vector<int> A(N); rep(i, N){cin >> A.at(i);}

    vector<int> indices(N);
    iota(indices.begin(), indices.end(), 0);
    sort(indices.begin(), indices.end(), [&A](ll i1, ll i2) {
        return A[i1] < A[i2];
    });
    for (auto a: indices){cout << a + 1 << " ";}
}

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


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

constexpr double EPS = 1e-10;
using Point = complex<double>;
using Line  = pair<Point, Point>;

double dot(Point p, Point q) { return (conj(p) * q).real(); }
double cross(Point p, Point q) { return (conj(p) * q).imag(); }

Point cross_point(Line a, Line b) {
    Point base = b.second - b.first;
    double area1 = abs(cross(base, a.first - b.first));
    double area2 = abs(cross(base, a.second - b.first));
    double t = area1 / (area1 + area2);
    return a.first + (a.second - a.first) * t;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int q; cin >> q;
    for(int i=0; i < q; ++i) {
        double a,b,c,d,e,f,g,h;
        cin>>a>>b>>c>>d>>e>>f>>g>>h;
        Line l1(Point(a,b), Point(c,d));
        Line l2(Point(e,f), Point(g,h));
        Point ret = cross_point(l1, l2);
        cout << ret.real() << " " << ret.imag() << '\n';
    }
    return 0;
}


Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;

int H, W, N;
pii p[200005];
map<pii, bool> mp;
int R[200005];
int L[200005];

signed main()
{
    cin >> H >> W >> N;
    for(int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        p[i] = mk(a, b);
        mp[p[i]] = true;
    }
    int r = 0;
    for(int i = 1; i < H; i++){
        if(!mp[mk(i, r + 1)]){
            r++;
        }
        R[i] = r;
    }
    fill(L, L + H, INF);
    sort(p, p + N);
    for(int i = N - 1; i >= 0; i--){
        L[p[i].first] = p[i].second;
    }
    int ans = H;
    for(int i = 1; i < H; i++){
        if(L[i] <= R[i]){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    /*for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(mp[mk(i, j)]){
                printf("#");
            }
            else{
                printf(".");
            }
        }
        printf("\n");
    }*/

    return 0;
}

/*

7
3
13
15
1
31
33
1

*/


Measured memory_bytes: 28928
#include <bits/stdc++.h>
#define R register
#define fp(i, a, b) for (R int i = (a), I = (b) + 1; i < I; ++i)
#define fd(i, a, b) for (R int i = (a), I = (b)-1; i > I; --i)
#define go(u) for (int i = head[u], v = e[i].v; i; i = e[i].nx, v = e[i].v)
template <class T>
inline bool cmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
inline bool cmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
using namespace std;
int P;
inline void upd(R int &x, R int y) { (x += y) >= P ? x -= P : 0; }
inline int add(R int x, R int y) { return x + y >= P ? x + y - P : x + y; }
inline int dec(R int x, R int y) { return x - y < 0 ? x - y + P : x - y; }
inline int mul(R int x, R int y) { return 1ll * x * y - 1ll * x * y / P * P; }
int ksm(R int x, R int y) {
  R int res = 1;
  for (; y; y >>= 1, x = mul(x, x)) (y & 1) ? res = mul(res, x) : 0;
  return res;
}
const int N = 155;
int n, p;
inline int max(R int x, R int y) { return x > y ? x : y; }
int solve(int n, int p) {
  static int f[N][N];
  memset(f, 0, sizeof(f));
  f[0][0] = 1;
  fp(i, 0, n - 1) fp(j, 0, p) if (f[i][j]) upd(f[i + 1][0], f[i][j]),
      upd(f[i + 1][j + 1], f[i][j]);
  R int res = 0;
  fp(i, 0, p) upd(res, f[n][i]);
  return res;
}
int f[N][N][N];
int main() {
  //  freopen("testdata.in","r",stdin);
  scanf("%d%d%d", &n, &p, &P);
  if (p & 1 ^ 1)
    return printf("%d\n",
                  mul(solve(n >> 1, p >> 1), solve((n + 1) >> 1, p >> 1))),
           0;
  f[0][0][0] = 1;
  fp(i, 1, n + 1) {
    R int r = (i << 1), l = r - p;
    R bool fr = (r >= 1 && r <= n), fl = (l >= 1 && l <= n);
    fp(j, 0, n) fp(k, 0, p + 1) if (f[i - 1][j][k]) {
      upd(f[i][0][0], f[i - 1][j][k]);
      if (fr) upd(f[i][j + 1][0], f[i - 1][j][k]);
      if (fl && k + 1 < p + 2) upd(f[i][0][k ? k + 1 : k], f[i - 1][j][k]);
      if (fl && fr && max(j + 2, k + 1) < p + 2)
        upd(f[i][j + 1][max(k + 1, j + 2)], f[i - 1][j][k]);
    }
  }
  printf("%d\n", f[n + 1][0][0]);
  return 0;
}

Measured memory_bytes: 12800
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
  input! {
    mut a: isize, b: isize, mut c: isize, d: isize
  };

  loop {
    c -= b;
    if c <= 0 {
      println!("Yes");
      std::process::exit(0);
    }
    a -= d;
    if a <= 0 {
      println!("No");
      std::process::exit(0);
    }
  }
}


Measured memory_bytes: 2100
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int h[] = new int[N+1];
		long dp[] = new long[N+1];
		for (int i = 1; i <= N; i++) {
			h[i] = sc.nextInt();
		}

		Arrays.fill(dp,1,N + 1, Integer.MAX_VALUE);
		dp[1] = 0;

		for (int i = 1; i < N; i++){
			if (i <= N-2) {
				dp[i + 2] = Math.min(dp[i + 2], dp[i] + Math.abs(h[i] - h[i + 2]));
			}
			dp[i + 1] = Math.min(dp[i + 1], dp[i] + Math.abs(h[i] - h[i + 1]));
		}
	  System.out.println(dp[N]);
	}
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int32 a, b;
  cin >> a >> b;
  if(a > 8 || b > 8){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int[] arrayx=new int[n];
		int[] arrayy=new int[m];

		for(int i=0;i<n;i++) {
			arrayx[i]=sc.nextInt();
		}
		for(int i=0;i<m;i++) {
			arrayy[i]=sc.nextInt();
		}
		Arrays.sort(arrayx);
		Arrays.sort(arrayy);
		int x1,y1;

		y1=Math.min(y, arrayy[0]);
		x1=Math.max(x, arrayx[n-1]);

		if(y1-x1>0) {
			System.out.println("No War");
		}else {
			System.out.println("War");
		}
	}
}




Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

Measured memory_bytes: 3628
import copy
import sys
sys.setrecursionlimit(10**9)

def dfs(G, v, p, d, depth):
    depth[v] = d
    for nv in G[v]:
        if nv == p:
            continue
        dfs(G, nv, v, d+1, depth)
    return G, depth


n, T, A = map(int,input().split())
T, A = T-1, A-1
g = [[] for _ in range(n)]
for i in range(n-1):
    x, y = map(int,input().split())
    x, y = x-1, y-1
    g[x].append(y)
    g[y].append(x)

depth = [0]*n
GT = copy.deepcopy(g)
GT[T].append(-1)
GT, dt = dfs(GT, T, -1, 0, depth)

depth = [0]*n
GA = copy.deepcopy(g)
GA[A].append(-1)
GA, da = dfs(GA, A, -1, 0, depth)

ans = 0
for t, a in zip(dt, da):
    if t <= a:
        ans = max(ans, a)
print(ans-1)

Measured memory_bytes: 142256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;
	int[][] data;
	int[] memo;
	boolean[] use;
	int n, m, N;

	void run() {
		for (;;) {
			n = sc.nextInt();
			if (n == 0) {
				return;
			}
			data = new int[201][2];
			for (int i = 0; i < n; i++) {
				data[i][0] = sc.nextInt();
				data[i][1] = sc.nextInt();
			}
			m = sc.nextInt();
			for (int i = n; i < m + n; i++) {
				data[i][0] = sc.nextInt();
				data[i][1] = sc.nextInt();
			}

			N = n + m;
			memo = new int[n + m];
			use = new boolean[n + m];
			int ans = 0;
			for (int i = 0; i < N; i++) {
				ans = Math.max(ans, dfs(i));
			}
			System.out.println(ans);
		}
	}

	int dfs(int index) {
		if (memo[index] > 0) {
			return memo[index];
		}
		int res = 1;
		use[index] = true;
		for (int i = 0; i < N; i++) {
			if (!use[i]) {
				if (data[i][0] < data[index][0] && data[i][1] < data[index][1]) {
					res = Math.max(res, dfs(i) + 1);
				}
			}
		}
		use[index] = false;
		return memo[index] = res;
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

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

int64_t luca(vector<int64_t> &lucas ,int x){
    int64_t ans = 0 ;
    int64_t X = lucas.at(x) ;
    if ( X != 0)
    {
        ans = X ;
        return ans ;
    }
    
    if (x == 0)
    {
        return 2 ;
    }
    else if (x == 1)
    {
        return 1;
    }
    else
    {
        ans = luca(lucas, x-1) + luca(lucas,x-2) ;
    }
    lucas.at(x) = ans ;
    return ans ;
    
    
}

int main(){
    int N ;
    cin >> N ;
    vector<int64_t> lucas(N+1 ,0) ;
    lucas.at(0) = 2 ;
    lucas.at(1) = 1 ;
    cout << luca(lucas, N) << endl ;
}

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

int main(){
    string s; cin>>s;
    int n=s.size();
    int ans,m=n/2,l,r;
    if(n&1){
        l=m-1;
        r=m+1;
        ans=m+1;
    }
    else{
        l=m-1;
        r=m;
        ans=m;
    }
    while(0<=l){
        if(s[m]==s[l--]&&s[m]==s[r++]){
            ans++;
        }
        else break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
S=list(input())
K=int(input())
S2 = S*2
tmp=0
tmp2=0

if all([S[i] == S[0] for i in range(1,len(S))]):
    print((len(S)*K)//2)
    exit()
for i in range(1,len(S)):
    if S[i-1]==S[i]:
        S[i]="0"
        tmp += 1

for i in range(1,len(S2)):
    if S2[i-1]==S2[i]:
        S2[i]="0"
        tmp2 += 1

print(tmp+(tmp2-tmp)*(K-1))

Measured memory_bytes: 3064