akhauriyash/Code-Regression huggingface dataset:
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

vector<ll> z_algorithm(const string& s) {
	vector<ll> prefix(s.length());
	for (int i = 1, j = 0; i < s.length(); i++) {
		if (i + prefix[i - j] < j + prefix[j]) {
			prefix[i] = prefix[i - j];
		}
		else {
			ll k = max(0ll, j + prefix[j] - i);
			while (i + k < s.size() && s[k] == s[i + k]) ++k;
			prefix[i] = k;
			j = i;
		}
	}
	prefix[0] = (int)s.size();
	return prefix;
}


ll n, ans;
int main() {
	string h;
	cin >> n >> h;
	while (h.length()) {
		auto mon = z_algorithm(h);
		for (int j = 1; j < mon.size(); ++j) {
			ans = max(ans, min(mon[j], (ll)j));
		}
		h.erase(0, 1);
	}
	cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  int a, b, c;
  a = n / 100;
  b = n / 10 - 10*a;
  c = n - (100*a + 10*b);
  if(a == 7 || b == 7 || c == 7)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3636
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

int f(int a){
	if(a==1)return 1;
	return 2*f(a/2)+1;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a;cin>>a;
	cout<<f(a)<<endl;
	
}









Measured memory_bytes: 256
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N = ri()
    S = ["a"] * N
    T = [0] * N
    for i in range(N):
        ss = rsa()
        S[i] , T[i] = ss[0], int(ss[1])
    X = rs()

    ans = 0
    sleep = False
    for i in range(N):
        if S[i] == X:
            sleep = True
            continue
        if sleep:
            ans += T[i]
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12512
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vt vector
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;
const int mxn=10000005;

int main()
{
  fastio;
  
  
  double d,t,s;
  cin>>d>>t>>s;
  double v=d/s;
 // cout<<v<<' ';
  if(v<=t)
  {
    cout<<"Yes";
  }
  else cout<<"No";
  
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N=0;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int64_t ans=0;
  int maxnum=0;
  for(int i=0;i<N;i++){
    maxnum=max(maxnum,A.at(i));
    int B=maxnum;
    ans+=B-A.at(i);
  }
  cout<<ans<<endl;
}

    


Measured memory_bytes: 4024
#include <iostream>
using namespace std;
typedef long long LL;
const LL INF=1LL<<30;
const int SIZE=4000;
LL A[SIZE];
LL DP[SIZE][SIZE];
LL solve(int s,int e,bool isJOI){
	if(s>e) return 0;
	if(DP[s][e]) return DP[s][e];
	if(isJOI)
		return DP[s][e]=max(solve(s+1,e,false)+A[s],solve(s,e-1,false)+A[e]);
	else if(A[s]<A[e]) return DP[s][e]=solve(s,e-1,true);
	else return DP[s][e]=solve(s+1,e,true);
}	
int main() {
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i];
		A[i+N]=A[i];
	}
	LL maxim=0;
	for(int i=0;i<N;i++){
		maxim=max(maxim,solve(i,i+N-1,true));
	}
	cout << maxim << endl;
	// your code goes here
	
	return 0;
}

Measured memory_bytes: 64164
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>

#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define un unsigned

#define mod 1000000007
#define MAXN 3001
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)



int main()
{
    fast;
    string s;
    cin>>s;
    if(s[2] == s[3] && s[4] == s[5])
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
dp = [[1] + [0 for i in range(K)] for j in range(N+1)]

for i in range(1, N+1):
    for j in range(1, K+1):
        dp[i][j] = dp[i-1][j] + dp[i-1][j-1]

for i in range(1, K+1):
    print((dp[N-K+1][i] * dp[K-1][i-1]) % (10**9+7))

Measured memory_bytes: 356488
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int a, b,c;
    cin >> a >> b >> c;
    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    
}




Measured memory_bytes: 3080
n=int(input())
keta=len(str(n))
count=0
i=1
# if keta%2==0:
# 	while keta-i>=0:
# 		10**i-10**(i-1)
# 		i+=2
# else:
# 	count+=n-10**(keta-1)+1

