akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define N               200005
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fio(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

ll a[N], h[N];

struct Bit{
   ll b[N] = {};

   void update(ll i, ll val){
       while(i < N){
           b[i] = max(b[i], val);

           i += (i & (-i));
       }
   }

   ll query(ll i){
       ll ans = 0;

       while(i > 0){
           ans = max(ans, b[i]);
           i -= (i & (-i));
       }

       return ans;
   }

} f;

int main(){
    fio();

    ll n;
    cin>>n;

    for(ll z=1;z<=n;z++) cin>>h[z];
    for(ll z=1;z<=n;z++) cin>>a[z];

    ll res = INT16_MIN;
    for(ll x=1;x<=n;x++){
        ll q = f.query(h[x] - 1);

        res = max(res, q + a[x]);
        f.update(h[x], q + a[x]);
    }

    cout<<res;

    return 0;
}

Measured memory_bytes: 8348
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let n: usize = read!();
    let t: isize = read!();
    let a: isize = read!();
    let mut v = Vec::new();
    for i in 0..n {
        let h:isize = read!();
        v.push(h);
    }
    let t =t*1000;
    let a =a*1000;
    let mut ans = v
        .iter()
        .map(|hi| t - hi * 6)
        .map(|t| (t - a).abs())
        .enumerate()
        .sorted_by(|(aa, ab), (ba, bb)| ab.cmp(bb))
        .next()
        .unwrap().0;
    println!("{}",ans+1);
}

Measured memory_bytes: 2192
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
map<lli,lli>mp;
map<string,lli>ms;
set<string>ss;
set<lli>si;
set<char>sc;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S >> T;
  rep(i,0,S.size()){
    if(S[i]!=T[i])flag=1;
  }
  if(flag)Out("No");
  else Out("Yes");
}

Measured memory_bytes: 3652
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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


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


int main()
{
	int a, b;
	cin >> a>>b;
	int c = a * b;
	if (c % 2 == 0)
	{
		cout << "Even" << endl;

	}
	else
	{
		cout << "Odd" << endl;
	}



  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	int me[6];
	int cmp;
	int sum[5];
	int hasi;
	string str;
	sum[0]=1;
	sum[1]=1;
	sum[2]=1;
	sum[3]=1;
	sum[4]=1;
	sum[5]=1;
	for(int i=0;i<10;i++){
		cin >> n;
		if(n==0){
			hasi=i;
			break;
		}
		me[0]=1;
		me[1]=2;
		me[2]=3;
		me[3]=4;
		me[4]=5;
		me[5]=6;
			for(int i0=0;i0<n;i0++){
				cin >> str;
				if(str=="North"){
					cmp=me[0];
					me[0]=me[1];
					me[1]=me[5];
					me[5]=me[4];
					me[4]=cmp;
				}
				else if(str=="East"){
					cmp=me[0];
					me[0]=me[3];
					me[3]=me[5];
					me[5]=me[2];
					me[2]=cmp;
				}
				else if(str=="West"){
					cmp=me[0];
					me[0]=me[2];
					me[2]=me[5];
					me[5]=me[3];
					me[3]=cmp;
				}
				else if(str=="South"){
					cmp=me[0];
					me[0]=me[4];
					me[4]=me[5];
					me[5]=me[1];
					me[1]=cmp;
				}
				else if(str=="Right"){
					cmp=me[1];
					me[1]=me[2];
					me[2]=me[4];
					me[4]=me[3];
					me[3]=cmp;
				}
				else if(str=="Left"){
					cmp=me[1];
					me[1]=me[3];
					me[3]=me[4];
					me[4]=me[2];
					me[2]=cmp;
				}
				sum[i]+=me[0];
			}
			hasi=i;
	}
	for(int i=0;i<hasi;i++){
		cout << sum[i] << endl;
	}
	return 0;
}

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

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; }

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

ull dp[110][100100];
int main() {
    ll n, w;
    cin >> n >> w;
    vector<ll> value(n);
    vector<ll> weight(n);
    rep(i, n) cin >> weight[i] >> value[i];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= w; j++) {
            if (j - weight[i] >= 0) chmax(dp[i + 1][j], dp[i][j - weight[i]] + value[i]);
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[n][w] << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 81592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string S = GetString();
            string T = GetString();

            string TTrimEnd = T.Remove(T.Length-1);

            if(S == TTrimEnd)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            
            return;
        }
    }
}


