akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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(nullptr);

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int A, B;
    in2(A, B);

    if (B % A == 0)
    {
        outl(A + B);
    }
    else
    {
        outl(B - A);
    }
    return 0;
}

Measured memory_bytes: 3632
<?php
list($n, $m) = explode(' ', trim(fgets(STDIN)));

$ans = 0;

if($n < 2){
	$n_2 = 0;
}else{
	$fact = 0;
	for($i = $n - 1; $i > 0; $i--){
		$fact += $i;
	}
	$n_2 = $fact;
}

if($m < 2){
	$m_2 = 0;
}else{
	$fact = 0;
	for($i = $m - 1; $i > 0; $i--){
		$fact += $i;
	}
	$m_2 = $fact;
}
$ans = $n_2 + $m_2;

echo $ans;
?>


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y = 0;
  cin >> x;
  for (int a = 1; a < 121; a++) {
    for (int b = -120; b < a; b++) {
      if (pow(a,5)-pow(b,5) == x) {
        cout << a << ' ' << b;
        y = 1;
        break; 
      }
      else continue;
    }
    if (y == 1) break;
  }
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> S, T;

bool isOK(int index, int key) {
	if (S[index] >= key) return true;
	else return false;
}

int binary_search(int key) {
	int ng = -1;
	int ok = (int)S.size();
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (isOK(mid, key)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main(){
	int n;
	cin >> n;
	S.resize(n);
	for (int i = 0; i < n; i++) cin >> S[i];

	int q;
	cin >> q;
	T.resize(q);
	for (int i = 0; i < q; i++) cin >> T[i];

	int C = 0;

	for (int i = 0; i < q; i++) {
		int index = binary_search(T[i]);
		if (S[index] == T[i]) C++;
	}

	cout << C << endl;

	return 0;
}



Measured memory_bytes: 3280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long 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<double,int,double> 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-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
}








Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
    if(A[i]==0):
        print(0)
        exit()
for i in range(N):
    ans *= A[i]
    if(ans > 10**18):
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 21460
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

struct stc {ll s, t, c;};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll L; cin >> L;
    ll N = 0;
    for(ll i = 20; i >= 0; i--) if(L>>i & 1){
        N = i; break;
    }
    
    vector<stc> ans;
    rep(i, N){
        ans.pb({i+1, i+2, 0});
        ans.pb({i+1, i+2, 1ll<<i});
    }
    
    ll sum = 1ll<<N;
    for(ll i = N-1; i >= 0; i--) if(L>>i & 1){
        ans.pb({i+1, N+1, sum});
        sum += 1ll<<i;
    }
    
    cout << N+1 << " " << ans.size() << endstr;
    rep(i, ans.size()) cout << ans[i].s << " " << ans[i].t << " " << ans[i].c << endstr;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi pair<int,int>
#define mp(x,y) make_pair(x,y)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
const int maxn=2e5+999;

struct node{
	int x,y,posx,posy,L,R;
	node(int a,int b,int c,int d,int e,int f){x=a,y=b,posx=c,posy=d;L=e,R=f;}
	friend bool operator<(node a,node b){
		return a.x==b.x?a.y>b.y:a.x>b.x;
	}
};
int n;
struct seg{
	pi val[maxn<<2];
	void pushup(int rt){
		if(val[ls].first<val[rs].first)val[rt]=val[ls];
		else val[rt]=val[rs];
	}
	void build(int l,int r,int rt,int *a){
		if(l==r)return val[rt]=mp(a[l],l),void();
		int mid=l+r>>1;
		build(l,mid,ls,a);
		build(mid+1,r,rs,a);
		pushup(rt);
	}
	void modify(int pos,int l,int r,int rt){
		if(l==r){val[rt].first=INT_MAX;val[rt].second=0;return;}
		int mid=l+r>>1;
		if(pos<=mid)modify(pos,l,mid,ls);
		else modify(pos,mid+1,r,rs);
		pushup(rt);
	}
	pi query(int L,int R,int l,int r,int rt){
		if(L>R)return mp(-1,-1);
		if(L<=l&&r<=R)return val[rt];
		int mid=l+r>>1;pi ret=mp(INT_MAX,0);
		if(L<=mid)ret=query(L,R,l,mid,ls);
		if(R>mid){
			pi tmp=query(L,R,mid+1,r,rs);
			if(tmp.first<ret.first)ret=tmp;
		}
		return ret;
	}
}seg[2];
int a[maxn],b[2][maxn];
priority_queue<node>q;
node get(int l,int r){ 
	pi tmp1=seg[l&1].query(l,r,1,n,1),tmp2=seg[(l-1)&1].query(tmp1.second,r,1,n,1);
	seg[l&1].modify(tmp1.second,1,n,1);seg[(l-1)&1].modify(tmp2.second,1,n,1);
	node ret=node(tmp1.first,tmp2.first,tmp1.second,tmp2.second,l,r);
	return ret;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)b[0][i]=(!(i&1))?a[i]:INT_MAX;
	for(int i=1;i<=n;++i)b[1][i]=(i&1)?a[i]:INT_MAX;
	seg[0].build(1,n,1,b[0]);
	seg[1].build(1,n,1,b[1]);
	node s=get(1,n);
	q.push(s);
	while(q.size()){
		node now=q.top();q.pop();
		if(now.x==INT_MAX||now.y==INT_MAX)break;
		cout<<now.x<<" "<<now.y<<" ";
		int l=now.posx,r=now.posy;
		if(l+1<r-1)q.push(get(l+1,r-1));
		if(now.L<l-1)q.push(get(now.L,l-1));
		if(r+1<now.R)q.push(get(r+1,now.R));
	}
}