if keta%2!=0:
	count+=n-10**(keta-1)+1
	keta-=1
while keta-i>=0:
		count+=10**i-10**(i-1)
		i+=2
print(count)

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

// Problem https://atcoder.jp/contests/abc080/tasks/abc080_b

int sumDigit(int gNum){
    int result=0;
    while(gNum>0){
        int gMod = gNum % 10;
        result = result + gMod;
        gNum = gNum / 10; 
    }
    return result;
}

string solver(int gNum){
    string result="No";
    int gMod;
    gMod = gNum % sumDigit(gNum);
    if(gMod == 0){
        result = "Yes";
    }
    return result;
}

int main(void){
    int N;
    string answer;
    cin >> N;
    answer = solver(N);
    cout << answer << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	vector<vector<ll>> dp(n + 1, vector<ll>(2));
	dp[0][0] = 1;
	rep(i, n) rep(j, 2) {
		if (s[i] == '1') {
			dp[i + 1][1] = (dp[i + 1][1] + dp[i][j]) % mod;
		}
		else {
			dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
		}
		if (!(s[i] == '0' && j == 0)) dp[i + 1][j] = (dp[i + 1][j] + (dp[i][j] * 2) % mod) % mod;
	}
	dunk((dp[n][0] + dp[n][1]) % mod);
	return 0;
}


Measured memory_bytes: 5840
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int i,j,k,n,ans=0;
	cin>>n;
	int a[n*2];
	for(i=0;i<n*2;i++)
		cin>>a[i];
	sort(a,a+n*2);	
	for(i=0;i<n*2;i+=2)
		ans+=a[i];
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		double[] a = new double[n];
		double p = 0;
		for (int i = 0; i < n; i++) {
			p = sc.nextDouble();
			a[i] = (p+1)/2;
		}

		double ans = 0;
		for (int i = 0; i < k; i++) {
			ans += a[i];
		}
		double max = ans;
		int i = k;
		while(i<n) {
			ans += a[i]-a[i-k];
			if(ans > max) max = ans;
			i++;
		}
		System.out.println(max);
		sc.close();
	}
}

Measured memory_bytes: 161268
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

template <class T, class T2> long long modpower(long long radix, T x, T2 mod) {
    // 高速階乗計算 radix^x
    long long ans = 1;
    auto moder    = [&]() {
        if (mod != 0)
            ans %= mod;
    };
    while (0 < x) {
        if (x & 1) {
            ans = ans * radix;
            moder();
        }
        radix = radix * radix;
        moder();
        x >>= 1;
    }
    return ans == 0 ? 1 : ans;
}

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

    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    ll ans    = 3;
    int start = 1;
    if (s[0] != t[0]) {
        start = 2;
        ans   = 6;
    }
    FOR(i, start, s.size()) {
        if (s[i] == t[i] && s[i - 1] == t[i - 1]) {
            ans *= 2;
            ans %= MOD7;
        } else if (s[i] != t[i]) {
            if (s[i - 1] == t[i - 1]) {
                ans *= 2;
            } else {
                ans *= 3;
            }
            ans %= MOD7;
            i++;
        }
    }

    ans %= MOD7;
    print(ans);

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<pair<string, int>> p(N);
  string x;
    int y;
  int sum=0;
    for(int i = 0; i < N; i++){
        cin >> x >> y;
        p[i] = make_pair(x,y);
      sum+=y;
    }
  string s;cin>>s;
  int ans=0;
    for(int i = 0; i < N; i++){
      ans+=p[i].second;
        if(p[i].first==s)
        {
          break;
        }
          
    }
  cout<<sum-ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <vector>
 
 
