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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
    int h,w; cin>>h>>w;
    char A[h][w];
    int cnt = 0;
    rep(i,h){
        rep(j,w){
            cin>>A[i][j];
            if(A[i][j] == '#') cnt++;
        }
    }
    int count = 1,i = 0,j = 0;
   // cout<<"cnt=="<<cnt<<endl;
while(1){
while(j<w&&A[i][j+1] == '#'){
    j++;
    count++;
    //cout<<"count=="<<count<<endl;
}
if(i == h-1 && j == w-1 && count == cnt){
    cout<<"Possible"<<endl;
    return 0;
}else if(A[i+1][j] == '#'){
    i++;
    count++;
}else
{
    cout<<"Impossible"<<endl;
    return 0;
}

}
    return 0;
}


Measured memory_bytes: 3620
n=int(input())
ans=0
for i in range(n):
  I=str(i+1)
  s=I[0];o=I[-1]
  if o=="0":continue
  if o==s:
    ans+=1
  a=(n-int(s))//10
  
  for j in range(6):
    chk=int(o)*(10**j)
    if chk<=a:
      if chk+10**j<=a:ans+=10**j
      else:
        ans+=a-chk+1
print(ans)

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

int main() {
    int x,y;
    vector<int> n(3);
    rep(i,3)
        cin >> n.at(i);
    sort(n.begin(), n.end());

    x = n.at(2)-n.at(1);
    y = n.at(2)-n.at(0)-x;
    if(y%2)
        x++, y++;
    cout << x+y/2 << endl;
}

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

int main()
{   int a,b;
   while(~scanf("%d%d",&a,&b))
   {
       int x,y,z,m;
       x=a+b;
       y=a-b;
       z=a*b;
       m=-999999;
       if(x>m)
        m=x;
       if(y>m)
        m=y;
       if(z>m)
        m=z;

       printf("%d\n",m);

       //printf("%d %d %d",x,y,z);
   }

    return 0;
}

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

int main() {
    int64_t ans, x;
    for (int64_t i = 0; i < 5; i++) {
        cin >> x;
        if (x == 0) {
            ans = i + 1;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        mut n: i64,
    }
    let mut ans = vec![];
    let mut k = 0;
    let mut tmp = 1;

    while n != 0 {
        if n & (1 << k) != 0 {
            ans.push('1');
            n -= tmp;
        } else {
            ans.push('0');
        }
        tmp *= -2;
        k += 1;
    }

    ans.reverse();
    if ans.len() == 0 {
        ans.push('0');
    }

    use std::iter::FromIterator;
    println!("{}", String::from_iter(ans.into_iter()));
}


Measured memory_bytes: 4352
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	vector<int>v(31);
	for (int i = 0; i < 28; i++) {
		cin >> N;
		v[N]++;
	}
	for (int i = 1; i <= 30; i++) {
		if (!v[i])cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,n,l;
  cin>>n;
  while(n!=0){
    int nn[4]={n%10,(n/10)%10,(n/100)%10,(n/1000)%10};
    //cout<<nn[3]<<nn[2]<<nn[1]<<nn[0]<<endl;
    if(nn[0]==nn[1]&&nn[1]==nn[2]&&nn[2]==nn[3]){
      cout<<"NA"<<endl;
    }else{
      int cou=0;
      while(nn[0]!=4||nn[1]!=7||nn[2]!=1||nn[3]!=6){
	int rn[4];
	for(int i=0;i<3;i++){
	  for(int j=i+1;j<4;j++){
	    if(nn[i]>nn[j]){
	      int exi=nn[i];
	      nn[i]=nn[j];
	      nn[j]=exi;
	    }
	  }
	}
	//cout<<nn[3]<<nn[2]<<nn[1]<<nn[0]<<' '<<nn[0]<<nn[1]<<nn[2]<<nn[3]<<endl;
	for(int i=0;i<4;i++){
	  rn[i]=nn[i];
	}
	for(int i=0;i<4;i++){
	  if(rn[i]-nn[3-i]<0){
	    rn[i]+=10;
	    rn[i]-=nn[3-i];
	    rn[i+1]--;
	  }else{
	    rn[i]-=nn[3-i];
	  }
	}
	for(int i=0;i<4;i++){
	  nn[i]=rn[i];
	}
	//cout<<nn[3]<<nn[2]<<nn[1]<<nn[0]<<endl;
	cou++;
      }
      cout<<cou<<endl;
    }
    cin>>n;
  }
  return (0);
}



Measured memory_bytes: 3112
n = int(input())

a = [int(input()) for _ in range(n)]

a.insert(0, 0)

i = 1
ans = 0
while True:
    if a[i] == 0:
        print(-1)
        exit()
    elif a[i] == 2:
        print(ans + 1)
        exit()
    a[i], i = 0, a[i]
    ans += 1

Measured memory_bytes: 7084
S = input()
n = len(S)
ans = 0
for bit in range(2**(n-1)):
  x = S[0]
  for i in range(n-1):
    if bit & (1<<i):
      x += '+'
    x += S[i+1]
  ans += sum(map(int, x.split('+')))
print(ans)

Measured memory_bytes: 9116
/*
    Author : manu_sy
*/
#include "bits/stdc++.h"
using namespace std;
 
/** Template Begins **/
 
typedef long long        ll;
typedef pair<int,int>    PII;
 
#define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(a)      (a).begin(), (a).end()
#define FOR(i,a,b)  for(int i=a;i<=b;i++)
#define LP(i,n)     for(int i=0;i< n;i++)
 
/* Debug */
 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.F << "," << P.S << ")";
} 
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr << sdbg << '=' << h << endl; }
 
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr << *sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
/* Debug Ends */
const int M = 19 + 1;
const int N = (1 << 19) + 7;
 