public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() => int.Parse(getArg());
    public static long GetLong() => long.Parse(getArg());
    public static double GetDouble() => double.Parse(getArg());
    public static string GetString() => getArg();
    public static char GetChar() => getArg()[0];
    public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
    public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
    public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
    public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

Measured memory_bytes: 25808
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct flower
{
    int hi;
    int bty;
};
ll solve(vector<flower> &v, int n)
{
    vector<ll>dp(n+1);
    map<int,ll> meaningful;
    dp[1]  = v[1].bty;
    meaningful[v[1].hi] = dp[1];
    ll ans = dp[1];
    for(int i=2;i<=n;i++){
        dp[i] = v[i].bty;

        auto it = meaningful.lower_bound(v[i].hi+1);
        if(it != meaningful.begin())
        {
            it--;
            dp[i]+=it->second;
        }

        meaningful[v[i].hi] = dp[i];

        it = meaningful.upper_bound(v[i].hi);

        while(it!=meaningful.end() && it->second<=dp[i]){
            auto temp = it;
            temp++;
            meaningful.erase(it);
            it = temp;

        }

        ans = max(ans,dp[i]);
    }
    return ans;
}

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

    vector<flower> v(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> v[i].hi;
    for (int i = 1; i <= n; i++)
        cin >> v[i].bty;

    cout << solve(v, n);

    return 0;
}

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

int main(){
    int result = 0;
    int N,K;
    cin >> N >> K;
    int a[N];
    for (int i = 0; i < N; i++) cin >> a[i];
    int num[N];
    for (int i = 0; i < N; i++) num[i] = 0;
    for (int i = 0; i < N; i++) {
        num[a[i]-1]++;
    }
    int count = 0;
    for (int i = 0; i < N; i++) {
        int max = num[i], index = i;
        for (int j = i; j < N; j++) {
            if (max < num[j]) {
                max = num[j];
                index = j;
            }
        }
        if (max == 0 || count > K) break;
        if (index != i) {
            num[index] = num[i];
            num[i] = max;
        }
        count++;
    }
    for (int i = 0; i < K; i++) {
        result += num[i];
    }
    cout << N-result;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define INF 10001
int ans=0;
int main()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	b--;
	for(int i=1;i<=n;i++)
	{
		int input;
		cin>>input;
		if(a<=input&&input<=b)
			ans--;
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#include <map>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N,M;
ll a[500][500];
ll cnt[500];
ll ans = 114514;
int main(){
  cin >> N >> M;
  rep(i,N){
    rep(j,M){
      cin >> a[i][j];
    }
  }
  rep(i,M){
    rep(j,M+9){
      cnt[j] = 0; 
    }
    ll t_cnt = 0;
    ll p = 0;
    rep(j,N){
      rep(k,M){
        if(a[j][k] !=0){
          cnt[a[j][k]]++;
          if(t_cnt < cnt[a[j][k]]){
            t_cnt = cnt[a[j][k]];
            p = a[j][k];
          }
          break;
        }
      }
    }
    if(t_cnt < ans) ans = t_cnt;
    rep(j,N){
      rep(k,M){
        if(a[j][k] == p){
          a[j][k] = 0;
          break;
        }
      }
    }
    /*
    rep(j,N){
      rep(k,M){
        cerr << a[j][k] << " ";
      }
      cerr << endl;
    }
    cerr << endl;
    */
  }
  cout << ans << endl;
}


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

int main() {
    long long x,k,d;
    cin >> x >> k >> d;
    if(x < 0) x *= -1;

    long long ans;
    long long r = x/d;
    if(r > k) ans = x - (k*d);
    else if((k-r) % 2 == 0) ans = x - (r*d);
    else ans = (r+1) *d -x;
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    int n, len;
    string s;
    cin >> n >> s;
    len = s.length();
    for(int i=0;i<len;i++){
        char c = s[i] + n;
        if(c > 'Z'){
            c -= 26;
        }
        s[i] = c;
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;
const ll mod=998244353;

ll mod_pow(ll a,ll x){
    ll ans=1;
    for(int i=0;i<63;i++){
        if(x>>i&1){ans*=a; ans%=mod;}
        a*=a;
        a%=mod;
    }
    return ans;
}

ll R(ll a){
    return mod_pow(a,mod-2);
}


vector<ll> F={1,1};

ll c(ll n,ll k){
    if(n==0 || k==0){return 1;}
    if(n<k){return 0;}
    return F[n]*R(F[n-k])%mod*R(F[k])%mod;
}

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



int main(){
    ll T;
    cin>>T;
    while(T--){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<b){cout<<"No"<<endl;}
    else if(d<b){cout<<"No"<<endl;}
    else if(c>=b){cout<<"Yes"<<endl;}
    else{
        ll D=gcd(d,b);
        a%=b;
        d%=b;
        //cout<<(a+b-D)<<" "<<a<<" "<<D<<endl;
        if((a%D+b-D)%b>c){cout<<"No"<<endl;}
        else{cout<<"Yes"<<endl;}
    }
    }
    
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> ans(N);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    
    ans.at(a - 1)++;
    ans.at(b - 1)++;
  }
  
  for (int j = 0; j < N; j++) {
    cout << ans.at(j) << endl;
  }
}

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();
        String ans = "";
        int a=0;
        
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)=='0'){
                ans=ans+0;
                a++;
            }else if(s.charAt(i)=='1'){
                ans=ans+1;
                a++;
            }else{
                if(a!=0){
                    ans=ans.substring(0,a-1);
                    a--;
                }
            }
        }
        
        System.out.println(ans);
   }
}


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