int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	vector<int> a(n+1);
	vector<int> b(n+1);

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

	int m=0;
	for (int i=n; i>0 ; i--)
	{
		b[i]=a[i];
		for (int j=i+i;j<=n; j+=i)
		{
			b[i]+=b[j];
		}
		b[i]%=2;
		m+=b[i];
	}
	cout<<m <<endl;
	for (int i=1; i<=n; i++)
	{
		if (b[i]) cout<<i<<" ";
	}
	return 0;
}



Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n, a[90], St=1000, Buy, Sell;
int main()
{
    //I am Monim, a tiny creature of Allah
    cin >> n;
    for(i=1;i<=n;i++)
        cin >> a[i];
    for(i=1;i<n;i++)
    {
        if(a[i]<a[i+1])
        {
            St =(St/a[i])*(a[i+1]-a[i])+St;
        }
    }
    cout << St << endl;
    return 0;
}


Measured memory_bytes: 3564
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
#print(a)
cnt=0
for i in range(n):
    if (x-a[i]>=0):
        cnt=cnt+1
    x=x-a[i]
    #print(x)
if x <= 0:
    print(cnt)
else:
    print(cnt-1)


Measured memory_bytes: 2940
from collections import defaultdict
n = int(input())
dct = defaultdict(int)
for i in range(1,n+1):
    s = str(i)
    dct[(s[0],s[-1])] += 1
ans = 0
for i in range(1,n+1):
    s = str(i)
    ans += dct[(s[-1],s[0])]
print(ans)

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

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

    string keys[4] = {"AC", "WA", "TLE", "RE"};
    map<string, int> c {
        {keys[0], 0},
        {keys[1], 0},
        {keys[2], 0},
        {keys[3], 0},
    };

    for (auto i = 0; i < n; i++) {
        string s;
        cin >> s;

        c[s]++;
    }

    for (auto key: keys) {
        cout << key << " x " << c[key] << endl;
    }
}

Measured memory_bytes: 3604
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  vi dp(10010);
  dp[0] = 1;
  rep(i,n) {
    df(a);
    drep(j,sz(dp)-a) {
      dp[j+a] |= dp[j];
    }
  }
  drep(i,sz(dp)) if (dp[i] && i%10) {
    cout<<i<<endl;
    return 0;
  }
  cout<<0<<endl;
  return 0;
}






















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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n; i >= a; i--)
#define pb              push_back
#define lb              lower_bound		// first element >= val(itr) 
#define ub              upper_bound		// first element >  val(itr)
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))	//x can be 0 or -1

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }


const ll inf = 1e18;
const int nax = 1e5 + 5;

void SolveTestCase()
{
	ll n,m;
	cin>>n>>m;
	
	vector<ll> a(n);
	ll sum = 0;
	forn(i,0,n)
	{
		cin>>a[i];
		sum += a[i];
	}
	sort(all(a));
	reverse(all(a));
	
	if(a[m-1]*4*m >= sum)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	forn(i,0,t)
	{
		SolveTestCase();
	}

	return 0;
}


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

using namespace std;

struct xy {
    int x;
    int y;
};

xy A[900001];
long d[900001];