/** Template Ends **/
int n, a[N];
vector<int> dp[N];

 
signed main() {
 
    IOS;
    cin >> n;
    int m = (1 << n);
    for (int i = 0; i < m; i++) {
    	int x;	cin >> x;
    	dp[i].pb(x);
    }
    auto comb = [&] (vector<int> a, vector<int> b) {
    	a.insert(a.end(), all(b));
    	sort(all(a), greater<int>());
    	a.resize(2);
    	return a;
    };
    for (int i = 0; i < n; i++) {
    	for (int msk = 0; msk < m; msk++) {
    		if ((msk >> i) & 1) {
    			dp[msk] = comb(dp[msk], dp[msk ^ (1 << i)]);
    		}
    	}
    }
    int mx = 0;
    for (int i = 1; i < m; i++) {
    	debug(dp[i]);
    	int cur = dp[i][0] + dp[i][1];
    	mx = max(cur, mx);
    	cout << mx << endl;
    }
 
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << 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; }

void Main(){
    ll A; double B; cin >> A >> B;
    ll b = round(B*100);
    ll ans = A*b/100;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int maxn = -1;

const double eps = 1e-7;
bool eq(const double &a, double const &b) { return fabs(a - b) < eps; }
bool ls(const double &a, double const &b) { return a + eps < b; }

int main ()
{
	int n;
	scanf("%d",&n);
	if (n % 10 == 9 || n / 10 == 9)
		printf("Yes\n");
	else
		printf("No\n");

    return 0;
}


Measured memory_bytes: 256
//======================================
//author @Amit Singh : global_const
//======================================
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define yeah ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define vi vector<int>
#define pb push_back
#define loop(i,n) for(int i=0;i<n;++i)
#define pii pair<int,int>
#define mp make_pair
signed main()
{yeah;
 int n,k;
 cin>>n>>k;
 priority_queue<int, vector<int>, greater<int> > pq;
 for(int i=0;i<n;++i)
  {  int p;
    cin>>p;
 	pq.push(p);
  }
 ll sum=0;
 for(int i=0;i<k;++i)
 {sum+=pq.top();
  pq.pop();
 }
 cout<<sum<<endl;  	
 return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
int main(){
    int r; cin >> r;
    cout << 3*r*r;
}

Measured memory_bytes: 256
def divisor(x):
    ret = []
    for i in range(1, int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    return sorted(list(set(ret)))

def prime_factor(n):
    ass = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            ass.append(i)
            n = n // i
    if n != 1:
        ass.append(n)
    return len(set(ass))==1

n = int(input())

div = divisor(n)[1:]

l=[]
for i in div:
    if prime_factor(i):
        l.append(i)

ans = 0
for i in l:
    if n % i == 0:
        ans += 1
        n //= i
 
print(ans)

Measured memory_bytes: 69096
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
  ci(n>>k);
  ll ans=0;
  FOR(i,0,n){
    ll a;
    ci(a);
      ans+=min(k-a,a);
  }
  co(2*ans)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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 gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int r; cin >> r;
  if (r < 1200) std::cout << "ABC" << '\n';
  else if (r < 2800) std::cout << "ARC" << '\n';
  else std::cout << "AGC" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int n;
    cin >> n;
    n = n % 10;
    
    if(n == 3) {
        cout << "bon\n";
    } else if(n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon\n";
    } else {
        cout << "hon\n";
    }
    return(0);
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

/*==================================================*/

/*==================================================*/

int N, K, x;

int main() {
    cin>>N>>K;
    int ans = 0;
    REP(i,0,N){
        cin>>x;
        ans += 2 * min(x, K-x);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    class Program
    {


        static void Main(string[] args)
        {
            Solve();
        }

        static void Solve()
        {
            Scan sc = new Scan();
            write wr = new write();


            int[] c1 = sc.intarr;
            int[] c2 = sc.intarr;
            int[] c3 = sc.intarr;

            bool han = false;

            
            for(int i = 0; i <= 100; ++i)
            {
                for(int j = 0; j <= 100; ++j)
                {
                    for(int k = 0; k <= 100; ++k)
                    {
                        if(c1[0]-i==c1[1]-j&& c1[1]-j == c1[2]-k&& c2[0] - i == c2[1] - j && c2[1] - j == c2[2] - k && c3[0] - i == c3[1] - j && c3[1] - j == c3[2] - k)
                        {
                        han = true;
                        }
                    }
                }
            }

        if (han) wr.wri("Yes");
        else wr.wri("No");
        }
}


    class Scan
    {
    public string str => Console.ReadLine();

    public string[] strarr => str.Split(' ');

    public long[] longarr => strarr.Select(long.Parse).ToArray();
    public int [] intarr => strarr.Select(int.Parse).ToArray();



}

class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
    using namespace std;
    #define all(x) (x).begin(), (x).end()
    #define SZ(X) ((int)(X).size())
    #define endl "\n";
    int main()
    {
    	ios::sync_with_stdio(0);
    	cin.tie(0);
    	// freopen("input.txt", "r", stdin);
    	// freopen("output.txt", "w", stdout);
    	string s,a;
    	cin>>s;
    	set<char> t(all(s));
    	a = "abcdefghijklmnopqrstuvwxyz";
    	
    	for (auto c:a)
    	{
    		auto pos =t.find(c);
    		if(pos==t.end()){
    			cout<<c;	
    			return 0;
    		}
    		
    	}
    cout<<"None";
     
       return 0;
    }

Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>

using namespace std;

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<vector<int>> A(N);
  vector<int> C(N);
  for (int i = 0; i < N; ++i) {
    cin >> C[i];
    A[i] = vector<int>(M);
    copy_n(istream_iterator<int>(cin), M, A[i].begin());
  }

  int result = -1;
  int pat_num = (1 << N);
  vector<int> R(M);
  for (int i = 0; i < pat_num; ++i) {
    fill(R.begin(), R.end(), 0);
    int cost = 0;
    for (int j = 0; j < N; ++j) {
      if ((i >> j) & 1) {
        for (int k = 0; k < M; ++k) {
          R[k] += A[j][k];
        }
        cost += C[j];
      }
    }
    bool learned = true;
    for (int k = 0; k < M; ++k) {
      if (R[k] < X) {
        learned = false;
        break;
      }
    }
    if (learned) {
      if ((result == -1) || (cost < result)) {
        result = cost;
      }
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
signed main() {
    while (true) {
        ll b; cin >> b;
        if (b == 0) break;
        ll l = 1, r = 1;
        ll acc = 0;
        while(acc!=b){
            if(acc>b){
                acc-=l;
                l++;
            }
            if(b>acc){
                acc+=r;
                r++;
            }
        }
        cout << l << ' ' << r - l << endl;
    }
}


Measured memory_bytes: 3000
n = int(input())

nlll = {}
    
for i in range(n):
    aaa = int(input())
    if aaa in nlll:
        del nlll[aaa]
    else:
        nlll.update({aaa:1})

sums = 0
for i in nlll.values():
    sums = sums + i
print(sums)

Measured memory_bytes: 15072
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,K;
  char S[100];
  string J;
  cin>>N>>K;
  cin>>S;
   int index = K -1;
 	S[index] = S[index] + 32;
   cout<<S;
   return 0;
}

Measured memory_bytes: 256
<?php
$N = intval(trim(fgets(STDIN)));

$W = [];
for ($i = 0; $i < $N; $i++) {
    array_push($W,trim(fgets(STDIN)));
}

# 重複チェック
# array_uniqueがどの程度の速度のものかは調べてない
# けど、処理対象のサイズがせいぜい１００件なので、多分大丈夫
if ($W !== array_unique($W)){
    die('No');
}

# 繋がってるかチェック
for ($i = 0; $i < $N-1; $i++) {
    // 繋がってるかチェック
    if (substr($W[$i], -1, 1) !== substr($W[$i+1], 0, 1)) {
        die('No');
    }
}

echo 'Yes';
?>


Measured memory_bytes: 4604
n,m=gets.split.map &:to_i
a=[];b=[]
sum=m
ans=0
n.times do |i|
  a[i],b[i]=gets.split.map &:to_i
end
ab=a.zip(b).sort
ab.each{|k,v|
  if sum>=v
    sum-=v
    ans+=(k* v)
  else
    ans+=(k* sum)
    break
  end
}
puts ans


Measured memory_bytes: 22544
#include <stdio.h>

int main(void)
{
	int a,b,c;
	
	for(a=1;a<=9;a++){
		for(b=1;b<=9;b++){
			c=a*b;
			printf("%dx%d=%d\n",a,b,c);
		}
		b=1;
	}
	return 0;
}

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

int main(){
	char c;
	int count = 0;
	int diff = 0;
	char tmp = '0';

	while(cin >> c){
		++count;
		if(c == tmp){
		}else{
			++diff;
		}
		if(tmp == '0'){
			tmp = '1';
		}else{
			tmp = '0';
		}
	}

	if(diff > (count-diff)){
		cout << (count-diff) << endl;
	}else{
		cout << diff << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

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

int main(){
	ll x,y;
	cin >> x >> y;

    ll cnt = 0;

    while(x != y){
        //cout << x << " " << y << endl;
        if(x < y){
            if(0 <= x){
                cnt += y-x;
                x = y;
            }else if( 0 <= y){
                if(abs(x) <= abs(y)){
                    x = -x;
                    cnt++;
                }else{
                    cnt += abs(x)-abs(y);
                    x = -y;
                }
            }else{
                 cnt += abs(x)-abs(y);
                 x = y;
            }
        }else{
            if(x < 0){
                x = -x;
                cnt++;
            }else{
                if(abs(x) < abs(y)){
                    cnt += abs(y)-abs(x) + 1;
                    x = y;
                }else{
                    cnt++;
                    x = -x;
                }
            }
        }
    }

    cout << cnt << endl;
	return  0;
}

Measured memory_bytes: 256
import numpy as np

if __name__ == "__main__":
    N = int(input())
    mod = 1000000007
    def power_func(a,n,p):
        bi = str(format(n,"b"))#2進表現に
        res = 1
        for i in range(len(bi)):
            res = (res*res) %p
            if bi[i] == "1":
                res = (res*a) %p
        return res

    if N <= 1:
        print(0)
    elif N == 2:
        print(2)
    else:
        Ans = (power_func(10,N,mod) - 2 * power_func(9, N, mod) + power_func(8,N,mod))%mod
        print(Ans)

Measured memory_bytes: 27148
import heapq
import math
n,m=map(int, input().split())
hp=list(map(lambda x:-1*int(x), input().split()))
heapq.heapify(hp)
for _ in range(m):
  item=heapq.heappop(hp)
  heapq.heappush(hp, math.ceil(item/2))
  
print(sum(hp)*-1)


Measured memory_bytes: 20596
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int t,i,j,q,p,b[105],sum[105],ans,trueans;
        char a[105];
    cin>>t;
    cin>>a;
    trueans=0;
    for(i=0;i<t;i++)
    {
        ans=0;
        for(j='a';j<='z';j++)
        {
            int tmp=0;
            for(q=0;q<=i;q++)
            {
                if(a[q]==j)tmp++;
            }
            int tmp2=0;
            for(q=i+1;q<t;q++)
            {
                if(a[q]==j)tmp2++;
            }
            if(tmp>0&&tmp2>0) ans++;
        }
        trueans=max(trueans,ans);
    }
    cout<<trueans;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = map(int, input().split(" "))

color_types = [False]*8
pro_count = 0
for a_i in a:
	if a_i < 3200:
		color_types[a_i//400] = 1
	else:
		pro_count += 1
print(max(1, sum(color_types)), sum(color_types)+pro_count)

Measured memory_bytes: 2940
import sys
input = sys.stdin.buffer.readline
MOD = 998244353

N, S = map(int, input().split())
A = list(map(int, (input().split())))
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += dp[i][j]*2
        dp[i+1][j] %= MOD
        if j+A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j]
            dp[i+1][j+A[i]] %= MOD
print(dp[-1][S])

Measured memory_bytes: 139060
#include<bits/stdc++.h>
using namespace std;
int main()
{

	set< int > s;
	int n, k, d, x;

	cin >> n >> k;

	for ( int i = 0; i < k; i++ )
	{
		cin >> d;

		for ( int j = 0; j < d; j++ )
		{
			cin >> x;
			s.insert ( x );
		}
	}

	cout << n - s.size() << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  int64_t a, b, x;
  cin >> a >> b >> x;
  int64_t count=0;
    
  if(a % x == 0){
  	count = b / x - a/ x +1;
  }
  else{
  	count = b/ x - a/ x;
  }
    
    
	cout << count << endl;
}

Measured memory_bytes: 256
a = []
for i in range(5):
    b = int(input())
    c = b % 10 if b % 10 != 0 else 9
    d = (b + 10 - 1) // 10 * 10
    a.append([b, c, d])
a = sorted(a, key=lambda x: x[1], reverse=True)
total = 0
for i in range(len(a)):
    total += a[i][2]
print(total - a[i][2] + a[i][0])


Measured memory_bytes: 3316
def main():
    N = int(input())
    A = list(int(x) for x in input().split())
    B = list(int(x) for x in input().split())
    C = list(int(x) for x in input().split())
    ans = 0
    a1 = N

    for a in A:
        ans += B[a-1]
        if a - a1 == 1:
            ans += C[a1-1]
        a1 = a
    print(ans)

if __name__ == '__main__':
    main()

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

e = [0 for _ in range(n)]
for i in range(1, n):
    e[i] = a[i] - a[i-1]
e[0] = k + a[0] - a[-1]
print(k - sorted(e, reverse=True)[0])


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

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

void Main(){
  int N, K; cin >> N >> K;
  string S; cin >> S;
  int L = 0, R = 0;
  char cur = S[0];
  rep(i, 1, N){
    if(S[i] == cur){
      
    }else{
      if(cur == 'L'){
        L++;
        cur = 'R';
      }else{
        R++;
        cur = 'L';
      }
    }
  }
  if(cur == 'L'){
    L++;
  }else{
    R++;
  }
  if(S.front() == 'L'){
    if(R <= K){
      cout << N - 1 << endl;
      return;
    }else{
      if(S.back() == 'L'){
        cout << N - 2 * (R - K) - 1 << endl;
        return;
      }else{
        cout << N - 2 * (R - K) << endl;
        return;
      }
    }
  }else{
    if(L <= K){
      cout << N - 1 << endl;
      return;
    }
    if(S.back() == 'L'){
      cout << N - 2 * (L - K) << endl;
      return;
    }else{
      cout << N - 2 * (L - K) - 1 << endl;
      return;
    }
  }
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 512
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n,m,a,b,c,d,x,y,z;
  string s,t;
  //

  // ここから
  IN3(a,s,b);
  if(s=="+") OUT(a+b);
  else OUT(a-b);
}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n, W;
    cin>>n>>W;
    vi weight(n), val(n);
    for(int i=0; i<n; i++) {
        cin>>weight[i]>>val[i];
    }
    vvi dp(n, vi(W+1));
    for(int w=0; w<=W; w++) {
        if(w < weight[0]) {
            dp[0][w] = 0;
        }
        else {
            dp[0][w] = val[0];
        }
    }
    for(int i=1; i<n; i++) {
        for(int w=0; w<=W; w++) {
            if(w < weight[i]) {
                dp[i][w] = dp[i-1][w];
            }
            else {
                dp[i][w] = max(dp[i-1][w], dp[i-1][w-weight[i]] + val[i]);
            }
        }
    }
    cout << dp[n-1][W] << "\n";
    return 0;
}



Measured memory_bytes: 79488
#include <iostream>                                                      
#include <cstdio>                                                        
#include <climits>                                                       
#include <vector>                                                        
using namespace std;                                                     
                                                                         
int main() {                                                             
  int n;                                                                 
  cin >> n;                                                              
  vector<int> a;                                                         
  while (n--) {                                                          
    int x;                                                               
    cin >> x;                                                            
    a.push_back(x);                                                      
  }                                                                      
  int maxa = -INT_MAX;                                                   
  int mina = INT_MAX;                                                    
  long long sum = 0;                                                     
  for (int i=0; i<a.size(); i++) {                                       
    maxa = max(a[i],maxa);                                               
    mina = min(a[i],mina);                                               
    sum += a[i];                                                         
  }                                                                      
  printf("%d %d %ld\n", mina, maxa, sum);                               
  return 0;                                                              
}                                                                        
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                         

Measured memory_bytes: 3280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()


int main(){

    ll N;
    cin >> N;

    vector<string> s(N);
    for(int i = 0; i < N; i++) cin >> s[i];

    ll a = 0;  // 末尾がa
    ll b = 0;  // 始まりがb
    ll ab = 0; // 両方

    ll ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < s[i].size() - 1; j++){
            if(s[i][j] == 'A' && s[i][j+1] == 'B'){
                ans ++;
            }
        }
        if(s[i].back()  == 'A' && s[i].front() == 'B') ab++;
        else if(s[i].front() == 'B') b++;
        else if(s[i].back()  == 'A') a++;
    }

    if(ab - 1 > 0) ans += ab - 1;
    if(ab > 0){
        if(b > 0){
            ans ++;
            b--;
        }
        if(a > 0){
            ans ++;
            a --;
        }
    }
    ans += min(a, b);
    cout << ans << endl;
}

Measured memory_bytes: 768
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n,m;
	cin >> n >> m;

	vector<int> v(100);

	for(int i = 0; i< m; ++i)
	{
		int x,y;
		cin >> x >> y;
		if(v[x-1] == 0 || v[x-1] == y)
			v[x-1] = y;
		else
		{
			cout << -1;
			return 0;
		}
		if(x == 1 && y == 0 && n != 1)
		{
			cout << -1;
			return 0;
		}
		
	}
	string  res= "";
	for(int i =0 ; i < n; i++)
	{
		if(v[i])
			res+=to_string(v[i]);
		else
		{
			if(i == 0 && n!= 1)
			{
				res += "1";
			}
			else
			{
				res+= "0";
			}
		}
		
	}

	cout << res;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String weather = sc.nextLine();
    
    if(weather.equals("Sunny"))
      System.out.println("Cloudy");
    if(weather.equals("Cloudy"))
      System.out.println("Rainy");
    if(weather.equals("Rainy"))
      System.out.println("Sunny");
  }
}

Measured memory_bytes: 21332
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }




int main() {
	double N, T, A;
	scanf("%lf%lf%lf", &N, &T, &A);
	double hd = 700;
	int tmp,ans;

	double *H = (double*)malloc(sizeof(double) * N);
	double *hh = (double*)malloc(sizeof(double) * N);
	for (int i = 0; i < N; i++) {
		scanf("%lf", &H[i]);
		hh[i] = T - 0.006 * H[i];//ondo
		if (hd > fabs(A - hh[i])) {//yori tikai ondo 
			tmp = i;//basho kioku
			hd = fabs(A - hh[i]);
		}

	}
	ans = tmp+1;
	printf("%d\n", ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
def resolve():
    a, b, c = map(int, input().split())
    k = int(input())
    
    for i in range(k):
        if (a >= b):
            b *= 2
        elif (b >= c):
            c *= 2
    
    if(a < b < c):
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9188
N, K = map(int, input().split())
h = list(map(int, input().split()))
# dp = [None] * N
dp = [10**9] * N

for i in range(N):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = abs(h[0]-h[1])
    else:
        # ans = 10**10
        for j in range(1, K+1):
            if j > i:
                break
            # ans = min(ans, dp[i-j] + abs(h[i-j]-h[i]))
            dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]))
        # dp[i] = ans

print(dp[N-1])

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

const int MOD = 1e9+7;
const int MAX_H = 1010;
const int MAX_W = 1010;
string S[MAX_H];
int H, W, dp[MAX_H][MAX_W];

int dfs(int y, int x){
    if (dp[y][x] != -1) return dp[y][x];

    long long ans = 0;
    if (y <= H-2 && S[y+1][x] == '.') ans = (ans + dfs(y+1, x)) % MOD;
    if (x <= W-2 && S[y][x+1] == '.') ans = (ans + dfs(y, x+1)) % MOD;
    return dp[y][x] = ans;
}

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; ++i){
        cin >> S[i];
    }
    for (int i = 0; i < H; ++i){
        for (int j = 0; j < W; ++j){
            dp[i][j] = -1;
        }
    }
    dp[H-1][W-1] = 1;
    cout << dfs(0,0) << endl;

    // for (int i = 0; i < H; ++i){
    //     for (int j = 0; j < W; ++j){
    //         cout << dp[i][j];
    //     }
    //     cout << endl;
    // }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