Measured memory_bytes: 16884
a = int(input())
last_run_dict = {0:["0"],1:["1"],2:["2"],3:["3"],4:["4"],5:["5"],6:["6"],7:["7"],8:["8"],9:["9"]}
s = 9
"""
新しい桁の数に対して前の桁の前後1の辞書から値をとってきて頭に足したものを再度格納する

"""
if a <= 9:
    print(a)
else:
    flag = False
    answer = ""
    while True:
        keta = 2
        tmp_dict = {0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[]}
        #0についてはカウントせずに0と1に対して先に格納
        for i in last_run_dict[0]:
            tmp_dict[0].append("0"+i)
        for i in last_run_dict[1]:
            tmp_dict[0].append("0"+i)
        #1~8については前後1、9については前1に対して格納してカウントを一つ進める
        for i in range(1,10):
            if i != 9:
                for num in range(-1,2):
                    for j in last_run_dict[int(i)+num]:
                        tmp_dict[i].append(str(i) + j)
                        s += 1
                        if s == a:
                            flag = True
                            answer = str(i) + j
                            break
                    if flag:
                        break
            else:
                for num in range(-1,1):
                    for j in last_run_dict[int(i)+num]:
                        tmp_dict[i].append(str(i) + j)
                        s += 1
                        if s == a:
                            flag = True
                            answer = str(i) + j
                            break
                    if flag:
                        break
            if flag:
                break
        if flag:
            break
        last_run_dict = tmp_dict
    print(answer)

Measured memory_bytes: 9076
import java.util.*;

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int maxim = 0;

        List<Integer> num1 = new ArrayList<>();
        List<Integer> num2 = new ArrayList<>();

        for (int i = 0; i < n; i++){
            num1.add(sc.nextInt());
        }
        for (int j = 0; j < n; j++){
            num2.add(sc.nextInt());
        }

        for (int k = 0; k < n; k++){
            if ((num1.get(k) - num2.get(k)) >= 1){
                maxim += (num1.get(k) - num2.get(k));
            }
        }
        System.out.println(maxim);
    }
}


Measured memory_bytes: 23252
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=b&&b<=c){
	printf("%d %d %d\n",a,b,c);
	}
	else if(a<=c&&c<=b){
	printf("%d %d %d\n",a,c,b);
	}
	else if(b<=a&&a<=c){
	printf("%d %d %d\n",b,a,c);
	}
	else if(b<=c&&c<=a){
		printf("%d %d %d\n",b,c,a);
	}
	else if(c<=a&&a<=b){
		printf("%d %d %d\n",c,a,b);
	}
	else {
		printf("%d %d %d\n",c,b,a);
	}
	return 0;
}

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