int main(void)
{
    int H, W, D;
    cin >> H; cin >> W; cin >> D;

    int num;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> num;
            A[num].x = j; A[num].y = i;
        }
    }
    // for (int i = 0; i < 10; i++) cout << A[i].x << endl;
    
    // 使用しないところを0にする
    for (int i = 0; i <= D + 2; i++) d[i] = 0;
    for (int i = 1; i + D <= H * W; i++) {
        d[i + D] = abs(A[i].x - A[i + D].x) + abs(A[i].y - A[i + D].y) + d[i];     
    }

    int Q;
    cin >> Q;
    int L, R;

    for (int i = 0; i < Q; i++) {
        cin >> L; cin >> R;
        long ans = d[R] - d[L];
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3840
import sys

N = int(input())

if N == 4:
  print(4)
  print('{} {}'.format(1, 2))
  print('{} {}'.format(1, 3))
  print('{} {}'.format(4, 3))
  print('{} {}'.format(4, 2))
  sys.exit()

if N % 2 == 0:
  M = N // 2 * 4
  print(M)
  for k in range(1, N // 2):
    print('{} {}'.format(k, k+1))
    print('{} {}'.format(k, N-k))
    print('{} {}'.format(N-k+1, N-k))
    print('{} {}'.format(N-k+1, k+1))
  print('{} {}'.format(1, N//2))
  print('{} {}'.format(1, N//2 + 1))
  print('{} {}'.format(N, N//2))
  print('{} {}'.format(N, N//2 + 1))
  sys.exit()

if N == 3:
  print(2)
  print('{} {}'.format(1, 3))
  print('{} {}'.format(2, 3))
  sys.exit()


if N % 2 == 1:
  M = (N // 2) * 4
  print(M)
  for k in range(1, N // 2):
    print('{} {}'.format(k, k+1))
    print('{} {}'.format(k, N-k-1))
    print('{} {}'.format(N-k, N-k-1))
    print('{} {}'.format(N-k, k+1))
  print('{} {}'.format(1, N))
  print('{} {}'.format(N-1, N))
  print('{} {}'.format(N // 2, N))
  print('{} {}'.format(N // 2 + 1, N))
  sys.exit()
  

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int ans = 700;
        for(int i = 0; i < 3; i++) {
            if(s.charAt(i) == 'o') {
                ans += 100;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc *bufio.Scanner

func nextString() string {
	sc.Scan()
	i := sc.Text()
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	s, p := nextString(), nextString()
	s = s + s
	var Flag bool
	for i := 0; i < len(s); i++ {
		Flag = true
		for j := 0; j < len(p); j++ {
			if i+j >= len(s) || s[i+j] != p[j] {
				Flag = false
				break
			}
		}
		if Flag {
			break
		}
	}
	if Flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



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

int main() {
  string s;
  cin >> s;
  for(int i=1; i<s.size(); i++){
    for(int j=0; j<i; j++){
      if(s[i] == s[j]){
        cout << "no" << endl;
        return 0;
      }
    }
  }
  cout << "yes" << endl;
}


Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include<algorithm>
#include<map>

using namespace std;


int main(){
  int n;
  string s;
  map<string,bool> Ans;
  cin >> n;
  while(n-- > 0){
    cin >> s;
    string s1,s2;
    for(int i=1;i<s.length();i++){
      s1 = s.substr(0,i);
      s2 = s.substr(i,s.length()-i);
      Ans[s1+s2] = true;
      Ans[s2+s1] = true;
      reverse(s1.begin(),s1.end());
      Ans[s1+s2] = true;
      Ans[s2+s1] = true;
      reverse(s1.begin(),s1.end());
      reverse(s2.begin(),s2.end());
      Ans[s1+s2] = true;
      Ans[s2+s1] = true;
      reverse(s1.begin(),s1.end());
      Ans[s1+s2] = true;
      Ans[s2+s1] = true;
    }
    cout << Ans.size() << endl;
    Ans.clear();
  }

  return 0;
}

Measured memory_bytes: 1300
#include <iostream>
#include <cassert>
#include <vector>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <string>
#include <sstream>
#include <iterator>
#include <map>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <limits>
#include <typeinfo>
 
#include <stdio.h>
#include <string.h>
 
 
using namespace std;
 
int main(int argc, char* argv[])
{

  long long int N, K, a, count, i, ans=0;
  long long int b[100001]={0};
 
  cin >> N >> K;
 
  while(N--){
    cin >> a >> count;
    b[a]+=count;
  }
 
  for(i=1;i<100001;i++){
    ans+=b[i];
    if(K<=ans){
      cout << i << endl;
      break;
    }
  }

	return 0;
	
}


Measured memory_bytes: 1024
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, m, c = sc.nextInt()
    val bs = List.fill(m)(sc.nextInt())
    val as = Array.ofDim[Int](n, m)

    for (i <- 0 until n) {
      for (j <- 0 until m) {
        val a = sc.nextInt()
        as(i)(j) = a
      }
    }

    println(as.count(a => {
      var tmp = 0
      for (i <- 0 until m) {
        tmp += a(i) * bs(i)
      }
      tmp + c > 0
    }))
  }
}


Measured memory_bytes: 25660
N,M,Q=map(int,input().split())
ABCD=[list(map(int,input().split())) for i in range(Q)]
from itertools import combinations
ans=0
for p in combinations(range(N+M-1),N):
    r=0
    for a,b,c,d in ABCD:
        if p[b-1]-b+1-(p[a-1]-(a-1))==c:
            r+=d
    ans=max(ans,r)
print(ans)

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

int main(int argc, char** argv) {
	int n, state = 0;
	int recent = 0;
	vector<int> a, b, c;
	cin >> n;
	a.resize(n);
	b.resize(n);
	c.resize(n - 1);
	for (auto &i : a) {
		cin >> i;
	}
	for (auto &i : b) {
		cin >> i;
	}
	for (auto &i : c) {
		cin >> i;
	}

	for (int i = 0; i < n; i++) {
		// cout << recent << endl;
		state += b.at(a.at(i) - 1);
		if (recent + 1 == a.at(i) && i > 0) {
			state += c.at(a.at(i - 1) - 1);
		}
		recent = a.at(i);
	}

	cout << state << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int N, M, C;
  cin >> N >> M >> C;

  int A[N][M];
  int B[M];

  for(int j=0;j<M;j++) cin >> B[j];

  for(int i=0;i<N;i++){
  	for(int j=0;j<M;j++){
  		cin >> A[i][j];
  	}
  }
  int count = 0;

  for(int i=0;i<N;i++){
  	int sum = 0;
  	for(int j=0;j<M;j++){
  		sum += A[i][j]*B[j];
  	}
  	if(sum+C>0) count++;
  }  
  
  cout << count <<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
mul=1
mx=10**18
for i in arr:
	if(i==0):
		print("0")
		exit(0)
for i in range(n):
	mul=mul*arr[i]
	if(mul>mx):
		print("-1")
		exit(0)
print(mul)

Measured memory_bytes: 84672
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a, b;
	cin >> a >> b;
	int ans = a + b;
	ans = max(ans, a*b);
	ans = max(ans, a - b);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
N = int(input())
cnt = 0
L = []
for i in range(N):
    x, l = map(int, input().split())
    L.append([x, l])

L.sort(key=lambda x: x[0])

for i in range(N):
    x, l = L[i]
    if i == 0:
        px, pl = x, l
    else:
        if px + pl >  x - l:
            cnt += 1
            if px + pl > x + l:
                px, pl = x, l
        else:
            px, pl = x, l
print(N - cnt)

Measured memory_bytes: 21356
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void){
	int n,W;
	scanf("%d %d",&n,&W);
	
	int weight[1010],value[1010];
	for(int i=0;i<n;i++){
		scanf("%d %d",&value[i],&weight[i]);
	}//ここまでが入力
	
	int dp[110][10010];
	for(int i=0;i<n;i++){
		dp[0][i] = 0;
	}//ここでｄｐの配列を初期化
	
	for(int i=0;i<n;i++){
		for(int j=0;j<=W;j++){
			if(j >= weight[i]){
				dp[i+1][j] = max(dp[i][j-weight[i]]+value[i],dp[i][j]);//選ぶパターンと選ばないパターンを比較
			}else{
				dp[i+1][j] = dp[i][j];
			}//ナップザックにものが入るかどうかを確認
		}//それを重さごとにやっています
	}//もの個数だけやります
	
	printf("%d\n",dp[n][W]);
	return 0;
}


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

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

int main (){
  int A,B,C;

  cin >> A>>B>>C;

  if((A+B)>=C)cout << "Yes"<<endl;
  else cout << "No"<< endl;


  return 0;
}


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

int main() {

	int n; cin >> n;
	vector<int> h(n);
	int hMax = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		hMax = max(hMax, h[i]);
	}
	vector<vector<int>> c(hMax, vector<int>(n, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < hMax; j++) {
			if (h[i] <= j) continue;
			else c[j][i] = 1;
		}
	}
	int ans = 0;
	for (int j = hMax - 1; j >= 0; j--) {
		for (int i = 0; i < n; i++) {
			if (i == n - 1) {
				if (c[j][i] == 1) ans++;
			}
			else {
				if (c[j][i + 1] == 0 && c[j][i] == 1) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
def s(a):
 if a:
  return(s(a//10) + a%10)
 else:
  return(0)
n = int(input())
ans = 10000000000000
for i in range(1,n//2+1):
 k = s(i) + s(n-i)
 if k < ans:
  ans = k
print(ans)

Measured memory_bytes: 2940
import sys
import math
M = 1000000
B = int(math.sqrt(M)+1)//6+1
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
i = 5
ini = 4
for p in range(B):
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])
    i += 6
    ini += 5

for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
    print(r)

Measured memory_bytes: 11936
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 

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


struct Node{
	int cnt;
	Node *left, *right;
	Node(){}
	Node(int cnt, Node *left, Node *right){
		this->cnt = cnt;
		this->left = left;
		this->right = right;
	}
 
	Node* insert(int s, int e, int val);
};
 
 
Node *null = new Node(0, NULL, NULL);
Node* root[100005];
 
Node* Node::insert(int s, int e, int pos){
	
	if(pos<s || pos>e)	return this;
 
	if(s == e)	return new Node(this->cnt+1, null, null);
 
	int mid = (s + e)/2;
	Node* resultant = new Node(this->cnt+1, this->left->insert(s, mid, pos), this->right->insert(mid+1, e, pos));
	return resultant;
}
 
 
int query(Node *a, Node *b, int s, int e, int lo, int hi){
	
	if(s > e || lo > e || s > hi)	return 0;
	if(s >= lo && e <= hi)	return b->cnt - a->cnt;
 
	int mid = (s + e)/2;
 	int x = query(a->left, b->left, s, mid, lo, hi);
 	int y = query(a->right, b->right, mid+1, e, lo, hi);
 	return x+y;
}


int n, m;
vector<int> arr[100005];


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

    ll n;
    cin>>n;

    ll ans = (n/11)*2;
    n -= (ans/2)*11;
    if(n >= 7)	ans += 2;
    else	if(n >= 1)	ans++;

    cout<<ans;
    return 0;
}








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

const ll INF = 1LL << 60;

vector<ll> G[100100];

int main() {
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        A[i]--;
        B[i]--;
    }

    for(int i = 0 ; i < M ; i++){
        G[A[i]].push_back(H[B[i]]);
        G[B[i]].push_back(H[A[i]]);
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        // cout << G[i].size() << endl;
        if (G[i].size() == 0) {
            ans++;
        } else {
           vector<ll> v = G[i];
           sort(v.rbegin(), v.rend());
           // cout << v[0] << endl;
           if (H[i] > v[0]) {
               ans++;
           }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 11464
n = int(input())
a = list(map(int, input().split()))
k = 0
num = sum(a)
import math

for i in range(n):
    reje = num - a[i]
    k += reje * a[i]

x = k//2
t = 10 ** 9 + 7
ans = x % t
print(ans)



Measured memory_bytes: 94208
import math
X, K, D = map(int, input().split())

if X > 0:
    p = math.ceil(X/D)
    if K < p:
        ans = X - K*D
    else:
        X -= p*D
        K -= p
        ans = X + (K % 2) * D
else:
    p = math.ceil(abs(X/D))
    if K < p:
        ans = X + K*D
    else:
        X += p*D
        K += p
        ans = X - (K % 2) * D

print(abs(ans))

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ods;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

void solve(ll t)
{
    // cout<<"Case #"<<t<<":\n";
    ll r;
    cin>>r;
    ld PI=3.14;
    ld ans=2*PI*r;
    cout<<fixed<<setprecision(20)<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    ll tt=1;
    while(t--)
    {
        solve(tt);
        tt++;
    }
}     


Measured memory_bytes: 3792
N = int(input())
S = list(int(input()) for _ in range(N))
SUM = sum(S)
S.sort()
for i in range(N):
  if SUM % 10 != 0:
    print(SUM)
    exit()
  if S[i] % 10 != 0:
    SUM -= S[i]
print(0)

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < K; i++) ans += p[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    vector<ll> acc(N + 1, 0);
    for (int i = 0; i < N; i++) acc[i + 1] = acc[i] + a[i];
    vector<vector<ll>> dp(N, vector<ll>(N + 1, 0));
    for (int w = 2; w <= N; w++) {
        for (int i = 0; i + w <= N; i++) {
            ll tmp = INF;
            for (int sep = i + 1; sep < i + w; sep++) {
                tmp = min(tmp, dp[i][sep] + dp[sep][i + w]);
            }
            dp[i][i + w] = tmp + acc[i + w] - acc[i];
        }
    }
    cout << dp[0][N] << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll MOD= 1000000007;
#define pb push_back
#define mpr make_pair

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];

	ll j=1,c=0;
	for(ll i=0;i<n;i++)
	{
		if(a[i]==j)
		{
			j++;
			
		}
		
		else
			c++;
	}
	
	if(c==n)
		cout<<-1<<endl;
	
	else
		cout<<c<<endl;	
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int f = sc.nextInt();

        int[] arr = {a,b,c,d,e};
        Arrays.sort(arr);

        if ((e-a)<=f)
            System.out.println("Yay!");
        else
            System.out.println(":(");
    }
}


Measured memory_bytes: 35772
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	stack<long long> gogo;
	long long ans = 0;
	REP(i, n) {
		long long tmp;
		cin >> tmp;
		if (gogo.empty() == false) {
			ans += max(0LL, gogo.top() - tmp);
		}
		while (gogo.empty() == false && gogo.top() > tmp) {
			gogo.pop();
		}
		gogo.push(tmp);
	}
	cout << ans + gogo.top() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int limit = 1000000;
int a[1000000];
int s;
int ans = 2;
int temp;
int collatz(int n)
{
    if (n % 2)
    {
        return 3 * n + 1;
    }
    else
    {
        return n / 2;
    }
}
int main()
{
    cin >> s;
    a[s]++;
    while (true)
    {
        s = collatz(s);
        if (a[s]++)
            break;
        ans++;
    }

    cout << ans << endl;
}

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

public class Main {
	static final int MOD = (int)1e9+7;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int[] d = sc.nextIntArray(n);
		
		Arrays.sort(d);
		
		int mid = (n/2)-1;
		
		out.println(d[mid +1] -  d[mid]);
		
		//1 4 4 6 7 9
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 34352
#include<stdio.h>
int max(int a,int b){return a>b ? a:b;}
int main(){
    int n,k,i,ans=1;
    scanf("%d%d",&n,&k);
    char s[n+1];
    scanf("%s",s);
    for(i=1;i<n;i++)
        if(s[i]!=s[i-1])
            ans++;
    printf("%d\n",n-max(ans-k*2,1));
    return 0;
}

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

typedef long long ll;
#define MOD1 1000000007
#define MOD2 1000000009
#define fr(a,b) for(ll i=a;i<b;i++)

const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int32_t main(){
#ifdef _MSC_VER
    _CRT_SECURE_NO_WARNINGS
#endif
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
#pragma warning(suppress: 4101) srand(time(nullptr));
    cout << setprecision(20) << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
        ll n;
        cin>>n;
       int ans=n-30;
       if(ans>=0)
           cout<<"Yes\n";
       else
           cout<<"No\n";
    }

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

#define froop1(a,n) for(long long i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N,sum = 0;
  cin >> N;
  froop1(1,N + 1){
    if(i % 3 != 0 && i % 5 != 0){
      sum += i;
    }
  }
  cout << sum << endl;

}

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


int main(){
	int n, k;
 	cin >> n >> k;
 	vector<int> choices(n, 0);
	for(int i = 0; i < n; i++){
		cin >> choices[i];
 	}
 	vector<bool> dp(k+1, false);
 	for(int i = 1; i < k + 1; i++){
		for(int j = 0; j < n; j++){
			if(i - choices[j] >= 0){
				dp[i] = dp[i] || !(dp[i-choices[j]]);
			}
		}
	}
 	if(dp[k])
		cout << "First" << endl;
    else
		cout << "Second" << endl;
	return 0;
}


Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

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

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }

}

use std::cmp::{max, min};

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    println!("{}", max(0, a - (2 * b)));
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(){
	while(1){
		int start,end,target,n;
		scanf("%d",&target);
		if(!target) break;
		scanf("%d",&n);
		while(n--){
			scanf("%d %d",&start,&end);
			target -= end-start;
		}
		if(target>0) printf("%d\n",target);
		else printf("OK\n");
	}
	return 0;
}

Measured memory_bytes: 1040
import java.util.*;

public class Main {
  private static int EVENTS = 3;

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

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < EVENTS; j++) {
        days[j][i] = scan.nextInt();
      }
    }
    scan.close();

    System.out.println(maxHappy(days, n));
  }

  private static int maxHappy(int[][] days, int n) {
    if (n == 0)
      return 0;

    int[][] dp = new int[EVENTS][n];
    for (int i = 0; i < EVENTS; i++) {
      dp[i][0] = days[i][0];
    }
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < EVENTS; j++) {
        int currentDayValue = days[j][i];
        for (int k = 0; k < EVENTS; k++) {
          if (k == j) continue;
          int previousDayOfAnotherType = dp[k][i - 1];
          dp[j][i] = Math.max(dp[j][i], currentDayValue + previousDayOfAnotherType);
        }
      }
    }

    int max = 0;
    int last = n - 1;
    for (int i = 0; i < EVENTS; i++)
      max = Math.max(max, dp[i][last]);
    return max;
  }
}


Measured memory_bytes: 92972
#include<iostream>
using namespace std;
int main()
{
    long long n, k, ans = 0;
    cin >> n;
    k = n;
    for(int i = 18; i >= 0; i--){
        ans += k % 10;
        k /= 10;
    }
    cout << (n % ans == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
	n = int(input())
	if n == 0:
		break
	w, h = map(int, input().split())
	count = 0
	table = [[False]*h for i in range(w)]
	for i in range(n):
		x, y = map(int, input().split())
		table[x-1][y-1] = True
	s, t = map(int, input().split())

	for i in range(w-s+1):
		for j in range(h-t+1):
			rc = ([row[j:j+t] for row in table[i:i+s]])
			count = max(count, (sum(rc, []).count(True)))
	print(count)

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

void chmax(int a, int b){
  int c = a;
  if(a > b){
    a = b;
    b = c;
  }
}

void chmin(int a, int b){
  int c = a;
  if(a < b){
    a = b;
    b = c;
  }
}

int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int n;
  cin>>n;
  int in[n],dp[n];
  rep(i,n){
    cin>>in[i];
    dp[i] = INF;
  }
  rep(i,n){
   	if(i==0) dp[i] = 0;
    else if(i==1) dp[i] = abs(in[i-1]-in[i]);
    else {
      dp[i] = min(dp[i-1] + abs(in[i-1]-in[i]), dp[i-2] + abs(in[i-2]-in[i]));
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main() {

	string s, t;
	int a, b;

	string u;

	cin >> s >> t >> a >> b >> u;

	if (s == u) a--;
	else if (t == u) b--;

	cout << a << " " << b;

	return 0;
}

Measured memory_bytes: 256
def lower(h)
  ans = 0
  cur = 0
  1.upto(h.size - 1) do |i|
    if h[i - 1] >= h[i]
      cur += 1
      ans = [ans, cur].max
    else
      cur = 0
    end
  end
  ans
end

n = gets.to_i
h = gets.split.map(&:to_i)

puts lower(h)

Measured memory_bytes: 11140