bool gu(string s) {
  if (s.size() % 2 != 0) return false;
  return s.substr(0, s.size() / 2) == s.substr(s.size() / 2);
}

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (gu(s.substr(0, i))) ans = i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
char c;
cin >> c;
set<char> st = {'a','i','u','e','o'};
st.insert(c);
if(SZ(st) == 5) puts("vowel");
else puts("consonant");
return 0;
}

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

int main()
{
    int N = 0;
    int L = 0;
    cin >> N >> L;

    vector<string> vec(N);
    for(int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());

    string result = "";

    for(int i = 0; i < N; i++) {
        result += vec.at(i);
    } 

    cout << result << endl;
  
    return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
int FUNC(char S[],char A){
if(S[0]==A&&S[1]==A&&S[2]==A)
return 1;
else if(S[3]==A&&S[4]==A&&S[5]==A)
return 1;
else if(S[6]==A&&S[7]==A&&S[8]==A)
return 1;
else if(S[0]==A&&S[3]==A&&S[6]==A)
return 1;
else if(S[1]==A&&S[4]==A&&S[7]==A)
return 1;
else if(S[2]==A&&S[5]==A&&S[8]==A)
return 1;
else if(S[0]==A&&S[4]==A&&S[8]==A)
return 1;
else if(S[2]==A&&S[4]==A&&S[6]==A)
return 1;
else return 0;
}
int main(){
char s[10],A;
while(scanf("%s",s)!=EOF){
A='o';
if(FUNC(s,A)){
printf("o\n");
continue;
}
A='x';
if(FUNC(s,A))
printf("x\n");
else printf("d\n");
}
return 0;
}

Measured memory_bytes: 0
def solve(N):
    stack = ["3", "5", "7"]
    count = 0

    while len(stack) > 0:
        s = stack.pop()
        if int(s) <= N: 
            count += int(all([c in s for c in "753"]))
            for c in "753":
                stack.append(s + c)
    return count
    

def main():
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main()


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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

Int N;
Int sum;

int main(void) {
    cin>>N;

    for(Int p = 1;p <= sqrt(N);p++) {
        Int m = (N / p) - 1;
        if(m <= 0)
            continue;
        if(N / m == N % m)
            sum += m;
    }

    cout<<sum<<endl;

}




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

int A[NUM],n;
bool solve(int,int);

int main(void) {
  int i,q,m;

  cin >> n;
  rep(i,n) {
    cin >> A[i];
  }
  cin >> q;
  rep(i,q){
    cin >> m;
    if(solve(0,m)) 
      cout << "yes" << endl;
    else cout << "no" << endl; 
  }
  return 0;
}

bool solve(int i, int m) {
  int res;
  if(m == 0) return true;
  if(i >= n) return false;
  res = solve(i + 1,m) || solve(i + 1, m - A[i]);
  return res;
}

Measured memory_bytes: 1156
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	
		int n,a;
		vector<int>number;
		int c[101] = { 0 };
		for (int i = 0; i<100; i++){
			cin >> a;
			c[a]++;
		}
		int max = 1;
		for (int i = 1; i <= 100; i++){ 
			if (max == c[i]){
				number.push_back(i);
			}
			else if (max<c[i]){
				max = c[i];
				number.clear();
				number.push_back(i);
			}
			
		}
		for (int i = 0; i < number.size(); i++){
			cout << number[i] << endl;
		}
}

Measured memory_bytes: 1212