using namespace std;

int main(void) {
	int num, i, a, ma1 = 0, ma2 = 0, id = 0;
	cin >> num;
	for (i = 0; i < num; i++) {
		scanf("%d", &a);
		if (ma1 <= a) {
			id = i;
			ma2 = ma1;
			ma1 = a;
		}
		else if (ma2 <= a)
			ma2 = a;
	}
	for (i = 0; i < num; i++) {
		if (i == id)
			printf("%d\n", ma2);
		else
			printf("%d\n", ma1);
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdlib>

int main() {
  int a, b = 0;
  std::cin >> a >> b;


  if (a > 0 && b > 0) {
    std::cout << "Positive" << std::endl;
  } else if (a < 0 && b < 0) {
    int difference = std::abs(b - a);
    if (difference % 2 == 1) {
      std::cout << "Positive" << std::endl;
    } else {
      std::cout << "Negative" << std::endl;
    }
  } else {
    std::cout << "Zero" << std::endl;
  }

}

Measured memory_bytes: 256
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;
typedef pair < ll, ll > pl;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)3e5 + 5;
const int mod = (int)1e9 + 7;

int n, k;
int pr[MAX_N];

void read() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &pr[i]);
    }
}

vector < int > g[MAX_N];
int ans;
int sz[MAX_N];

void dfs(int v) {
    sz[v] = 0;
    for (auto to : g[v]) {
        dfs(to);
        if (v != 1 && sz[to] == k - 1) {
            ans++;
        } else {
            sz[v] = max(sz[v], sz[to] + 1);
        }
    }
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    read();
    
    if (pr[1] != 1)
        ans++, pr[1] = 1;
    for (int i = 2; i <= n; i++)
        g[pr[i]].pb(i);
    dfs(1);
    
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    int max;
    int min;
    cin >> n;
    vector<int> a(n);
    long long result = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        result += a[i]; //合計
    }
    min = a[0];
    max = a[0];
    for(int i = 0; i < n; i++){
        if(min > a[i]){
            min = a[i];
        }
        if(max < a[i]){
            max = a[i];
        }
    }
    cout << min << " ";
    cout << max << " ";
    cout << result << endl;
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdio.h>

#define _ << " " <<
#define debug(x) #x << " = " << x

#define ll long long
#define ull unsigned long long

char buf[200005];
int main()
{
    fread(buf, 1, sizeof(buf), stdin);
    int n = std::strlen(buf) - 1;

    ll ans = 1ll * n * (n - 1) / 2ll;
    for (int i = 0; i < 26; i++)
    {
        ll count = 0;
        char c = 'a' + i;
        for (int j = 0; j < n; j++)
            count += buf[j] == c;
        ans -= count * (count - 1) / 2;
    }

    printf("%lld\n", ans + 1);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

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

    int n; cin >> n;
    cout << 1-n << "\n";



}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

const int INF = 1000000000;