int main()
{
    int n;
    int64_t d;
    cin >> n >> d;
    int count = 0;
    int64_t x, y;

    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        if (sqrt(x * x + y * y) <= d)
        {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long a[200500];
int main(){
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
    long long ans=1e18+7;
    for (int i=1;i+k-1<=n;i++){
        long long tmp=a[i+k-1]-a[i];
        if ((a[i]<0) && (a[i+k-1]<0)) tmp+=abs(a[i+k-1]);
        if ((a[i]>0) && (a[i+k-1]>0)) tmp+=a[i];
        if ((a[i]<0) && (a[i+k-1]>0)) tmp+=min(-a[i],a[i+k-1]);
        ans=min(ans,tmp);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author P.Alizadeh
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll,ll>     pll;
typedef complex<ld>     cld;

#define all(x)          x.begin(),x.end()
#define Sort(x)         sort(all(x))
#define kill(x)         return cout << x << endl, 0;
#define Mp              make_pair
#define X               first
#define Y               second
#define sep             " "
#define endl            "\n"
#define fastio          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define ld_io           cout << setprecision(10) << fixed;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll pw(ll a, ll b, ll md) {
    if (!b)
        return 1;
    if (b & 1)
        return a * pw(a * a % md, b / 2, md) % md;
    return pw(a * a % md, b / 2, md) % md;
}

const ll MAXN = 1e5 + 10,
         INF  = 8e18,
         MOD  = 1e9 + 7,
         LOG  = 32;
//const ld PI   = M_PI;

ll n, m, indeg[MAXN], dp[MAXN], ans;
vector<ll> g[MAXN], bg[MAXN], topo;

void kahn() {
    queue<ll> q;
    for (ll i = 1; i <= n; i++)
        if (indeg[i] == 0)
            q.push(i);

    while (!q.empty()) {
        ll u = q.front(); q.pop();
        topo.push_back(u);
        for (ll v : g[u]) {
            indeg[v]--;
            if (indeg[v] == 0)
                q.push(v);
        }
    }
}

int main()
{
    fastio;
    //ld_io;

    cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        ll u, v;
        cin >> u >> v;
        g[u].push_back(v);
        bg[v].push_back(u);
        indeg[v]++;
    }

    kahn();

    for (ll u : topo) {
        for (ll v : bg[u]) {
            dp[u] = max(dp[u], dp[v] + 1);
        }
        ans = max(ans, dp[u]);
    }

    cout << ans << endl;

    return 0;
}



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    ll n, k; cin >> n >> k;
    int cnt = 1;
    while (n / k > 0) {
        n =  n/ k;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
n=int(input())
c = [[0 for i in range(10)] for j in range(10)]

for i in range(n+1):
	left=int(str(i)[0])
	right=i%10
	c[left][right]+=1
	
ans=0
for i in range(1,10):
	for j in range(1,10):
		ans+=c[i][j] * c[j][i]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define badi_val 1000000007
int n;
int pd[1100];
const int mo=1e9+7;
int main(){
	string s;
  	cin >> s;
  	int i = 0 , j = s.size() - 1;
 	while(i < j){
     	 if(s[i] != 'A')
           i++;
      	 if(s[j] != 'Z')
           j--;
      	 if(s[i] == 'A' and s[j] == 'Z')
         {
            break;
         }
    }
  	if(i == j)
      cout << 0 << endl;
  	else
      cout << j - i + 1 << endl;
 	return 0;  
}

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

int main(void) {
    std::deque<int> deq;
    deq.emplace_back(1);
    for (int b=2;b<=1000;b++) {
        int tmp=b;
        for (int p=2;tmp*b<=1000;p++) {
            tmp=tmp*b;
            deq.emplace_back(tmp);
        }
    }
    sort(deq.begin(),deq.end());
    int n;
    cin>>n;
    auto result=find(deq.begin(),deq.end(),n);
    if (result!=deq.end()) {
        cout<<*result<<endl;
    } else {
        auto itr=lower_bound(deq.begin(),deq.end(),n);
        int hoge=distance(deq.begin(),itr);
        cout<<deq[hoge-1]<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Point{
    long long x,y;
    Point():x(0),y(0){}
    Point(long long _x,long long _y):x(_x),y(_y){}
};
struct Vector{
    long long x,y;
    Vector(long long _x,long long _y):x(_x),y(_y){}
};
Vector to_vector(Point a,Point b){
    return Vector(b.x-a.x,b.y-a.y);
}
long long cross(Vector a,Vector b){
    return (a.x*b.y)-(a.y*b.x);
}
// checks whether point B lies on line segment AC
bool on_line_segment(Point a,Point b,Point c){
    if(cross(to_vector(a,b),to_vector(b,c))==0
     &&min(a.x,c.x)<=b.x&&b.x<=max(a.x,c.x)
     &&min(a.y,c.y)<=b.y&&b.y<=max(a.y,c.y))return true;
    return false;
}
bool line_segment_intersection(Point a,Point b,Point c,Point d){
    if(cross(to_vector(a,b),to_vector(b,c))*cross(to_vector(a,b),to_vector(b,d))<0
     &&cross(to_vector(c,d),to_vector(d,a))*cross(to_vector(c,d),to_vector(d,b))<0)return true;
    if(on_line_segment(a,c,b)
     ||on_line_segment(a,d,b)
     ||on_line_segment(c,a,d)
     ||on_line_segment(c,b,d))return true;
    return false;
}
int q;
Point p[4];
int main(){
    scanf("%d",&q);
    while(q--){
        for(int i=0;i<4;i++)scanf("%lld %lld",&p[i].x,&p[i].y);
        if(line_segment_intersection(p[0],p[1],p[2],p[3]))puts("1");
        else puts("0");
    }
    return 0;
}

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

#define MAXOP 100
#define NUMBER '0'

int getop(char []);
void push(double);
double pop(void);

/*逆ポーランド電卓プログラム*/
main()
{
	int type;
	double op2;
	char s[MAXOP];

	while((type = getop(s)) != EOF) {
		switch (type) {
		case NUMBER:
			push(atof(s));
			break;
		case '+':
			push(pop() + pop());
			break;
		case '*':
			push(pop() * pop());
			break;
		case '-':
			op2 = pop();
			push(pop() - op2);
			break;
		case '/':
			op2 = pop();
			if (op2 != 0.0)
				push(pop() / op2);
			else
				printf("error: zero divisor\n");
			break;
		case '\n':
			printf("%.8g\n", pop());
			break;
		default:
			printf("error: unknown command %s\n", s);
			break;
		}
	}
	return 0;
}

#define MAXVAL 100

int sp = 0;
double val[MAXVAL];

/* push: fを値スタックにプッシュする*/
void push(double f)
{
	if (sp < MAXVAL)
		val[sp++] = f;
	else
		printf("error: stack full, can't push %g\n", f);
}

/* pop: スタックをポップし，一番上の値を返す*/
double pop(void)
{
	if (sp > 0)
		return val[--sp];
	else {
		printf("error: stack empty\n");
		return 0.0;
	}
}

#include <ctype.h>

int getch(void);
void ungetch(int);

/* getop:　次の演算子あるいは数値の被演算数をとってくる*/
int getop(char s[])
{
	int i, c;

	while ((s[0]= c = getch()) == ' ' || c == '\t')
		;
	s[1] = '\0';
	if (!isdigit(c) && c != '.')
		return c;	/*　cは数ではない */
	i = 0;
	if (isdigit(c)) /*　整数部を集める　*/
		while (isdigit(s[++i] = c = getch()))
			;
	if (c == '.') /*　小数部を集める　*/
		while (isdigit(s[++i] = c = getch()))
			;
	s[i] = '\0';
	if (c != EOF)
		ungetch(c);
	return NUMBER;
}

#define BUFSIZE 100

char buf[BUFSIZE];
int bufp =0;

int getch(void) /* 1文字を取ってくる */
{
	return (bufp > 0) ? buf[--bufp] : getchar();
}

void ungetch(int c) /* 文字を入力に戻す */
{
	if (bufp >= BUFSIZE)
		printf("ungetch: too many characters\n");
	else
		buf[bufp++] = c;
}



Measured memory_bytes: 2068
read = input 
rn = lambda :map(int, read().split())
n,m = rn()
A = list(rn())
l = len(A)
d = {}
for x in A:
    if x not in d:
        d[x]=0
    d[x] += 1
for i in range(m):
    b, c = rn()
    if c not in d:
        d[c]=0
    d[c] += b
A = list(d.items())
A.sort(reverse=True)
ans = 0
cnt = l
# print(A)
for v, c in A:
    tmp = min(cnt, c)
    ans += tmp * v
    cnt -= tmp
print(ans)

Measured memory_bytes: 39840
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
vector<vector<int>> A(3, vector<int>(3));//二次元配列[N][M][列][行]
for (int j = 0; j < 3 ; j++){
  for (int k = 0; k < 3; k++){
    cin >> A[j][k];
  }
}
int N ; cin >> N;
vector<int> b(N);
bool ans = false;
rep(i,N) cin >> b[i];
vector<vector<bool>> c(3, vector<bool>(3));
for (int j = 0; j < 3 ; j++){
  for (int k = 0; k < 3; k++){
    c[j][k] = false;
  }
}
rep(i,3){
	rep(j,3){
		rep(k,N){
			if(A[i][j] == b[k]){
				c[i][j] = true;
			}
		}
	}
}
if(c[0][0] && c[0][1] && c[0][2]) ans = true;
if(c[1][0] && c[1][1] && c[1][2]) ans = true;
if(c[2][0] && c[2][1] && c[2][2]) ans = true;
if(c[0][0] && c[1][0] && c[2][0]) ans = true;
if(c[0][1] && c[1][1] && c[2][1]) ans = true;
if(c[0][2] && c[1][2] && c[2][2]) ans = true;
if(c[0][0] && c[1][1] && c[2][2]) ans = true;
if(c[2][0] && c[1][1] && c[0][2]) ans = true;
if(ans) cout << "Yes" << endl;
else cout << "No" << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
tu=tuple(map(int,input().split()))
l=[0]*(N+1)
l[0]=0
ans=0
for i in range(1,N+1):
  l[i]=l[i-1]+(tu[i-1]+1)/2
  if i>=K:
    ans=max(ans,l[i]-l[i-K])
print(ans)

Measured memory_bytes: 72968
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong a, b;
  while(true){
    scanf("%lld %lld", &a, &b);
    if(a == 0 && b == 0) break;

    b -= a;
    llong c1 = 0, c2 = 0, c3 = 0;
    c1 = b / 1000;
    b = b % 1000;
    c2 = b / 500;
    b = b % 500;
    c3 = b / 100;

    printf("%lld %lld %lld\n", c3, c2, c1);
  }
  return 0;
}




Measured memory_bytes: 3160
n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort()
f.sort(reverse=True)

import numpy as np
a = np.array(a)
f = np.array(f)

low = -1
hi = 10**18

while hi-low > 1:
    ave = (hi+low)//2
    if np.maximum(0,a-ave//f).sum() <= k:
        hi = ave
    else:
        low = ave

print(hi)

Measured memory_bytes: 33940
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
// #include <prettyprint.hpp>
using namespace std;
typedef long long llong;
static const int max_n = 200010;
static const llong max_cost = 2000000000000000;
// vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
vector<vector<pair<llong, int>>> adj_list(max_n);
vector<llong> distance_table(max_n, max_cost);
vector<pair<llong, int>> points_sort_x;
vector<pair<llong, int>> points_sort_y;
// vector<pair<llong, int>> points_sort_y;

int N;


llong prim(int st){
    priority_queue<pair<llong, int>, vector<pair<llong, int>>, greater<pair<llong, int>>> PQ;
    llong total_weight = 0;
    vector<bool>used(N, false);
    PQ.push(make_pair(0, st));

    
    while(!PQ.empty()){
        auto u = PQ.top(); PQ.pop();
        // cout << u << endl;
        if(u.first>distance_table[u.second]||used[u.second])continue;
        // printf("start push\n");
        total_weight += u.first;
        distance_table[u.second] = u.first;
        used[u.second] = true;

        for(auto &v:adj_list[u.second]){
            if(distance_table[v.second] > v.first && !used[v.second]){
                PQ.push(make_pair(v.first, v.second));
            }
        }

    }

    return total_weight;
}

int main(){
    // int u, v;
    // bool updated = false;
    llong cost, ans, u, v;
    // printf("ok3\n");

    scanf("%d", &N);
    // printf("ok2\n");

    for(int i=0;i<N;i++){
        scanf("%lld %lld", &u, &v);
        points_sort_x.push_back(make_pair(u, i));
        points_sort_y.push_back(make_pair(v, i));
        // points_sort_y.insert(make_pair(v, i));
    }

    sort(points_sort_x.begin(), points_sort_x.end());
    sort(points_sort_y.begin(), points_sort_y.end());

    for(int i=0;i<N-1;i++){
        auto x1 = points_sort_x[i];
        auto x2 = points_sort_x[i+1];
        llong x_length = x2.first - x1.first;
        adj_list[x1.second].push_back(make_pair(x_length, x2.second));
        adj_list[x2.second].push_back(make_pair(x_length, x1.second));
        x1 = points_sort_y[i];
        x2 = points_sort_y[i+1];
        x_length = x2.first - x1.first;
        adj_list[x1.second].push_back(make_pair(x_length, x2.second));
        adj_list[x2.second].push_back(make_pair(x_length, x1.second));
    }


    // printf("ok1\n");

    ans = prim(0);

    printf("%lld\n", ans);


    return 0;

}

Measured memory_bytes: 21220
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<LL, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}


const int N = 1e5 + 100;
vector<int> G[N];

int DFS(int u) {
	vector<int> vec;
	for(int v : G[u]) {
		vec.push_back(DFS(v));
	}
	sort(vec.begin(), vec.end(), greater<int>());
	int ans = 0;
	for(int i = 0; i < SZ(vec); i ++) {
		ans = max(ans, i + 1 + vec[i]);
	}
	return ans;
}
int main() {
	int n, fa;
	cin >> n;
	for(int i = 2; i <= n; i ++) {
		scanf("%d", &fa);
		G[fa].push_back(i);
	}
	printf("%d\n", DFS(1));
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << 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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
const ll BetsuMOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	string s;
	cin >> s;
	int n = s.size();
	ll ans = 0;
	ll b = 0;
	rep(i, n) {
		if (s[i] == 'B') b++;
		else ans += b;
	}
	cout << ans << endl;
	return 0;
}

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

const int T[8][8] = 
  {
    {0,0,0,0,0,0,0,0},
    {0,0,300,500,600,700,1350,1650},
    {0,6,0,350,450,600,1150,1500},
    {0,13,7,0,250,400,1000,1350},
    {0,18,12,5,0,250,850,1300},
    {0,23,17,10,5,0,600,1150},
    {0,43,37,30,25,20,0,500},
    {0,58,52,45,40,35,15},
  };
const int h_begin = 17*60 + 30;
const int h_end = 19*60 + 30;

int main() {
  int s, sh, sm, t, th, tm;
  while(cin >> s && s) {
    cin >> sh >> sm;
    cin >> t;
    cin >> th >> tm;
    int a = s, b = t;
    if(a > b) swap(a, b);
    int cost = T[a][b];
    int dist = T[b][a];
    int in = sh * 60 + sm;
    int out = th * 60 + tm;
    if(dist <= 40 && 
       (h_begin <= in && in <= h_end ||
        h_begin <= out && out <= h_end) ) {
      cost /= 2;
      while(cost % 50) ++cost;
    }
    cout << cost << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
void primefactors(long long n){
   while(n%2==0){
    n=n/2;
    v.push_back(2);
   }
   for(int i=3;i<=sqrt(n);i+=2){
    while(n%i==0){
      v.push_back(i);
      n=n/i;
    }
   }
   if(n>2){
      v.push_back(n);
   }


}
 
 
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long n;
  cin>>n;
  if(n==1){
    cout<<0;
  }else{
  primefactors(n);
  sort(v.begin(),v.end());
  vector<pair<long long , long long >> c;
  c.push_back(make_pair(v[0],1));
  for(int i=1;i<v.size();i++){
    int d=c.size()-1;
    if(c[d].first==v[i]){
      c[d].second++;
    }else{
      c.push_back(make_pair(v[i],1));
    }
  }
  long long ans=0;
  for(int i=0;i<c.size();i++){
    int f;
    for(int j=1;j<=2*sqrt(c[i].second)+1;j++){
        if(j*j+j<=2*c[i].second){
        f=j;
        }
    }
    ans+=f;
  }
  cout<<ans;


  }

}
 
 
 
 

Measured memory_bytes: 3612
n, k = map(int, input().split())
if k > n:
    k = n
A = [int(i) for i in input().split()]
INF = 10 ** 12
dp = [INF] * n

dp[0] = 0
for i in range(1, n):
    for j in range(1, k + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(A[i] - A[i - j]))
    
print(dp[-1])

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size()<=k){
        cout << s;
    }else{
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+100;
int n,l,t,ans[N],wa,wb;
struct node
{
    int x,w,id;
}a[N];
node b[N],sh[N];
deque <int> s;
signed main()
{
    scanf("%lld%lld%lld",&n,&l,&t);
    for (int i=1;i<=n;i++)
    {
        int x,w;
        scanf("%lld%lld",&x,&w);
        sh[i].x=x,sh[i].w=w;
        if (w==1) a[++wa].x=x,a[wa].w=w,a[wa].id=i;
        else b[++wb].x=x,b[wb].w=w,b[wb].id=i;
    }
    if (wa==0 || wb==0)
    {
        for (int i=1;i<=n;i++)
        {
            if (sh[i].w==2) printf("%lld\n",(sh[i].x-t+l)%l);
            else printf("%lld\n",(sh[i].x+t)%l);
        }
        return 0;
    }
    for (int i=1;i<=wb;i++) s.push_back(b[i].x);
    for (int i=1;i<=wa;i++)
    {
        while (s.front()<a[i].x)
        {
            int x=s.front();
            s.pop_front();
            s.push_back(x+l);
        }
        int now=2ll*t,cnt=0;
        cnt=(now/l)*wb,now%=l;
        cnt+=upper_bound(s.begin(),s.end(),a[i].x+now)-s.begin();
        cnt%=n;
        if (a[i].id+cnt>n) sh[a[i].id].id=a[i].id+cnt-n;
        else sh[a[i].id].id=a[i].id+cnt;
    }
    s.clear();
    for (int i=1;i<=wa;i++) s.push_back(a[i].x);
    for (int i=wb;i>=1;i--)
    {
        while (s.back()>b[i].x)
        {
            int x=s.back();
            s.pop_back();
            s.push_front(x-l);
        }
        int now=2ll*t,cnt=0;
        cnt=(now/l)*wa,now%=l;
        cnt+=wa-(lower_bound(s.begin(),s.end(),b[i].x-now)-s.begin());
        cnt%=n;
        if (b[i].id-cnt<1) sh[b[i].id].id=n+b[i].id-cnt;
        else sh[b[i].id].id=b[i].id-cnt;
    }
    t%=l;
    for (int i=1;i<=n;i++)
    {
        if (sh[i].w==2) ans[sh[i].id]=(sh[i].x-t+l)%l;
        else ans[sh[i].id]=(sh[i].x+t)%l;
    }
    for (int i=1;i<=n;i++) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 9644
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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







int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    vector<ll> v;
    for(ll i = 1; i <= min(a, b); i++){
        if(a % i == 0 && b % i == 0){
            v.push_back(i);
        }
    }
    sort(v.begin(), v.end(), greater<ll>());
    cout << v[k - 1] << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
#from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

x=I()
a=I()
b=I()
ans=(x-a)%b
print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;


int main(void){
    int h,w;
    cin>>h>>w;
    for(int i=0;i<w+2;i++)cout<<'#';
    cout<<endl;
    for(int i=0;i<h;i++){
        cout<<'#';
        for(int j=0;j<w;j++){
            char in;
            cin>>in;
            cout<<in;
        }
        cout<<'#'<<endl;
    }
    for(int i=0;i<w+2;i++)cout<<'#';
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
S = list(map(int, input()))
length = len(S) - 1
for bit in range(2 ** length):
    ans = S[0]
    ope = ['+' if bit & (2 ** i) else '-' for i in range(length)]
    for i in range(1, length + 1):
        if ope[i-1] == '+':
            ans += S[i]
        else:
            ans -= S[i]
    if ans == 7:
        print('{}{}{}{}{}{}{}=7'.format(
            S[0], ope[0],
            S[1], ope[1],
            S[2], ope[2],
            S[3]))
        break


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

int main()
{
  string S;
  int A, B;
  cin >> A >> B;
  cin >> S;
  transform(S.begin() + B - 1, S.begin() + B, S.begin() + B - 1, ::tolower);
  cout << S <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int min(int x,int y){
    if(x>y) return y;
    else return x;
}
int main(void){
    int n,i;
    scanf("%d",&n);
    int h[n],dp[n];
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
        dp[i]=0;
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%d",dp[n-1]);
}

Measured memory_bytes: 2444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
const long long INF = 1LL << 60;
using namespace std;
// ------------------------

void solve() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A); rep(i, A) cin >> a[i];
    vector<int> b(B); rep(i, B) cin >> b[i];
    vector<int> x(M), y(M), c(M);
    rep(i, M) cin >> x[i] >> y[i] >> c[i];

    int min_a = *min_element(a.begin(), a.end());
    int min_b = *min_element(b.begin(), b.end());

    int ans = min_a + min_b;

    rep(i, M){
        int qupon = a[ x[i]-1 ] + b[ y[i]-1 ] - c[i];
        if( ans > qupon){
            ans = qupon;
        }
    }
    cout << ans << "\n";
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 2176
//Template Matching
#include <iostream>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    string a[n];
    string b[m];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<m; i++){
        cin >> b[i];
    }
    int x=0;
    int y=0;
    int z=0;
    for(int i=0; i<(n-m+1); i++){
        for(int j=0; j<(n-m+1); j++){
            int t=i;
            int s=j;
            int x=0;
            int y=0;
            while(a[t][s]==b[x][y]){
                s++;
                y++;
                if(x==(m-1) && y==m){
                    cout << "Yes" << endl;
                
                    return 0;       
                }
                else if(y==m){
                    y=0;
                    x++;
                    t++;
                    s-=m;

                }
                
            }
        }
    }
        cout << "No" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())
*c,=map(int,input().split())
print(sum(b)+sum(c[a[i]-1]for i in range(n-1) if a[i]+1==a[i+1]))


Measured memory_bytes: 9088
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Long> seven = new ArrayList<>();
        for (long i = 6; i <= 300000; i += 7) {
            seven.add(i);
            if (i + 2 > 300000) {
                break;
            }
            seven.add(i + 2);
        }
        List<Long> prime = new ArrayList<>();
        for (long num : seven) {
            if (isPrime(num)) {
                prime.add(num);
            }
        }
        while (true) {
            long n = sc.nextLong();
            if (n == 1) {
                return;
            }
            
            List<Long> ans = new ArrayList<>();
            for (long num : prime) {
                if (n % num == 0) {
                    ans.add(num);
                }
            }
            System.out.print(n + ":");
            for (long a : ans) {
                System.out.printf(" %d", a);
            }
            System.out.println();
        }
    }

    public static boolean isSeven(long x) {
        if (x % 7 == 1 || x % 7 == 6) {
            return true;
        }
        return false;
    }

    public static boolean isPrime(long x) {
        if (x == 1) {
            return false;
        }
        for (long i = 2; i * i <= x; i++) {
            if (x % i == 0 && isSeven(i)) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 39396
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<int(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<int> w(n);
    REP(i,n)cin>>w[i];
    vector<vector<int>> dp(n, vector<int>(n+1, 0));
    REP(i,n-1) {
      if (abs(w[i]-w[i+1]) <= 1) dp[i][2] = 2;
    }
    FOR(l,3,n+1) REP(i,n) {
      if (i+l > n) break;
      FOR(k,1,l) {
        dp[i][l] = max(dp[i][l], dp[i][k] + dp[i+k][l-k]);
      }
      if (dp[i+1][l-2] == l-2 && abs(w[i] - w[i+l-1]) <= 1) {
        dp[i][l] = l;
      }
    }
    cout << dp[0][n] << endl;
  }
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

LL k;
int n = 50;
LL a[50];

int main() {
    cin >> k;
    forn(i, n) a[i] = n - 1;
    LL whole = k / n;
    forn(i, n) a[i] += whole;
    k -= n * whole;
    forn(i, int(k)) {
        forn(j, n) a[j] -= 1;
        a[i] += n + 1;
    }
    cout << n << endl;
    forn(i, n) cout << a[i] << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,t,a[100005];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	n%=k;
	cout<<min(n,abs(n-k));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  int n; cin >> n;

  pair<int, int> result = {0, 0};
  for (int i = 1; i <= n; ++i) {
    int divisions = floor(log2(i & -i));

    if (result.second == 0 || divisions > result.second) {
      result = {i, divisions};
    }
  }

  cout << result.first << "\n";
}


Measured memory_bytes: 3676