akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H; cin >> H;
  int N;
  cin >> N;
  int total = 0;
  int a;
  rep(i, 0, N) {
    cin >> a;
    total += a;
  }

  if (total >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
};


Measured memory_bytes: 256
import sys
n,y = map(int,input().split())
p = 0
for i in range(n+1):
  for k in range(n+1-i):
    p = n-i-k
    if 10000*i+5000*k+1000*p == y:
      print(str(i) + ' ' + str(k) + ' ' + str(p))
      sys.exit()
        
print("-1 -1 -1")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int dp[3010][3010];

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int n = (int)s.size();
    int m = (int)t.size();
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(s[i]==t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
    }

    string ans = "";
    while(n > 0 && m > 0){
        if(dp[n][m]==dp[n-1][m]) --n;
        else if(dp[n][m]==dp[n][m-1]) --m;
        else {
            ans = s[n-1] + ans;
            --n; --m;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long int
#define mp make_pair
#define PI 3.14159265358979

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='?')
        s[i]='D';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3740
use proconio::input;

fn main() {
    input! {
	N: usize,
	M: usize,
    }
    let mut H = vec![0; N];
    let mut G = vec![true; N];
    for i in 0..N {
	input! {
	    h: u32,
	}
	H[i] = h;
    }
    for _i in 0..M {
	input! {
	    a: usize,
	    b: usize,
	}
	let a = a - 1;
	let b = b - 1;
	if H[a] >= H[b] {
	    G[b] = false;
	}
	if H[b] >= H[a] {
	    G[a] = false;
	}
    }
    println!("{}", G.iter().filter(|x| **x).count());
}


Measured memory_bytes: 4548
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int A[100100]; rep(i, N) cin >> A[i];
    int k = 0;
    rep(i, N) {
        if(i % 2 == 0) {
            k += A[i];
        } else {
            k -= A[i];
        }
    }
    cout << k << " ";
    rep(i, N - 1) {
        k = 2 * A[i] - k;
        cout << k << " ";
    }
    cout << endl;
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstdio>
using namespace std;

int main(){
  int n, k, z; cin >> n >> k;
  int x[n];

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

  int ans = INT_MAX;
  for(int i = 0; i + k - 1< n; i++){
    int l = x[i], r = x[i + k - 1];
    if(l >= 0){
      ans = min(ans, r);
    }
    else if(r <= 0){
      ans = min(ans, -l);
    }
    else{
      ans = min(ans, r - 2*l);
      ans = min(ans, -l + 2*r);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
array = Array.new(100000 + 1, 0)

n, k = gets.split.map(&:to_i)
n.times do
  a, b = gets.split.map(&:to_i)
  array[a] += b
end

array.each_with_index do |x, i|
  k -= x
  if k <= 0
    puts i
    exit
  end
end



Measured memory_bytes: 2556
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>

using namespace std;

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

typedef long long ll;

int main(){
	char str_r[21][101];
	char str_s[11];
	int n;
	
	scanf("%s", str_s);
	
	int len = strlen(str_s);
	
	cin >> n;
	
	REP(i,n){
		scanf("%s", str_r[i]);
	}
	
	REP(i,n){
		char tmp[11];
		strcpy(tmp, str_r[i]);
		strcat(str_r[i], tmp);
	}
	
	int cnt = 0;
	int f;
	
	REP(i,n){
		f = 0;
		REP(j,10){
			if (str_s[0] == str_r[i][j]){
				f = 1;
				FOR(k,1,len){
					if (str_s[k] != str_r[i][j+k]){
						f = 0;
						break;
					}
					if (k == len-1) f = 1;
				}
			}
			if (f) break;
		}
		if (f) cnt++;;
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui M = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR2(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

template<class T,class U>
ostream &operator<<(ostream &os,const pair<T,U> &x) {
    return os<<"("<<x.first<<","<<x.second<<")";
}

template<class T>
ostream &operator<<(ostream &os,const vector<T> &x) {
    os << '[';
    if ( !x.empty() ) {
        std::copy (x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
        os << "\b";
    }
    os << "]";
    return os;
}
template<class T>
ostream &operator<<(ostream &os,const vector<vector<T> > &x) {
    os << '[';
    if ( !x.empty() ) {
        for (auto v: x) os << v << ",";
        os << "\b";
    } else os << "[]";
    os << "]";
    return os;
}
const int NMAX=2E5;
int x[NMAX];

ll doit(int i,int j){
    if (i>j) return 0;
    if (i==j) return x[i]==0;
    int mid=(i+j)/2;
    ll cnt=doit(i,mid)+doit(mid+1,j);
    map<ll,ll> sumas;
    ll s=0;
    for (int k=mid;k>=i;k--){
        s += x[k];
        sumas[s]++;
    }
    s=0;
    FOR2(k,mid+1,j+1){
        s -= x[k];
        auto it=sumas.find(s);
        if (it!=sumas.end()) cnt += it->second;
    }
    return cnt;
}

int main() {
    FAST;
  //  freopen ("in.txt", "r", stdin);
    int n;cin>>n;
    FOR(i,n) cin >> x[i];
    cout << doit(0,n-1);


    return 0;
}

Measured memory_bytes: 7296
#pragma GCC optimize("Ofast")

//#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x%N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x)%N;
		y = y >> 1;
		x = (x * x)%N;
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b;
	cin >> a >> b;
	b *= 2;
	cout << max((ll)0, a - b);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s.size()==4){
		cout<<0<<endl;
		return 0;
	}
	int n=s.size();
	int mod[200000];
	mod[n-1]=s[n-1]-'0';
	int hoge=1;
	for(int i=n-2;i>=0;i--){
		hoge*=10;
		hoge%=2019;
		mod[i]=(s[i]-'0')*hoge+mod[i+1];
		mod[i]%=2019;
	}
	int cnt[2020]={};
	for(int i=0;i<n;i++){
		cnt[mod[i]]++;
	}
	int ans=0;
	for(int i=0;i<2019;i++){
		ans+=cnt[i]*(cnt[i]-1)/2;
	}
	ans+=cnt[0];
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  char c;
  std::cin >> c;

  if(isupper(c))std::cout << "A" << '\n';
  else std::cout << "a" << '\n';

  return 0;
}


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

int main(){
	int n;
	cin >> n;
	
	vector<int> p(n), idx(n);
	rep(i,n){
		int tmp;
		cin >> tmp;
		p[i] = --tmp;
		idx[tmp] = i;
	}
	
	int now = 1;
	int cnt = 0;
	rep(i,n-1){
		if(idx[i+1] > idx[i]){
			now++;
		}
		else{
			cnt = max(cnt,now);
			now = 1;
		}
	}
  cnt = max(cnt,now);
	int res = n-cnt;
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#include <string>
#include<stdio.h>
using namespace std;

int main(int argc, const char *argv[])
{

    int N;
    cin>>N;
    string str;
    cin>>str;
    int count_R = 0;
    int count_B = 0;
    for(int i =0 ; i < N ; i++)
    {
        if(str[i] == 'R')
        {
            count_R++;
        }
        else
        {
            count_B++;
        }
    }
    if(count_R > count_B)
    {

        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
//#define MOD 1000000007
#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}

VVL g(150010);
map<LL,DB> dp[150010];
DB dfs(LL i,LL p,LL f=0){
  if(dp[i].count(p))return dp[i][p];
  LL n=g[i].size();
  if(p!=-1)n--;
  DB ret=0;
  if(f||p==-1){
    for(LL j:g[i])if(j!=p){
      ret+=dfs(j,i,f);
    }
  }else{
    ret=(dfs(i,-1,f)-1)*(n+1)-dfs(p,i,f);
  }
  if(n)ret=ret/n+1;
  return dp[i][p]=ret;
}

int main(){
  FAST;
  LL i,ans=0,N,u,v;
  cin>>N;
  rep(i,N-1){
    cin>>u>>v;
    g[u].EB(v);
    g[v].EB(u);
  }
  dfs(1,-1,1);
  FOR(i,1,N+1)printf("%.8f\n",dfs(i,-1));
}


Measured memory_bytes: 141056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] s = br.readLine().toCharArray();
		br.close();

		int n = s.length + 1;
		int[] arr = new int[n];

		for ( int i = 0; i <= n - 2; i++ ) {
			if ( s[i] == '<' ) {
				arr[i + 1] = arr[i] + 1;
			}
		}

		long ans = 0;
		for ( int i = n - 2; 0 <= i; i-- ) {

			if ( s[i] == '>' ) {

				if ( i <= 0 ) {
					arr[i] = arr[i + 1] + 1;
				} else if ( s[i - 1] == '<' ) {
					arr[i] = Math.max(arr[i], arr[i + 1] + 1);
				} else if ( s[i - 1] == '>' ) {
					arr[i] = arr[i + 1] + 1;
				}
			}

			ans += arr[i];
		}
		ans += arr[n - 1];

		System.out.println(ans);
	}
}

Measured memory_bytes: 29808
input_a,input_b = map(int, input().split())
#b1 = input_b % 10
#b10 = int((input_b - b1)/10)
count = 0

if input_a < 4 or input_b < 22:
    print(0)
    #print("case1")
else:
    for i in range(4, input_a+1):
        for j in range(22, input_b + 1):
            j1 = j%10
            j10 = (j-j1)/10
            if j1>=2 and j1*j10 == i:
                #print(i,j)
                count += 1
    print(count)
    #print("case2")



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

int main(){
  int n;cin >> n;
  vector<int> a(n);
  bool ans=true;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      ans=false;
    }
  }
  if(ans){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++) cin >> data[i];
  sort(all(data));
  int ans = 0;
  for(int i = 0; i < N - 1; i++) ans += data[i];
  ans += data[N - 1] / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int n;
vector<int> p, q;

int get(vector<int> &v)
{
	vector<int> v2 = v;
	sort(v2.begin(), v2.end());
	int cur = 0;
	while(true)
	{
		cur++;
		if(v == v2)
			return cur;
		next_permutation(v2.begin(), v2.end());
	}
}

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		p.push_back(x);
	}
	for(int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		q.push_back(x);
	}
	int ans = abs(get(p) - get(q));
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
module Main where
import Data.List

int = read :: String -> Int

main = interact $ printer . solver . parser

printer = unlines . (:[]) . show

parser = map int . tail . words

solver is = result 
  where
    ps = map (+1) is
    ms = map (subtract 1) is
    sorted = sort (ps ++ is ++ ms)
    result = maximum . map length . group $ sorted


Measured memory_bytes: 46332
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct {int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 6488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	cin >> N;
	ll sum=0,maxL=0;
	FOR(i,0,N){
		ll k;
		cin >> k;
		sum += k;
		maxL = max(maxL,k);
	}
	if(maxL<sum-maxL){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

using namespace std;

int main() {
    int n = 100001;

    vector<bool> prime(n, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i < n; i++) {
        if (prime[i]) {
            for (int j = 2 * i; j < n; j += i) {
                prime[j] = false;
            }
        }
    }

    vector<int> like(n, 0);
    for (int i = 2; i < n; i++) {
        like[i] += like[i - 1];
        if (prime[i] && prime[(i + 1) / 2]) {
            like[i]++;
        }
    }

    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << like[r] - like[l - 1] << endl;
    }
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

#define MAX 6400

int main()
{
	int i, j, H, W, A[82][82], B[82][82], D[82][82];
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) scanf("%d", &(A[i][j]));
	}
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			scanf("%d", &(B[i][j]));
			D[i][j] = abs(A[i][j] - B[i][j]);
		}
	}
	
	int k, dp[2][82][MAX + 1] = {};
	for (j = 2, dp[1][1][D[1][1]] = 1; j <= W; j++) {
		for (k = 0; k <= MAX; k++) {
			if (dp[1][j-1][k] == 1) {
				dp[1][j][abs(k - D[1][j])] = 1;
				if (k + D[1][j] <= MAX) dp[1][j][k + D[1][j]] = 1;
			}
		}
	}
	for (i = 2; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			for (k = 0; k <= MAX; k++) dp[i%2][j][k] = 0;
		}
		for (k = 0; k <= MAX; k++) {
			if (dp[1-i%2][1][k] == 1) {
				dp[i%2][1][abs(k - D[i][1])] = 1;
				if (k + D[i][1] <= MAX) dp[i%2][1][k + D[i][1]] = 1;
			}
		}
		for (j = 2; j <= W; j++) {
			for (k = 0; k <= MAX; k++) {
				if (dp[i%2][j-1][k] == 1) {
					dp[i%2][j][abs(k - D[i][j])] = 1;
					if (k + D[i][j] <= MAX) dp[i%2][j][k + D[i][j]] = 1;
				}
				if (dp[1-i%2][j][k] == 1) {
					dp[i%2][j][abs(k - D[i][j])] = 1;
					if (k + D[i][j] <= MAX) dp[i%2][j][k + D[i][j]] = 1;
				}
			}
		}
	}
	
	for (k = 0; k <= MAX; k++) if (dp[H%2][W][k] == 1) break;
	printf("%d\n", k);
	fflush(stdout);
	return 0;
}

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

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

using namespace std;

typedef int64_t ll;

const int MOD = 1000000007;

////// Mod int //////
struct mint {
	ll x;
	mint() :x(0) {}
	mint(ll x) :x((x% MOD + MOD) % MOD) {}
	// mint(ll x):x(x){}
	mint& fix() { x = (x % MOD + MOD) % MOD; return *this; }
	mint operator-() const { return mint(0) - *this; }
	mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
	mint& operator-=(const mint& a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; }
	mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
	mint operator+(const mint& a)const { return mint(*this) += a; }
	mint operator-(const mint& a)const { return mint(*this) -= a; }
	mint operator*(const mint& a)const { return mint(*this) *= a; }
	bool operator<(const mint& a)const { return x < a.x; }
	bool operator==(const mint& a)const { return x == a.x; }
};
istream& operator>>(istream& i, mint& a) { i >> a.x; return i; }
ostream& operator<<(ostream& o, const mint& a) { o << a.x; return o; }
typedef vector<mint> Vm;

/////////////////////

void init();
ll comb(ll, ll);
ll comb(int, int);
void initTable(int);

vector<ll> factMemo{ 1,1 }, factInvMemo{ 1, 1 }, invMemo{ 0, 1 };
int curMax{ 1 };

ll h, w, k;

int main()
{
	init();
	mint ans = 0;
	mint n_set = comb(h * w - 2, k - 2);

	REP1C(i, h)
		REP1C(j, w)
	{
		ll l = (ll)j * (j - 1) / 2 * h;
		ll r = (ll)(w - j + 1) * (w - j) / 2 * h;
		ll u = (ll)i * (i - 1) / 2 * w;
		ll d = (ll)(h - i + 1) * (h - i) / 2 * w;
		mint cst = l + r + u + d;
		cst *= n_set;
		ans += cst;
	}
	ans *= invMemo[2];
	cout << ans << endl;
}

void init()
{
	cin >> h >> w >> k;
}

void initTable(int n) {

	factMemo.resize(n + 1);
	factInvMemo.resize(n + 1);
	invMemo.resize(n + 1);

	for (; curMax < n;)
	{
		curMax++;
		factMemo[curMax] = factMemo[curMax - 1] * curMax % MOD;
		invMemo[curMax] = MOD - invMemo[MOD % curMax] * (MOD / curMax) % MOD;
		factInvMemo[curMax] = factInvMemo[curMax - 1] * invMemo[curMax] % MOD;
	}
}

ll comb(ll n, ll k) { return comb((int)n, (int)k); }
ll comb(int n, int k) {
	if (n < k || n < 0 || k < 0)
		return 0;

	if (curMax < n)
		initTable(n);

	return factMemo[n] * (factInvMemo[k] * factInvMemo[n - k] % MOD) % MOD;
}

//// done E in 70min on 30 Sep, 2019 ////


Measured memory_bytes: 4992
<?php 
  
  //自分の値以上引くことはない
fscanf(STDIN,"%d%d",$a,$b);

$diff=abs($a-$b)/2;

if(abs($a-$b)%2==0){
echo abs(min($a,$b)+$diff)."\n";
}else{
echo "IMPOSSIBLE\n";
}

Measured memory_bytes: 4604
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n = gi

puts n.count(5) == 2 && n.count(7) == 1 ? 'YES' : 'NO'

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

using namespace std;
typedef long long ll;

int main() {
  ll A; cin >> A;
  ll B; cin >> B;
  ll ans = max(A, B);
  if (ans == A) {
    cout << ans+max(A-1, B) << endl;
  } else {
    cout << ans+max(A, B-1) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	ll a,b,c,d; cin>>a>>b>>c>>d;
	--a;
	ll m=gcd(c,d);
	m=c*d/m;
	ll k=a/c+a/d-(a/(m));
	a-=k;
	ll l=b/c+b/d-(b/(m));
	b-=l;
	//cout<<"k:"<<k<<" l: "<<l<<endl;
	//cout<<a<<" "<<b<<endl;
	cout<<b-a<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3620
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int ans = 0;
			String s = sc.next().toUpperCase();
			while (true) {
				String[] ar = sc.nextLine().split(" ",0);
				if (ar[0].equals("END_OF_TEXT")) break;

				for (int i=0; i<ar.length; i++) {
					if (ar[i].toUpperCase().equals(s)) ans++;
				}
			}
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 26152
#include <bits/stdc++.h>
using namespace std;
char a[100005];
int main (){
  scanf ("%s",a+1);
  int n=strlen(a+1);
  if (a[1]!=a[n]) puts(n&1?"First":"Second");
  else puts((!(n&1))?"First":"Second");
  return 0;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))

a.sort()

M = 1000005
cnt = [0] * M

for i in range(n):
    if cnt[a[i]] != 0:
        cnt[a[i]] = 2
        continue
    for j in range(a[i], M, a[i]):
        cnt[j] += 1

ans = 0

for i in range(n):
    if cnt[a[i]] == 1:
        ans += 1

print(ans)

Measured memory_bytes: 32164
#include<bits/stdc++.h>
using namespace std;
const int N =110;
const int inf =1e5+100;
int main()
{
    int a,b;
    while(~scanf("%d%d",&a,&b))
    {
        if(b==1)
        {
            printf("0\n");
            continue;
        }
        int ans =1;

        b -=a;
        a--;

        if(b>0)
        {
            ans +=b/a;
            if(b%a)
                ans++;
        }

        printf("%d\n",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;

int main(){
    int N,M; cin>>N>>M;
    vector<int> ans(N,-1);

    bool flg = true;
    rep(i,M){
        int s,c; cin>>s>>c;
        s--;
        if(ans[s]==-1 || ans[s]==c){
            ans[s]=c;
        }else{
            flg = false;
        }
    }
    
    if(N>1){
        if(ans[0]==0) flg = false;
        if(ans[0]==-1) ans[0] = 1;
    }

    if(flg){
        for(int x:ans){
            if(x==-1) cout << 0;
            else cout << x;
        }    
        cout << endl;
    }else{
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3468
/*
    Author: FireDrake99
    Time created: 2019-10-19-18.59
*/

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

//------------Constants----------------
#define ll long long int
//------------Variables----------------
int a,b;
//------------Functions----------------

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//------------Input--------------------
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> a >> b;
//------------Work---------------------
    cout << max(0,a-2*b);
}


Measured memory_bytes: 256
N = int(input())

lst = [[0] * 10 for _ in range(10)]

for i in range(1, N + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    lst[a][b] += 1

ans = 0
for a in range(1, 10):
    for b in range(1, 10):
        ans += lst[a][b] * lst[b][a]

print (ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
unordered_map<ll , ll> mp , st ;
const ll N = 2e5 + 10 ;
ll a[N] ;
int main()
{
  ll n ;
  cin >> n ;
  for(ll i = 1 ; i <= n ;i ++) cin >> a[i] , mp[a[i]] ++ ;
  ll sum = 0 ;
  for(auto x : mp)
    sum += (x.second) * (x.second - 1) / 2 ;
  for(ll i = 1 ;i <= n ;i ++)
   {
     ll x = mp[a[i]] ;
     cout << sum - x * (x - 1) / 2 + (x - 1) * (x - 2) / 2 << endl ;
   }
  return 0 ;
}


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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)
#define print(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1> void __f(const char* name, Arg1&& arg1){
    cout << name << ": " << arg1 << '\n';
}

template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

int32_t main(){
    
    fast;

    int a; cin >> a;
    string s; cin >> s;

   bool flag = a<3200;
   if(!flag){
       cout << s;
   }else{
       cout << "red";
   }
 
 
 
    return 0;
} 

Measured memory_bytes: 256
s = gets.to_i

def f(n)
  if n.even?
    n / 2
  else
    3 * n + 1
  end
end

used = {}
found = false
n = s
i = 1
while true
  if used[n]
    puts i
    exit 0
  end
  used[n] = true
  n = f(n)
  i += 1
end


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define int long long

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

signed main()
{
  int n, a, b;
  cin >> n >> a >> b;

  cout << min(a, b) << " ";
  cout << (a+b-n > 0 ?  a+b-n : 0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
    ll n,sum=0,ans=MAX;cin>>n;
    ll a[n],s[n-1];
	for(ll i=0;i<n;i++) 
	{cin>>a[i];sum+=a[i];s[0]=a[0];
	 if(i>0 && i<n-1)
	 s[i]=a[i]+s[i-1];
	}
	for(ll i=0;i<n-1;i++)
	{
		ans=min(ans,abs(sum-2*s[i]));
	}
	cout<<ans;
    
	
	
	
 return 0;
}

Measured memory_bytes: 256
def main():
    n, add_time = map(int, input().split())
    times = list(map(int, input().split()))

    ans = add_time
    prev_finish = add_time
    for time in times:
        if time <= prev_finish:
            ans += add_time - (prev_finish - time)
        else:
            ans += add_time
        prev_finish = time + add_time
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 30848
#include <iostream>
#include <algorithm>

#define INF (1 << 29)

#define MAX_N 16

using namespace std;

int N, T[MAX_N][MAX_N + 1], dp[1 << MAX_N];

int main()
{
	int power2[MAX_N + 1];

	power2[0] = 1;

	for (int i = 1; i <= MAX_N; i++)
	{
		power2[i] = power2[i - 1] * 2;
	}

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j < N + 1; j++)
			{
				cin >> T[i][j];
			}
		}

		for (int i = 1; i < power2[MAX_N]; i++)
		{
			dp[i] = INF;
		}

		dp[0] = 0;

		//for (int i = 0; i < N; i++)
		//{
			for (int j = 0; j < power2[N]; j++)
			{
				for (int k = 0; k < N; k++)
				{
					if (j & power2[k])
					{
						dp[j] = min(dp[j - (1 << k)] + T[k][0], dp[j]);

						int val1 = j - power2[k];

						for (int l = 0; l < N; l++)
						{
							if (j & power2[l])
							{
								if (k != l)
								{
									dp[j] = min(dp[val1] + T[k][l + 1], dp[j]);
								}
							}
						}
					}
				}
			}
		//}

		cout << dp[power2[N] - 1] << endl;
	}

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int s = 0;
  for(int i = 0; i < N; ++i)
    cin >> A[i], s ^= A[i];
  for(int i = 0; i < N; ++i)
    cout << (s^A[i]) << (i+1 < N ? " " : "\n");
}


Measured memory_bytes: 3988
#include <stdio.h>
// #include <math.h>
// #include <stdlib.h>

int main(void) {

    int n;
    scanf("%d", &n); // search 1 to n

    for (int i=1; i<=n; i++) {
        int x = i;

        if (x % 3 == 0)
        {
            printf(" %d", i);
        }
        else if (x % 10 == 3)
        {
            printf(" %d", i);
        }
        else
        {
            do
            {
                x = x / 10;
                if (x % 10 == 3) {
                    printf(" %d", i);
                    break;
                }
            } while (x);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2720
#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;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N, K; cin >> N >> K;
    vector<int> A(N);
    int t = 0;
    rep(i, N) {
        cin >> A[i];
        if (A[i] == 1) t = i;
    }
    int ans = INF;
    for (int i=0; i<K; i++) {
        int l = t - i;
        int r = N - (t + K - i - 1) - 1;
        // cerr << l << " " << r << endl;

        int tmp = 1;
        if (l > 0) tmp += (l+K-1-1)/(K-1);
        if (r > 0) tmp += (r+K-1-1)/(K-1);
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}



Measured memory_bytes: 640
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int n, dp[500009]; string s;
int main() {
	cin >> n >> s;
	for (int i = 0; i < n - 2; i++) {
		dp[i + 3] = max(dp[i + 3], dp[i + 2]);
		if (s.substr(i, 3) == "101") {
			for (int j = i; j >= 0; j--) {
				if (s[j] != '1') break;
				dp[i + 3] = max(dp[i + 3], dp[j] + i - j + 1);
			}
			for (int j = i + 2; j < n; j++) {
				if (s[j] != '1') break;
				dp[j + 1] = max(dp[j + 1], dp[i] + j - i - 1);
			}
		}
	}
	cout << *max_element(dp, dp + n + 1) << endl;
	return 0;
}

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

using namespace std;

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

#define int ll


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

	if(d<=a){
		cout << d << endl;
	}else if(d<=a+b){
		cout << a << endl;
	}else{
		cout << a - (d-a-b) << endl;
	}

	return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>
int gcd(int x,int y){
    if(x%y)
        return gcd(y,x%y);
    else
        return y;
}
int main(void){
    int x,y;
    scanf("%d %d",&x,&y);
    printf("%d\n",gcd(x,y));
	return 0;		
}


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


int main() {
	int n, m; 
  cin >> n >> m;
  
	int a[2010], b[2010];
  
  long long c[2010] , dist[1010];
	
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i];
      
		c[i] = -c[i];
		a[i]--, b[i]--;
	}
	
	
	dist[0] = 0;
  
  for(int i=1;i<n;i++){
    dist[i] = 1000000000000000000000009;
  }
     
	for (int j = 0; j < n-1; j++) {
      
		for (int i = 0; i < m; i++) {
			if (dist[a[i]] == 1000000000000000000000009) continue;
          
			if (dist[b[i]] > dist[a[i]] + c[i]) {
				dist[b[i]] = dist[a[i]] + c[i];
			}
		}
	}
  
	long long ans = dist[n-1];

	bool abc[1010];
  
  for(int i=0;i<n;i++){
    abc[i] = false;
  }
  
	for (int j = 0; j < n; j++) {
		for (int i = 0; i < m; i++) {
			if (dist[a[i]] == 1000000000000000000000009) continue;
			if (dist[b[i]] > dist[a[i]] + c[i]) {
				dist[b[i]] = dist[a[i]] + c[i];
              
				abc[b[i]] = true;
			}
			if (abc[a[i]]) abc[b[i]] = true;
		}
	}

	if (abc[n-1])
		cout << "inf" << endl;
	else
		cout << -ans << endl;
}


Measured memory_bytes: 256
s = input()
if s == 'RRR':
    print(3)
elif s == 'RRS' or s == 'SRR':
    print(2)
elif s == 'RSS' or s == 'SRS' or s == 'SSR' or s == 'RSR':
    print(1)
elif s == 'SSS':
    print(0)

Measured memory_bytes: 9056
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include <queue>
#include <deque>
#include <numeric>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long LL;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< LL > vl;
typedef vector< vl > vvl;
typedef vector< bool > vb;
typedef pair <int, int> ii;
#define tr(c,it) for(decltype(c.begin()) it = c.begin(); it != c.end(); it++)
#define rep(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define repr(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define in(a,b) ( (b).find(a) != (b).end())


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

	int h, w;
	cin >> h >> w;

	vector < string > m(h);
	rep(i, h) cin >> m[i];

	vvl dp(h, vl(w));
	LL MOD = 1000000007;

	auto valid = [h, w] (int x, int y) -> bool { return x < h && y < w;};

	dp[0][0] = 1;
	rep(i, h) {
		rep(j, w) {
			if (m[i][j] == '.') {
				if (valid(i, j+1) && m[i][j+1] == '.') {
					dp[i][j+1] += dp[i][j];
					dp[i][j+1] %= MOD;
				}
				if (valid(i+1, j) && m[i+1][j] == '.') {
					dp[i+1][j] += dp[i][j];
					dp[i+1][j] %= MOD;
				}
			}
		}
	}

	cout << dp[h-1][w-1];
}


Measured memory_bytes: 9216
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-6
using namespace std;
typedef long long ll;
const int mods = 998244353;
const int maxn = 2e5+10;

ll n;
ll p[maxn];

inline long long read() {
    long long tmp=0, fh=1; char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
    while (c>='0'&&c<='9') tmp=tmp*10+c-48, c=getchar();
    return tmp*fh;
}

int main() {
	cin>>n;
	F(i,1,n) cin>>p[i];
	int maa=inf;
	int ans=0;
	F(i,1,n){
		if(p[i]<=maa){
			maa=p[i];
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1920
import math
import sys

a, b, x = map(int, input().split())
maxv = a**2 * b

if maxv == x:
    print(0)
    sys.exit()

if x >= maxv / 2:
    t = 2*b - (2 * x) / a**2
    tan = a / t
    print(90 - math.degrees(math.atan(tan)))
else:
    t = 2*x / (a * b)
    tan = 1 / (b / t)
    print(90 - math.degrees(math.atan(tan)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(auto i = 0 * (n); i < (n); ++i)
#define FOR(i, s, n) for(size_t i = (s); i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<double> Vector;
typedef vector<Vector> Matrix;

struct GaussJordan {
	typedef size_t T;
	GaussJordan(Matrix mat) : x(move(mat)) {
		T row = x.size(), col = x[0].size(), r = 0;
		REP(c, col) {
			T p = r;
			FOR(i, r, row) if (abs(x[i][c]) > abs(x[p][c])) p = i;
			swap(x[r], x[p]);
			if (abs(x[r][c]) > eps) {
				det *= x[r][c]; // ??????????????????????????????????????????
				FOR(j, c + 1, col) x[r][j] /= x[r][c];
				x[r][c] = 1;
				REP(i, row) if (r != i) {
					FOR(j, c + 1, col) x[i][j] -= x[i][c] * x[r][j];
					x[i][c] = 0;
				}
				if (++r == row) break;
			}
		}
		FOR(i, r, row) if (x[i][col - 1] > eps) impossible = 1; // ??????????????????????????????????????????
		rank = r;
	}
	const double eps = 1e-8;
	Matrix x;
	T rank;
	double det = 1; // mat ?????£??????????????? full rank ?????¨???????????????
	bool impossible = 0; // ?????¢????¬?????¨????????§£??????????????´???????????????????§£????????? <-> true
};

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios::sync_with_stdio(0);
	int d;
	while (cin >> d && d) {
		Vector b(d + 3); REP(i, d + 3) cin >> b[i];
		auto f = [&](const Matrix & m, double x) {
			double res = 0, cur = 1;
			REP(i, d + 1) {
				res += cur * m[i][m.size()];
				cur *= x;
			}
			return res;
		};

		Matrix A(d + 3, Vector(d + 2));
		REP(i, d + 3) {
			double cur = 1;
			REP(j, d + 1) {
				A[i][j] = cur;
				cur *= i;
			}
			A[i][d + 1] = b[i];
		}
		vector<int> cnt(d + 3);
		REP(i, d + 3) REP(j, i) {
			Matrix Ab;
			vector<pair<int, double>> t;
			REP(k, d + 3) {
				if (k == i || k == j) {
					t.push_back({ k, b[k] });
				} else {
					Ab.push_back(A[k]);
				}
			}
			auto gj = GaussJordan(Ab);
			REP(k, 2) {
				int x = t[k].first;
				cnt[x] += abs(t[k].second - f(gj.x, x)) > 1e-3;
			}
		}
		cout << max_element(ALL(cnt)) - cnt.begin() << endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  
  int64_t A = 2;
  int64_t B = 1;
  int64_t lucas;
  
  if (N == 0) cout << 2 << endl;
  else if (N == 1) cout << 1 << endl;
  else {
  //iはリュカ数のi番目を表す
  //ここでは2~N番目までのリュカ数を求める
  for (int i = 2; i <= N; i++) {
    lucas = A + B;
    
    //交互にAとBの中身を書き換える
    if (i % 2 == 0) {
      A = lucas;
    }
    else {
      B = lucas;
    }
  }
  cout << lucas << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int t[100000];
int main(){
	int n,m;	cin>>n>>m;
	vector<int> a(m);
	for(int i=0;i<n;i++)	t[i]=1e9;
	queue<int> q;
	for(int i=0;i<m;i++){
		cin>>a[i];	a[i]--;
		t[a[i]]=0;
		q.push(a[i]);
	}
	while(!q.empty()){
		int cur=q.front();	q.pop();
		if(cur+1<n){
			if(t[cur+1]>t[cur]+1){
				t[cur+1]=t[cur]+1;
				q.push(cur+1);
			}
		}
		if(cur-1>=0){
			if(t[cur-1]>t[cur]+1){
				t[cur-1]=t[cur]+1;
				q.push(cur-1);
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)	ans=max(ans,t[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

mat dist(10,vec(10,-1));

int main() {
    char c1, c2;
    cin>>c1>>c2;
    ll a = c1 - 'A', b = c2 - 'A';
    char ans;
    if(a==b) ans = '=';
    if(a > b) ans = '>';
    if(a < b) ans = '<';
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int d[n];
  rep(i, n) cin >> d[i];
  int ans = 0;
  rep(i, n) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = list(map(int, input().split()))
v = list(map(int, input().split()))
l = 0
r = 0
a = 0
m = min(n, k)+1
have = []
total = 0
ans = 0
for r in range(m):
    for l in range(m-r):
        have = []
        have.append(v[:r])
        if l != 0:
            have.append(v[-l:])
        else:
            have.append([])
        a = k-l-r
        data = have[0]+have[1]
        data.sort()
        for i in range(len(data)):
            if i < a and data[i] < 0:
                data[i] = 0
        total = sum(data)
        if total > ans:
            ans = total
print(ans)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,x,i,j,k,temp=0,count=0;
    cin>>a>>b>>c>>x;
    for(i=0;i<=a;i++){
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                temp=i*500+j*100+k*50;
                if(temp==x) count++;
            }
        }
    }cout<<count;
    return 0;
}


Measured memory_bytes: 3588