int main() {
  int H, W;
  char a[20][20];
  cin >> H >> W;
  rep(i, H) {
    rep(j, W) {
      cin >> a[i][j];
    }
  }
  int dist[20][20][20][20] = {0};
  rep(i, 20) {
    rep(j, 20) {
      rep(k, 20) {
        rep(l, 20) {
          if(i == k && j == l) continue;
          dist[i][j][k][l] = INF;
        }
      }
    }
  }
  rep(i, H) {
    rep(j, W) {
      if(a[i][j] == '#') continue;
      int dx[4] = {-1, 1, 0, 0};
      int dy[4] = {0, 0, -1, 1};
      rep(k, 4) {
        int ni = i + dx[k];
        int nj = j + dy[k];
        if(0 <= ni && ni < H && 0 <= nj && nj < W) {
          if(a[ni][nj] == '.') {
            dist[i][j][ni][nj] = 1;
          }
        }
      }
    }
  }

  rep(m, H) {
    rep(n, W) {
      rep(i, H) {
        rep(j, W) {
          rep(k, H) {
            rep(l, W) {
              dist[i][j][k][l] = min(dist[i][j][m][n] + dist[m][n][k][l], dist[i][j][k][l]);
            }
          }
        }
      }
    }
  }
  int ans = 0;    
  rep(i, H) {
    rep(j, W) {
      rep(k, H) {
        rep(l, W) {
          if(a[i][j] == '.' && a[k][l] == '.') {
            ans = max(ans, dist[i][j][k][l]);
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define be(v) (v).begin(), (v).end()
ll mod = 1000000007;

int main() {
	int n; cin >> n;
	ll s=0;
	vint a(n);
	rep(i,n) {
		cin >> a[i];
		s+=a[i];
	}
	ll ans=0;
	for(int i=0;i<n-1;i++) {
		s-=a[i];
		ans+=(s%mod)*a[i];
		ans%=mod;
	}
	cout << ans << endl;
}

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

int main(void)
{
    int N;
    cin >> N;
    int d[N];
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    long long sumHeal = 0;
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            sumHeal += d[i] * d[j];
        }
    }
    cout << sumHeal << endl;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx;
	int dy = ty - sy;
	string ans = string(dy, 'U');
	ans += string(dx, 'R');
	ans += string(dy, 'D');
	ans += string(dx, 'L');
	ans += string(1, 'L');
	ans += string(dy + 1, 'U');
	ans += string(dx + 1, 'R');
	ans += string(1, 'D');
	ans += string(1, 'R');
	ans += string(dy + 1, 'D');
	ans += string(dx + 1, 'L');
	ans += string(1, 'U');
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

int main() {
	
	int n, a;
	cin >> n >> a;
	cout << n * n - a << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        int n = s.length;
        int ans = Integer.MAX_VALUE;
        for (int i = 1; i < s.length-1; i++) {
            String f = String.format("%s%s%s", s[i-1], s[i], s[i+1]);
            int tmp = Integer.parseInt(f);
            ans = Math.min(ans, Math.abs(753 - tmp));
        }
        System.out.print(ans);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int maxn=1e5+5;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char str;
    cin>>str;
    if(str>='A'&&str<='Z'){
      cout<<"A"<<endl;
    }
    else{
      cout<<"a"<<endl;
    }
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  bool ans = false;
  rep(y, n) rep(x, n) {
    if (max(y, x) + m > n) continue;
    bool flg = true;
    rep(i, m) rep(j, m) flg &= (a[i + y][j + x] == b[i][j]);
    ans |= flg;
  }

  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
 
using namespace std;
int main()
{
    int k, n;
    cin>> k>> n;
    int h[n], d[n];
    for(int i=0; i<n; i++)
        cin>> h[i];
    for(int i=0; i<n-1; i++)
    {
        d[i]=h[i]+k-h[i+1];
    }
    d[n-1]=h[n-1]-h[0];
    sort(d, d+n);
    cout<< d[0]<<endl;
 
    return 0;
}

Measured memory_bytes: 1792
# 初期入力 2020-0730-2150

import sys
input = sys.stdin.readline  #文字列では使わない
H,W = map(int, input().split())
a =[]
for h in range(H):
    *aa, =input().strip()
    a.append(aa)

x =["."]*W
del_h =[]
for h in range(H):
    if a[h] ==x:
        del_h.append(h)

y =["."]*H
del_w =[]
for w in range(W):
    d =[]
    for h in range(H):
        if a[h][w] ==".":
            d.append(".")
    if d ==y:
        del_w.append(w)

for i in range(H):
    if i in del_h:
        continue
    for j in range(W):
        if j in del_w:
            continue
        print(a[i][j],end="")
    print()

Measured memory_bytes: 9224
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[0]]*N
ans = 0
for i in range(N):
  A[i] = list(map(int, input().split()))
  prod = 0
  for j in range(M):
    prod += A[i][j]*B[j]
  prod+=C
  if prod>0:
    ans +=1
  
print(ans)

Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	string s;
	cin >> s;
	int N = s.length();
	map<long long, int> mp;

	for (int i = 0; i < pow(2, N - 1); ++i) {
		string bit = "";
		for (int j = 1; j < pow(2, N - 1) ; j *= 2) {
			bit = to_string((i & j) / j) + bit;
		}

		string k = "";
		k += s[0];
		long long sum = 0;
		for (int j = 1; j < s.length(); ++j) {
			if (bit[j - 1] == '0') k += s[j];
			else {
				sum += stoll(k);
				k = s[j];
			}
		}
		sum += stoll(k);
		mp[sum]++;
	}

	long long sum = 0;
	for (auto x : mp) {
		sum += x.first * x.second;
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    int ans = (N*(N+1))/2;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,a[N],fa[22][N],L,q,x,y;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	scanf("%d%d",&L,&q);
	for (int i=1;i<n;i++){
		int l=i+1,r=n;
		while (l<r){
			int mid=(l+r+1)/2;
			if (a[i]+L>=a[mid])l=mid;
			else r=mid-1;
		}
		fa[0][i]=l;
	} 
	fa[0][n]=n;
	for (int i=1;i<=19;i++)
		for (int j=1;j<=n;j++)fa[i][j]=fa[i-1][fa[i-1][j]];
	while (q--){
		scanf("%d%d",&x,&y);
		if (x==y){
			puts("0");
			continue;
		}
		if (x>y)swap(x,y);
		int ans=0;
		for (int i=19;i>=0;i--)
			if (fa[i][x]<y)x=fa[i][x],ans+=1<<i;
		printf("%d\n",ans+1);	
	}
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int test=113023;
const int INF=1e9;
bool prime[300001];
bool is_prime(int n){
      if(n%6==0)return false;
      for(int i=1;i*i<=n;i++){
            if(n%(i*7+1)==0&&i*7+1!=n)return false;
            if(n%(i*7+6)==0&&i*7+6!=n)return false;
      }
      return true;
}
int main(){
      int n;
      memset(prime,false,sizeof(prime));
      for(int i=6;i<=300000;i++){
            if(i%7==1||i%7==6){
                  if(is_prime(i))prime[i]=true;
            }
      }
      while(scanf("%d",&n)&&n!=1){
            vector<int> ans;
            printf("%d:",n);
            if(n%6==0)ans.PB(6);
            for(int i=1;i*7+1<=n;i++){
                  if(n%(i*7+1)==0)if(prime[i*7+1])ans.PB(i*7+1);
                  if(n%(i*7+6)==0)if(prime[i*7+6])ans.PB(i*7+6);
            }
            REP(i,ans.size()){
                  printf(" %d",ans[i]);
            }
            puts("");
      }
}

Measured memory_bytes: 1512
// ARC094B.cpp
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll Q, n = 1e12, a, b;

int main()
{
    scanf("%lld", &Q);
    while (Q--)
    {
        scanf("%lld%lld", &a, &b);
        if (a > b)
            swap(a, b);
        ll ans = 0;
        if (a == b || a + 1 == b)
            ans += 2LL * a - 2;
        else
        {
            ll C = sqrt(1LL * a * b) - 1;
            while ((C + 1) * (C + 1) < 1LL * a * b)
                C++;
            if (C * (C + 1) >= 1LL * a * b)
                ans = 2LL * C - 2;
            else
                ans = 2LL * C - 1;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
x,n = map(int,input().split())
p = set(map(int,input().split()))
i = 0
while i <= x:
  if (x-i) in p and (x+i) in p:
    i+=1
  elif (x-i) in p:
    print(x+i)
    break
  elif (x+i) in p:
    print(x-i)
    break
  else :
    print(x-i)
    break

Measured memory_bytes: 9196
import java.util.*;

class Main {
    static int[] a;
    static ArrayList<Integer> ansArr = new ArrayList<Integer>();
    static int N = 1;

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

      int n = sc.nextInt();
      int q = sc.nextInt();

      while(N <= n) N *= 2;
      a = new int[2*N - 1];

      int com,x,y = 0;
      for(int i = 0 ; i < q ; i++) {
          com = sc.nextInt();
          x = sc.nextInt();
          y = sc.nextInt();
          if(com == 0) add(x, y);
          else ansArr.add(getSum(x, y, 0, 0, N-1));
      }

      for(int ans: ansArr) System.out.println(ans);
    }

    static void add(int x,int y) {
      x += N-1;
      a[x] += y;
      while(x > 0) {
        x = (x - 1)/2;
        a[x] = a[2*x+1] + a[2*x+2];
      }
    }

    static int getSum(int x, int y, int i, int l, int r) {
      if (r < x || y < l)
        return 0;
      if (x <= l && r <= y){
        return a[i];
      }else {
        int vl = getSum(x, y, i*2+1, l, (l+r)/2);
        int vr = getSum(x, y, i*2+2, (l+r+1)/2, r);
        return vl+vr;
      }
    }
}



Measured memory_bytes: 111480
def main():
    # s1 = list(map(int,input().split()))
    s = [input().split() for l in range(2)]
    X, N, p, v = int(s[0][0]), int(s[0][1]), {int(x): int(x) for x in s[1]}, 0
    for i in range(0, 100, 1):
        if X - i not in p:
            v = abs(X - i)
            break
        elif X + i not in p:
            v = abs(X + i)
            break
    print(v)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n,m,x; cin >>n >> m >> x;
        vll c(n); vector<vll> a(n,vll(m));

        rep(i,n){
            cin >> c[i];
            rep(j,m){
                cin >> a[i][j];
            }
        }
        ll ans = INF;
        rep(i,(1ll<<n)){
            ll tot =0;
            vll chk(m,0);
            rep(j,n){
                if(i&(1ll<<j)){
                    tot += c[j];
                    rep(k,m){
                        chk[k]+= a[j][k];
                    }
                }
            }
            bool working =true;
            rep(k,m){
                if(chk[k]<x){
                    working = false;
                    break;
                }
            }
            if(working){
                ans = min(ans,tot);
            }
        }
        if(ans ==INF){
            cout << -1 << endl;
        }else{
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N;
    cin >> N;
    lint A[N],B[N];
    rep(i,N) cin >> A[i] >> B[i];
    sort(A,A+N);
    sort(B,B+N,greater<lint>());
    lint md=(N+1)/2;
    lint lo=A[md-1];
    lint hi=B[md-1];
    if(N%2==1){
        cout << hi-lo+1 << endl;
    }
    else{ 
        cout << (B[md]+B[md-1])-(A[md]+A[md-1])+1 << endl;
    }
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    fcin;

    int n;
    cin >> n;
    bool ok = true;
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        if(x % 2 == 0 and x % 3 and x % 5) ok = false;
    }
    cout << (ok ? "APPROVED" : "DENIED") << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int n;
    vector<pair<long long,long long>> vp;
    long long a;
    long long b;
    
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> a >> b;
        vp.push_back({b,a});
    }
    
    sort(vp.begin(),vp.end());
    
    long long t = 0;
    int ans = 1;
    for (int i = 0;i < vp.size();i++){
        if (t > vp[i].first-vp[i].second){
            ans = 0;
            break;
        }
        else {
            t += vp[i].second;
        }
    }
    
    if (ans==1){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

using namespace std;

#define MOD 1000000007
#define N 3003
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

ld dp[N][N];
ld p[N];
ld ans;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, i, j, t;
    cin>>n;
    for(i=1; i<=n; i++){
        cin>>p[i];
    }
    dp[1][0] = p[1]; dp[1][1] = 1.0 - p[1];
    for(i=2; i<=n; i++){
        for(j=0; j<=i; j++){
            dp[i][j] = dp[i-1][j] * p[i];
            if(j > 0) dp[i][j] = dp[i][j] + dp[i-1][j-1] * (1.0 - p[i]);
        }
    }
    ans = 0;
    for(i=0; 2*i<n; i++){
        ans = ans + dp[n][i];
    }
    cout<<setprecision(20)<<fixed<<ans;
    return 0;
}

Measured memory_bytes: 139264
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

type st struct {
	ind int
	min int64
}

func main() {
	var X int64
	var K int64
	var D int64
	fmt.Scan(&X)
	fmt.Scan(&K)
	fmt.Scan(&D)
	if X < 0 {
		X = -X
	}
	div := X / D
	if K <= div {
		fmt.Print(X - K*D)
		return
	}
	tmp := X % D
	if div%2 == K%2 {
		fmt.Println(tmp)
	} else {
		fmt.Println(D - tmp)
	}
	// sc.Split(bufio.ScanWords)

}
func bc(s string, pos int) string {
	ch := "1"
	if string(s[pos]) == "1" {
		ch = "0"
	}
	pre := string(s[:pos])
	post := ""
	if pos != len(s)-1 {
		post = string(s[pos+1:])
	}
	tmp := pre + ch + post
	return tmp
}
func popCount(n string) int {
	count := 0
	for _, s := range n {
		if string(s) == "1" {
			count++
		}
	}
	return count
}
func chc(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for i, l := range m {
		tmp := []bool{}
		for _, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[i] = tmp
	}
	return ret
}
func chl(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for j, l := range m {
		tmp := []bool{}
		for i, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[j] = tmp
	}
	return ret
}
func helper(ma [][]bool) int {
	count := 0
	for _, l := range ma {
		for _, c := range l {
			if c == true {
				count++
			}
		}
	}
	return count
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 1840
#include<iostream>

using namespace std;

int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans = 0;
	if(k >= a) 
	{
		ans+=a;
		k -= a;
	}
	else 
	{
		cout<<k<<endl;
		return 0;
	}
	if(k <= b)
	{
		cout<<ans;
		return 0;
	}
	if(k > b) k-= b;
	ans -= k;
	cout<<ans;
	return 0;
}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using v = vector<T>;
using P = pair<int, int>;

/*
 *  */

const int mod = 1e9 + 7;

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

  string s;
  cin >> s;

  v<v<int>> dp(n, v<int>(n));
  rep(i, 0, n) dp[0][i] = 1;
  rep(i, 1, n){
    v<int> sum(n+1);
    rep(j, 0, n) sum[j+1] = (sum[j] + dp[i-1][j])%mod;
    if(s[i-1] == '<'){
      rep(j, 0, n-i) dp[i][j] = sum[j+1];
    }else{
      rep(j, 0, n-i) dp[i][j] = (sum[n-i+1]-sum[j+1]+mod)%mod;
    }
  }

  cout << dp[n-1][0] << endl;

//  rep(i, 0, n+1){
//    rep(j, 0, n-i) cout << dp[i][j] << " ";
//    cout << endl;
//  }

  return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
#include <map>
#include <climits>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
int main()
{
    char X, Y; cin >> X >> Y;
    cout << (X < Y ? '<' : X == Y ? '=' : '>') << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque


dh = [-1, 0, 1, 0]
dw = [0, 1, 0, -1]


H, W = map(int, input().split())
G = [input() for _ in range(H)]


# 色を変える前のマップ上の黒色マスを数える
def count_black():
    res = 0
    for i in range(H):
        for j in range(W):
            if G[i][j] == '#':
                res += 1
    return res


# 色を変えずにスタートからゴールまでの最短歩数を数える
def minimum_step():
    dist = [[0] * W for _ in range(H)]
    dist[0][0] = 1
    que = deque([[0, 0]])

    # BFS
    while que:
        h, w = que.popleft()
        for i in range(4):
            nh = h + dh[i]
            nw = w + dw[i]
            if nh < 0 or nw < 0 or nh >= H or nw >= W:
                continue
            if G[nh][nw] == '#':
                continue
            if dist[nh][nw]:
                continue
            dist[nh][nw] = dist[h][w] + 1
            que.append([nh, nw])
    return dist[H - 1][W - 1]


def main():
    step = minimum_step()
    print(H * W - step - count_black() if step else -1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 74024
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
const int inf = (int)1e18 + 10;

int dp[N][2] = {{0}} , a[N];
signed main(){
   int n;
  cin >> n;
  for(int i = 1 ; i <=n ; i++)
    cin >> a[i];

  dp[2][0] = - a[1] - a[2];
  dp[2][1] = a[1] + a[2];
  for(int i = 3 ; i<=n ; i++){
       dp[i][1] = max(dp[i-1][1] , dp[i-1][0] ) + a[i];
       dp[i][0] = max(dp[i-1][1] - 2*a[i-1] - a[i] , dp[i-1][0] + 2*a[i-1] - a[i]);
  }

  cout <<max(dp[n][0] , dp[n][1] ) << endl;
}	

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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

const LL INF = 1e18;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	LL a;
	LL w = 1;
	bool czy = 1;
	for(int i=0; i<n; i++) {
		cin>>a;
		if(a == 0) {
			cout<<0;
			return 0;
		}
		LL x = INF / w;
		if(x < a) {
			czy = 0;
		}
		if(czy)
			w*=a;
	}
	if(czy)
		cout<<w;
	else
		cout<<-1;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N,K;cin>>N>>K;
    if(N == 1){ cout<<1<<endl; return 0; }
	int m = sqrt(N) + 1;
	long dp[K+1][m+1][2];
	rep(i,1,m+1){ dp[0][i][0] = 1; dp[0][i][1] = 1; }
	rep(i,1,K+1){
        long res = 0;
		for(int j = 1; j <= m; j++){
			(res += dp[i-1][j][0]) %= mod;
			if(j == N / (N / j)) dp[i][j][1] = res;
		}
        if(m <= N / (m-1)) dp[i][m][0] = dp[i][m-1][1];
        else dp[i][m][0] = dp[i][m-2][1];
        for(int j = m - 1; j > 0; j--){
        	if(j == N / (N / j)){
                dp[i][j][0] = ((N/j - N/(j+1)) * dp[i-1][j][1]) % mod;
                (dp[i][j][0] += dp[i][j+1][0]) %= mod;
            }else dp[i][j][0] = dp[i][j+1][0];
		}
	}cout<<dp[K][1][0]<<endl;
}

Measured memory_bytes: 50176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> v(N);
    vector<bool> found(N, false);
    vector<ll> len(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> v[i];
        v[i]--;
    }

    ll cur = 0;
    ll times = 0;
    vector<ll> travel;
    
    while (true) {
        found[cur] = true;
        len[cur] = times;
        travel.push_back(cur);

        // next
        cur = v[cur];
        times++;
        if (found[cur]) break;
        if (times == K) break;
    }
    if (times == K) {
        cout << cur + 1 << endl;
    }
    else {
        if (len[cur] > K) {
            cout << travel[K] + 1 << endl;
        }
        else {
            ll close_dist = travel.size() - len[cur];
            K -= len[cur];
            ll idx = K % close_dist;
            cout << travel[idx + len[cur]] + 1 << endl;
        }
    }
}

Measured memory_bytes: 8428
H, W = map(int, input().split())
S = [input() for i in range(H)]
C = [[0 for i in range(W)] for j in range(H)]
 
dx = [1, 1, 0, -1, -1, -1, 0, 1]
dy = [0, 1, 1, 1, 0, -1, -1, -1]
 
for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      for k in range(8):
        if 0 <= j + dx[k] < W and 0 <= i + dy[k] < H:
          if S[i + dy[k]][j + dx[k]] == '#':
            C[i][j] += 1
    else:
      C[i][j] = '#'
 
for i in range(H):
  for j in range(W):
    print(C[i][j], end = '')
  print('\n')

Measured memory_bytes: 3444
import math
A,B,H,M = map(int, input().split())
H %= 12
M %= 60
dh = 360/12*(H+M/60)
dg = 360/60*M
th = max(dh,dg)-min(dh,dg)
print((A**2+B**2-2*A*B*math.cos(math.radians(th)))**0.5)

Measured memory_bytes: 9512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	InputStream inputStream = System.in;
    	OutputStream outputStream = System.out;
    	Scanner sc = new Scanner(inputStream);
    	PrintWriter out = new PrintWriter(outputStream);
      	String S = sc.next();
      	out.println(S.replace("2017", "2018"));
    	out.close();
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    char a;
    cin >> a;
    char msg = ('A' <= a and a <= 'Z') ? 'A' : 'a';
    cout << msg << endl;
    return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= N; i++)
			if(Integer.toString(i).length() % 2 == 1)
				ans++;
		System.out.println(ans);

	}

}


Measured memory_bytes: 29908