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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n,m,k;
    cin>>n>>m>>k;

    rep(i,n+1)rep(j,m+1){
        int blk = i*j + (n-i)*(m-j);
        if(blk == k){flag=true;break;}
    }

    //cout <<fixed<<setprecision(16)<< << endl;

    if(flag)cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
char s[9];

int main(){
	scanf("%s",s+1);
	sort(s+1,s+5);
	if(s[1]==s[2]&&s[2]!=s[3]&&s[3]==s[4])
	printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int K = 18;
const int KM = 1 << (K - 1);
int dat[1 << K];

void update(int A) {
	dat[A] = min(dat[A * 2], dat[A * 2 + 1]);
	if (A != 1) update(A / 2);
}

void add(int A, int B) {
	int C = A + KM;
	dat[C] = B;
	update(C / 2);
}

int check(int L, int R, int A, int l, int r) {
	if (L <= l && r <= R) return dat[A];
	if (r <= L || R <= l) return 1e9;
	return min(check(L, R, A * 2, l, (l + r) / 2), check(L, R, A * 2 + 1, (l + r) / 2, r));
}

int query(int L, int R) {
	return check(L, R, 1, 0, KM);
}

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


	int N;
	cin >> N;
	pair<int, int> LR[100000];
	int kotae = 0;
	rep(i, N) {
		int l, r;
		cin >> l >> r;
		LR[i] = mp(l, r);
	}
	sort(LR, LR + N);
	rep(i, 1 << K) dat[i] = 1e9;
	rep(i, N) add(i, LR[i].second);

	rep(i, N) {
		int l1 = LR[i].first;
		int r1 = LR[i].second;
		int lr1 = max(0, r1 - l1 + 1);
		int l2 = (i == N - 1) ? LR[N - 2].first : LR[N - 1].first;
		int r2 = min(query(i + 1, N), query(0, i));
		int lr2 = max(0, r2 - l2 + 1);

		kotae = max(kotae, lr1 + lr2);
	}


	rep(i, N - 1) {
		int l1 = LR[i].first;
		int r1 = query(0, i + 1);
		int lr1 = max(0, r1 - l1 + 1);
		int l2 = LR[N - 1].first;
		int r2 = query(i + 1, N);
		int lr2 = max(0, r2 - l2 + 1);

		kotae = max(kotae, lr1 + lr2);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 2048
#include<cstdio>
int main()
{
	int A,B,C,D;
	while(~scanf("%1d%1d%1d%1d",&A,&B,&C,&D)){
	if(A+B+C+D==7)
	{
		printf("%d+%d+%d+%d=7",A,B,C,D);
	}
	else if(A+B+C-D==7)
	{
		printf("%d+%d+%d-%d=7",A,B,C,D);
	}
	else if(A+B-C+D==7)
	{
		printf("%d+%d-%d+%d=7",A,B,C,D);
	}
	else if(A-B+C+D==7)
	{
		printf("%d-%d+%d+%d=7",A,B,C,D);
	}
	else if(A-B+C-D==7)
	{
		printf("%d-%d+%d-%d=7",A,B,C,D);
	}
	else if(A+B-C-D==7)
	{
		printf("%d+%d-%d-%d=7",A,B,C,D);
	}
	else if(A-B-C+D==7)
	{
		printf("%d-%d-%d+%d=7",A,B,C,D);
	}
	else if(A-B-C-D==7)
	{
		printf("%d-%d-%d-%d=7",A,B,C,D);
	}}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
using namespace std;
const LL MOD=1e9+7;
LL ans;
int main()
{
	int n;
	cin>>n;
	vector <LL> xors(n+1,0),s(n+1,0),a(n);
	rep(i,n)
	{
		cin>>a[i];
		xors[i+1]=(xors[i]^a[i]);
		s[i+1]=s[i]+a[i];
	}
	//rep(i,n) cout<<xors[i+1]<<" "<<s[i+1]<<endl;
	rep(i,n)
	{
		LL lft=i+1,rit=n+1,mid;
		while(lft+1<rit)
		{
			mid=(lft+rit)/2;
			if((xors[mid]^xors[i])==s[mid]-s[i]) lft=mid;
			else rit=mid;
		}
		ans+=lft-i;
		//cout<<lft-l<<endl;
	}
	cout<<ans;
    rt0;
}

Measured memory_bytes: 4992
// https://atcoder.jp/contests/abc070/tasks/abc070_c

#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long ;
ll gcd(ll a, ll b) {
    if (a % b != 0) {
        return gcd(b, a % b);
    }
    return b;
}
ll lcm(ll a, ll b) {
    return a / gcd(a,b) * b;
}
int main() {
    ll N;
    cin >> N;
    ll l = 1;
    for (ll i=0; i < N; ++i) {
        ll x;
        cin >> x;
        l = lcm(x, l);
    }
    cout << l << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

Graph G;
//2部グラフ判定
vector<ll> color; //1と-1に塗り分ける
bool ok = true;
int dfs(ll v, ll c)
{
    color[v] = c;
    rep(i, G[v].size())
    {
        if (color[G[v][i]] == 0)
            dfs(G[v][i], -c);
        else if (color[G[v][i]] == c)
            ok = false;
    }
    return 0;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    G.resize(n);
    color.resize(n);
    rep(i, m)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0, 1);
    ll b = 0;
    rep(i, n) if (color[i] == 1) b++;
    if (ok)
        cout << b * (n - b) - m << endl;
    else
        cout << n * (n - 1) / 2 - m << endl;
}

Measured memory_bytes: 10564
<?php
/**
 * ABC122
 * C - GeT AC
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d", $n, $q);
$s = trim(fgets(STDIN));

$sums[0] = 0;
for ($i = 1; $i <= $n; $i++) {
    $sums[$i] = $sums[$i - 1];
    if ($s[$i - 1] === 'A' and $s[$i] === 'C') {
        $sums[$i]++;
    }
}

for ($i = 0; $i < $q; $i++) {
    fscanf(STDIN, "%d %d", $l, $r);
    echo $sums[$r - 1] - $sums[$l - 1], PHP_EOL;
}


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

int judge(int c) {
  bool a3=false,a5=false,a7=false;
  
  for(int i=0; i<9; i++){
    ll dis1=c/pow(10,i);
    ll dis2=c/pow(10,i+1);
    int keta = dis1-dis2*10;
    if(keta==3) a3=true;
    if(keta==5) a5=true;
    if(keta==7) a7=true;
  }
  
  if(a3==true && a5==true && a7== true) return 1;
  else return 0;
}

int main() {
  
  ll n;
  cin >> n;
  
  queue<ll>Max;
  Max.push(0);
  int count = 0;
  while(Max.front()<=n){
    int x=Max.front();
    Max.pop();
    if(judge(x)==1) count++;
    for(int i=3; i<=7; i+=2){
      ll nx = 10*x+i;
      Max.push(nx);
    }
  }
  cout << count << endl;
  
}

Measured memory_bytes: 1024
# SPDX-License-Identifier: X11
# 2020-08-30
# Sum of product of pairs (300pt)

const M = 1000000007

function main()
  N = parse(Int, readline())

  s = parse(Int, readuntil(stdin, " "))
  t = 0
  for i ∈ 2:N
    A = parse(Int, readuntil(stdin, " "))
    t = mod(t + A * s, M)
    s = mod(s + A, M)
  end

  println(t)
end

main()


Measured memory_bytes: 169052
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
const int Max = 1e5;

int N,A;

int main()
{
	scanf ("%d", &N);
	scanf ("%d", &A);
	printf ("%d\n", N * N - A);
}


Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] p = new int[N];
    
    int cnt = 0;
    
    for (int i=0; i<N;i++){
      p[i] = sc.nextInt();
      if (p[i] != (i+1)){
        cnt++;
      }
      if (cnt >= 3){
        System.out.println("NO");
        return;
      }
    }
    
    System.out.println("YES");
  }
}

Measured memory_bytes: 23764
while gets do
  @n, @s = $_.split(' ').map(&:to_i)
  break if @n == 0 and @s == 0
  @c = 0
  @a = []
  def dfs(j)
    if @a.size == @n
      @c += 1 if @a.inject(:+) == @s
    end

    j.upto(9) do |i|
      @a.push(i)
      dfs(i+1)
      @a.pop
    end
  end

  dfs(0)
  puts @c
end

Measured memory_bytes: 6112
n=int(input())
x=list(map(int,input().split()))
ans=x[0]+x[n-2]
if n>3:
    for i in range(0,n-2):
        ans+=min(x[i],x[i+1])
elif n==3:
    ans+=min(x[0],x[1])
else:
    ans-=0
print(ans)

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

int sum(int n) {
  int ans = 0;
  while (n > 0) {
    ans += n % 10;
    n /= 10;
  }
  
  return ans;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  
  int ans = 0;
  REP(i, n) {
    if (sum(i) >= a && sum(i) <= b)
      ans += i;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
atoz = ("a".."z")
ans = atoz.each_with_object(Hash.new) { |c, h| h[c.to_sym] = 50 }

n.times do
  s = gets.chomp
  ans.each do |k, v|
    count = s.count(k.to_s)
    ans[k] = count if count <= v
  end
end

puts ans.select { |_, v| v > 0 }.map { |k, v| [k.to_s * v] }.join


Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
bool ok(string t)
{
	string r=t;
	reverse(t.begin(),t.end());
	return r==t;
}
int main()
{
	cin>>s;
	n=s.size();
	if(ok(s)&&ok(s.substr(0,n/2))&&ok(s.substr(n/2+1,n/2)))
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
// #define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)

typedef long long ll;

using namespace std;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};

int field[51][51];
int w, h;

void rec(int x, int y) {
  if (x < 0 || x > 50) return;
  if (y < 0 || y > 50) return;
  if (!field[x][y]) return;
  
  field[x][y] = 0;
  int dx[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
  int dy[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
  
  REP(i, 8) {
    rec(x + dx[i], y + dy[i]);
  }
}

int main() {
  while (true) {
    w = Scanner::nextInt();
    h = Scanner::nextInt();
    if (w + h == 0) break;
    memset(field, 0, sizeof(field));
    
    REP(i, h) {
      REP(j, w) {
        int c = Scanner::nextInt();
        field[i][j] = c;   
      }
    }
       
    int count = 0;   
    REP(i, h) {
      REP(j, w) {
        if (field[i][j]) {
          count++;
          rec(i, j);
        }
      }
    }
    PRINT(count);
  }
 
  
  return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> H){
    int ans = 0;
    int tmp = 0;
    LL now = H[0];
    REP1(i, N) {
        if (now >= H[i]) {
            tmp++;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
        now = H[i];
    }

    cout << max(ans, tmp) << endl;
}

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



Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <queue>
using namespace std;
typedef short sh;
#define N 105
int n,m,sum[N][N];
char mp[N][N];
sh f[N][N][N][N];
inline void upd(sh &x,sh y) {x=x>y?x:y;}
int getsm(int x,int y,int z,int w) {
	return sum[z][w]-sum[x-1][w]-sum[z][y-1]+sum[x-1][y-1];
}
int main() {
	scanf("%d%d",&n,&m);
	int i,j,sx=0,sy=0;
	for(i=1;i<=n;i++) scanf("%s",mp[i]+1);
	for(i=1;i<=n;i++) {
		for(j=1;j<=m;j++) {
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			if(mp[i][j]=='E') sx=i,sy=j;
			else if(mp[i][j]=='o') sum[i][j]++;
		}
	}
	int k,l;
	for(i=0;i<=n;i++)for(j=0;j<=n;j++)for(k=0;k<=m;k++)for(l=0;l<=m;l++)f[i][j][k][l]=-10000;
	f[0][0][0][0]=0;
	for(i=0;i<=sx-1;i++) {
		for(j=0;j<=n-sx;j++) {
			for(k=0;k<=sy-1;k++) {
				for(l=0;l<=m-sy;l++) {
					sh t=f[i][j][k][l];
					if(t<0) continue;
					//UP
					if(sx-i>1) upd(f[i+1][j][k][l],t+ (sx-i-1>=j+1?getsm(sx-i-1,max(l+1,sy-k),sx-i-1,min(m-k,sy+l)):0) );
					//DOWN
					if(sx+j<n) upd(f[i][j+1][k][l],t+ (sx+j+1<=n-i?getsm(sx+j+1,max(l+1,sy-k),sx+j+1,min(m-k,sy+l)):0) );
					//LEFT
					if(sy-k>1) upd(f[i][j][k+1][l],t+ (sy-k-1>=l+1?getsm(max(j+1,sx-i),sy-k-1,min(n-i,sx+j),sy-k-1):0) );
					//RIGHT
					if(sy+l<m) upd(f[i][j][k][l+1],t+ (sy+l+1<=m-k?getsm(max(j+1,sx-i),sy+l+1,min(n-i,sx+j),sy+l+1):0) );
				}
			}
		}
	}
	sh ans=0;
	for(i=0;i<=n;i++)for(j=0;j<=n;j++)for(k=0;k<=m;k++)for(l=0;l<=m;l++)ans=max(ans,f[i][j][k][l]);
	printf("%d\n",int(ans));
}


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



int main()
{
	string S, T;
	cin >> S >> T;
	int count = 0;
	for (int i = 0; i < S.size(); i++)
	{
		if (S.at(i)!=T.at(i))
		{
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3896
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
#include<map>
using namespace std;
int main(){
	int a,b,c;
	multiset<int>s;
	scanf("%d%d%d",&a,&b,&c);
	s.insert(a);
	s.insert(b);
	s.insert(c);
	int ans=s.count(a)+s.count(b)+s.count(c);
	if(ans==5)
	 printf("Yes\n");
	 else
	 printf("No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int dp[2][2222][2222];
 
int main() {
  string s;
  int m;
  cin >> s >> m;
  string s1="UD",s2="LR";
  int ans=0;
  for(int l=0; l<2; l++) {
    for(int r=0; r<2; r++) {
      for(int i=0; i<=s.size(); i++) {
        for(int j=0; j<=m; j++) dp[0][i][j]=dp[1][i][j]=-(1<<29);
      }
      dp[0][0][0]=dp[1][0][0]=0;
      for(int i=0; i<s.size(); i++) {
        for(int j=m; j>=0; j--) {
          if(s[i]=='U'||s[i]=='D') {
            dp[1][i+1][j]=dp[1][i][j];
            int x=1;
            if(s[i]==s1[(l+j)%2]) x=-1;
            dp[0][i+1][j]=max(dp[0][i+1][j],dp[0][i][j]+x);
            if(j<m) dp[0][i+1][j+1]=max(dp[0][i+1][j+1],dp[0][i][j]-x);
          } else {
            dp[0][i+1][j]=dp[0][i][j];
            int x=1;
            if(s[i]==s2[(r+j)%2]) x=-1;
            dp[1][i+1][j]=max(dp[1][i+1][j],dp[1][i][j]+x);
            if(j<m) dp[1][i+1][j+1]=max(dp[1][i+1][j+1],dp[1][i][j]-x);
          }
        }
      }
      for(int i=0; i<=m; i++) {
        for(int j=0; j<=m; j++) {
          if(i+j<=m) ans=max(ans,dp[0][s.size()][i]+dp[1][s.size()][j]);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 37956
def main():
  sx, sy, tx, ty = (int(_) for _ in input().split())
  dx, dy = tx - sx, ty - sy
  ret = 'R' * dx + 'U' * dy + 'L' * dx + 'D' * dy + 'D' + 'R' * (dx+1) + 'U' * (dy+1) + 'L' + 'U' + 'L' * (dx+1) + 'D' * (dy+1) + 'R'
  print(ret)
  return

if __name__ == '__main__':
  main()
    

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;

static const int m_MAX = 100;
static const int n_MAX = 1000000;

int insertionSort(int A[], int n, int g) {
	int i, j, v, cnt = 0;

	for (i = g; i < n; i++) {
		v = A[i];
		j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j+g] = A[j];
			j = j - g;
			cnt++;
			A[j+g] = v;
		}
	}

	return cnt;
}

void shellSort(int A[], int n) {
	int i, j, m, G[m_MAX], cnt = 0;

	G[0] = 1;
	for (i = 1; G[i - 1] * 3 + 1 < n; i++)
		G[i] = G[i - 1] * 3 + 1;
	m = i;

	cout << m << endl;

	cout << G[m-1];
	for (i = m - 2; i >= 0; i--)
		cout << ' ' << G[i];
	cout << endl;


	for (i = m - 1; i >= 0; i--)
		cnt += insertionSort(A, n, G[i]);

	cout << cnt << endl;

	for (i = 0; i < n; i++) {
		cout << A[i] << endl;
	}
}

int main () {
	int n, i, A[n_MAX];

	cin >> n;
	for (i = 0; i < n; i++)
		cin >> A[i];

	shellSort(A, n);

	return 0;
}

Measured memory_bytes: 6908
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, K; cin >> N >> K;

    int ans = 0;
    while (N > 0) {
        N /= K;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let vec = read_line();

    // 0 0 1 2
    let sx : i32 = vec[0];
    let sy : i32 = vec[1];
    let tx : i32 = vec[2];
    let ty : i32 = vec[3];

    // 1 s-->t
    // 2 t-->s
    {
        // go ahead
        let h = (sy - ty).abs();
        let w = (sx - tx).abs();
        for _ in 0..h {
            print!("U");
        }
        for _ in 0..w {
            print!("R");
        }
        
        // go back
        for _ in 0..h {
            print!("D");
        }
        for _ in 0..w {
            print!("L");
        }
    }

    // 3 s-->t
    {
        let sx = sx - 1;
        let ty = ty + 1;
        let h = (sy - ty).abs();
        let w = (sx - tx).abs();
        print!("L");
        for _ in 0..h {
            print!("U");
        }
        for _ in 0..w {
            print!("R");
        }
        print!("D");
    }

    // 4 t-->s
    {
        let sy = sy - 1;
        let tx = tx + 1;

        let h = (sy - ty).abs();
        let w = (sx - tx).abs();
        print!("R");
        for _ in 0..h {
            print!("D");
        }
        for _ in 0..w {
            print!("L");
        }
        print!("U");
    }

    println!("");
}

fn read_line() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v = s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    return v
}



Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
    int h,w,n;
    cin>>h>>w>>n;
    if(w>=h){
        if(n%w==0) cout<<(n/w)<<endl;
        else cout<<(n/w)+1<<endl;
    }
    if(h>w){
        if(n%h==0) cout<<(n/h)<<endl;
        else cout<<(n/h)+1<<endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a0, a1, a2, a3, a4, a5, a6, a7, a8;
  a8 = N / 100000000;
  a7 = N / 10000000 - 10 * a8;
  a6 = N / 1000000 - (100 * a8 + 10 * a7);
  a5 = N / 100000 - (1000 * a8 + 100 * a7 + 10 * a6);
  a4 = N / 10000 - (10000 * a8 + 1000 * a7 + 100 * a6 + 10 * a5);
  a3 = N / 1000 - (100000 * a8 + 10000 * a7 + 1000 * a6 + 100 * a5 + 10 * a4);
  a2 = N / 100 - (1000000 * a8 + 100000 * a7 + 10000 * a6 + 1000 * a5 + 100 * a4 + 10 * a3);
  a1 = N / 10 - (10000000 * a8 + 1000000 * a7 + 100000 * a6 + 10000 * a5 + 1000 * a4 + 100 * a3 + 10 * a2);
  a0 = N - (100000000 * a8 + 10000000 * a7 + 1000000 * a6 + 100000 * a5 + 10000 * a4 + 1000 * a3 + 100 * a2 + 10 * a1);
  if ((N % (a8 + a7 + a6 + a5 + a4 + a3 + a2 + a1 + a0)) == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
	int A,B;
	cin>>A>>B;
	int ans=(A+B)/2;
	if((A+B)%2==1)ans=(A+B)/2+1;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e9 + 7, INF = 1e9;


int main(void) {
	int h, w, n, si, sj, i, pi1, pi2, pj1, pj2;
	string s, t;

	scanf("%d%d%d%d%d", &h, &w, &n, &si, &sj);
	cin >> s >> t;

	pi1 = 1;
	pi2 = h + 1;
	pj1 = 1;
	pj2 = w + 1;
	for (i = n - 1; i >= 0; i--) {
		if (t[i] == 'L') pj2 = min(w + 1, pj2 + 1);
		if (t[i] == 'R') pj1 = max(1, pj1 - 1);
		if (t[i] == 'U') pi2 = min(h + 1, pi2 + 1);
		if (t[i] == 'D') pi1 = max(1, pi1 - 1);

		if (s[i] == 'L') pj1 = min(w + 1, pj1 + 1);
		if (s[i] == 'R') pj2 = max(1, pj2 - 1);
		if (s[i] == 'U') pi1 = min(h + 1, pi1 + 1);
		if (s[i] == 'D') pi2 = max(1, pi2 - 1);

		if (pi1 >= pi2 || pj1 >= pj2) {
			printf("NO\n");
			return 0;
		}
	}

	if (pi1 <= si && si < pi2 && pj1 <= sj && sj < pj2) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 776
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());

        for (int i = 0; i < 10; i++)
        {
            for (int j = i; j < 10; j++)
            {
                if (N == i * j)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }

        Console.WriteLine("No");
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int main(void)
{
	int n,m,x,i,k,a[100];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	for(k=1;k<=m;k++){
		for(i=0;i<n-1;i++){
			if(a[i]%k>a[i+1]%k){
				x=a[i]; a[i]=a[i+1]; a[i+1]=x;
			}
		}
	}
	for(i=0;i<n;i++) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 2704
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
using ll = long long;

int main(){
  ll n,x,z=0,y;
  cin >> n >> x;
  int count=0;
  for(int i=0;i<n;i++){
    cin >> y;
    z += y;
    if(z <= x){
      count++;
    }
  }
  cout << count+1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define test int t; cin>>t;
#define MOD 998244353LL
#define all(x) (x).begin(),(x).end()

using namespace std;

ll nxt() { ll x; cin>>x; return x; }

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS

    ll n,x,m;
    cin>>n>>x>>m;
    ll sum = 0;
    map<ll,bool>mm;
    vector<ll> mod;
    mod.pb(x);
    mm[x] = true;
    ll f = -1;
    bool cal = false;
    for(int i = 1; i<n; i++){
        x = x*x;
        x %= m;
        if(mm[x]){
            f = x;
            cal = true;
            break;
        }
        mm[x] = true;
        mod.pb(x);
    }
    if(cal){
    ll tmp = 0;
    bool add = false;
    ll nn = 0;
    int st = -1;
    for(int i = 0; i<mod.size(); i++){
        if(mod[i] == f){
            st = i;
            add = true;
        }
        if(add){
            tmp+=mod[i];
            nn++;
        }
        else{
            n--;
            sum+=mod[i];
        }
    }

    sum+=(n/nn) * tmp;
    n = n%nn;
    for(int i = st, j = 0; j<n; j++,i++){
        sum+=mod[i];
    }
    cout<<sum<<endl;
    }
    else{
        sum = 0;
        for(ll x: mod) sum+=x;
        cout<<sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 6672
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(key=lambda x:x[0])

num, cost = 0, 0
for a, b in AB:
    if num + b > m:
        b = m - num

    num += b
    cost += a * b

    if num == m:
        break

print(cost)

Measured memory_bytes: 29028
class Takahashi:
  def __init__(self, a , b):
    self.a = a
    self.b = b
    
  def test(self):  
    if self.a <10 and self.b <10:
      return a * b
    else:
      return '-1'
    
a, b = list(map(int,input().split(' ')))
#print(a,b)
keisan = Takahashi(a,b)
ans = keisan.test()
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	int x; cin >> x;
	if(x >= 30) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
from sys import stdin
import math

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

D, G = ds_in()

Score = []
for i in range(D):
    p, c = ds_in()
    Score.append([(i+1)*100, p, c])

INF = 10**10

search = []
def SearchMin(search, idx):
    if idx == D:
        score = 0
        num = 0
        res = []
        maxprob = [0, 0, 0]
        for s, i in zip(Score, search):
            num += s[1] * i
            score += (s[0] * s[1] + s[2]) * i
            if i == 0 and s[0] > maxprob[0]:
                maxprob = s.copy()
        if (G > score) and (math.ceil((G - score) / maxprob[0]) <= maxprob[1]):
            return num + max(0, math.ceil((G - score) / maxprob[0]))
        elif G <= score:
            return num
        else:
            return INF

    else:
        s0 = search.copy()
        s0.append(0)
        s1 = search.copy()
        s1.append(1)
        idx += 1
        ans0 = SearchMin(s0, idx)
        ans1 = SearchMin(s1, idx)
        return min(ans0, ans1)

print(SearchMin(search, 0))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1000000007;
int main() {
  int n; cin >> n;
  ll res = 1;
  ll cnt = 0;
  ll pos = -1;
  vector<ll> fact(n+1, 1);
  for (int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % mod;
  while (n--) {
    ll x; cin >> x; cnt++;
    if (n && x == pos + 1) {
      (res *= cnt--) %= mod;
    } else if (!n) {
      (res *= fact[cnt]) %= mod;
    } else {
      pos += 2;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
// Aizu 1108: A Long Ride on a Railway
// 2017.9.16 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int a, b, d, f; } T;
T tbl[25]; int n, m;
int ans[12], tmp[12], len, num;

void combi(int k, int a, int w)
{
	int i, b;

	for (b = 1; b <= n; b++) {
		if (b == a) continue;
		for (i = 0; i < m; i++) {
			if ((tbl[i].a == a && tbl[i].b == b || tbl[i].a == b && tbl[i].b == a) && !tbl[i].f) {
				tbl[i].f = 1, tmp[k] = b;
				combi(k+1, b, w + tbl[i].d);
				tbl[i].f = 0;
			}
		}
	}
	if (w > len) num = k, len = w, memcpy(ans, tmp, sizeof(int)*num);
}

int main()
{
	int i, a, b;

	while (scanf("%d%d", &n, &m) && n) {
		for (i = 0; i < m; i++) scanf("%d%d%d", &tbl[i].a, &tbl[i].b, &tbl[i].d), tbl[i].f = 0;
		for (len = num = 0, a = 1; a <= n; a++) for (b = 1; b <= n; b++) {
			if (b == a) continue;
			for (i = 0; i < m; i++) {
				if ((tbl[i].a == a && tbl[i].b == b || tbl[i].b == a && tbl[i].a == b) && !tbl[i].f) {
					tbl[i].f = 1;
					tmp[0] = a, tmp[1] = b, combi(2, b, tbl[i].d);
					tbl[i].f = 0;
				}
			}
		}
		printf("%d\n", len);
		printf("%d", ans[0]);
		for (i = 1; i < num; i++) printf(" %d", ans[i]);
		printf("\n");
    }
	return 0;
}

Measured memory_bytes: 1768
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n: usize = sc.read();

    let mut ans = 1e10 as usize;
    for left in 1..n {
        let right = n - left;
        ans = cmp::min(ans, get_sum(left) + get_sum(right));
    }
    println!("{}", ans);
}

fn get_sum(mut x: usize) -> usize {
    let mut sum = 0;
    while x > 0 {
        sum += x % 10;
        x /= 10;
    }
    sum
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
H, W = map(int, input().split())
s = [input() for i in range(H)]

# 四隅
# 左上
if s[0][0] == '#':
    if s[0][1] == '.' and s[1][0] == '.':
        print('No')
        exit()
# 右上
if s[0][W - 1] == '#':
    if s[0][W - 2] == '.' and s[1][W - 1] == '.':
        print('No')
        exit()
# 左下
if s[H - 1][0] == '#':
    if s[H - 1][1] == '.' and s[H - 2][0] == '.':
        print('No')
        exit()
# 右下
if s[H - 1][W - 1] == '#':
    if s[H - 1][W - 2] == '.' and s[H - 2][W - 1] == '.':
        print('No')
        exit()

# 上辺
for i in range(1, W - 1):
    if s[0][i] == '#':
        if s[0][i - 1] == '.' and s[0][i + 1] == '.' and s[1][i] == '.':
            print('No')
            exit()

# 下辺
for i in range(1, W - 1):
    if s[H - 1][i] == '#':
        if s[H - 1][i - 1] == '.' and s[H - 1][i + 1] == '.' and s[H - 2][i] == '.':
            print('No')
            exit()

# 左辺
for i in range(1, H - 1):
    if s[i][0] == '#':
        if s[i - 1][0] == '.' and s[i + 1][0] == '.' and s[i][1] == '.':
            print('No')
            exit()

# 右辺
for i in range(1, H - 1):
    if s[i][W - 1] == '#':
        if s[i - 1][W - 1] == '.' and s[i + 1][W - 1] == '.' and s[i][W - 2] == '.':
            print('No')
            exit()

# 中央
for h in range(1, H - 1):
    for w in range(1, W - 1):
        if s[h][w] == '#':
            if s[h - 1][w] == '.' and s[h + 1][w] == '.' and s[h][w - 1] == '.' and s[h][w + 1] == '.':
                print('No')
                exit()

print('Yes')


Measured memory_bytes: 9296
#include<iostream>
using namespace std;
int main () {
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  int o;
  o = 3-(a==b?1:0)-(a==c?1:0)-(b==c?1:0);
  if(o==0){
    o = 1;
  }
  cout<<o;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
int main(){
    int n,k; cin >> n >> k;
    double p[n];
    rep(i,n){
        double a; cin >> a;
        p[i]=(a+1)/2;
    }
    double res=0;
    double ans=0;
    rep(i,k) res+=p[i];
    ans=res;
    for(int i=k;i<n;i++){
        res+=p[i];
        res-=p[i-k];
        chmax(ans,res);
    }
    cout << fixed << setprecision(10) << ans << endl;
    
}


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

using namespace std;

typedef long long LL;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define ST first
#define ND second
#define PB push_back
#define DET(a,b,c) (LL(b.x-a.x)*LL((c.y-a.y))-LL((c.x-a.x))*LL((b.y-a.y)))

const int MAXN = 3010;
int n;
long double dp[MAXN][MAXN];
long double a[MAXN];
long double ans;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1; i<=n;i++) cin>>a[i];
    dp[0][0] = 1;
    for(int i=0; i<=n;i++) {
        for(int j=1; j<=n;j++) {
            dp[j][i] = (long double)dp[j-1][i]*(1-a[j])+(long double)dp[j-1][i-1]*a[j];
        }
    }
    for(int i=(n+1)/2; i<=n;i++) {
        ans+=dp[n][i];
    }
    cout<<setprecision(10)<<ans;
}


Measured memory_bytes: 141568
Num = [ 1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 
       128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 
       400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000]

N = int(input())

out = 1

for i in Num:
    if i<=N:
        out = i
    else:
        break

print(out)

Measured memory_bytes: 3060
n,m = map(int, input().split())
diff = abs(abs(n) - abs(m))
res = diff

if abs(n) <= abs(m):
  if n < 0:
    res += 1
  if m < 0:
    res += 1
  print(res)

else:
  if n > 0:
    res += 1
  if m > 0:
    res += 1
  print(res)

Measured memory_bytes: 3060
use utf8;
use strict;
use warnings;
use feature qw/say/;

chomp(my $line = <>);
my ($n, $d) = split(/ /, $line);
my $cnt = int($n / (2 * $d + 1));
my $mod = $n % (2 * $d + 1);
say ($cnt + ($mod ? 1 : 0));

Measured memory_bytes: 768
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9 ) {
		cout << "hon" << endl;
	}
	else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "bon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
import java.util.Scanner;

public class Main {

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


		System.out.println(a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0) ? "YES" : "NO");
	}
}

Measured memory_bytes: 21716
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	ab := make(dishes, n)

	for i := 0; i < n; i++ {
		ab[i].a,ab[i].b = scanInt(), scanInt()
		ab[i].ab = ab[i].a+ab[i].b
	}

	sort.Sort(ab)

	ans := int64(0)
	for i := 0; i < n; i++ {
		if i%2==0 {
			ans+=int64(ab[i].a)
		}	else {
			ans-=int64(ab[i].b)
		}
	}

	fmt.Println(ans)
}

type dish struct {
	a int
	b int
	ab int
}

type dishes []dish

func (a dishes) Len() int           { return len(a) }
func (a dishes) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a dishes) Less(i, j int) bool { return a[i].ab > a[j].ab }

func abs(a int) int {
	if a<0 {
		return -a
	}
	return a
}


Measured memory_bytes: 5120
<?php
// スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $n, $m);

//mの約数を列挙する
$m_root = sqrt($m);
$divisor = array();
$divisor[] = 1;
$divisor[] = $m;
for ($i = 2; $i <= $m_root; $i++) {
  if ($m % $i === 0) {
    $divisor[] = $i;
    $divisor[] = $m/$i;
  }
}

//昇順で並び替える
asort($divisor);

//約数のうちn以上でnに一番近いものをlとすると答えはm/l
$num = 0;
foreach ($divisor as $a) {
  $num = $a;
  if ($a >= $n) {
    break;
  }
}

echo $m / $num;
?>


Measured memory_bytes: 3828
#include <stdio.h>

struct Node {int p,l,r;};
struct Node T[10000];
int n;

void preParse(int u){
  if(u==-1)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==-1) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==-1) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=-1) T[l].p=v;
    if(r!=-1) T[r].p=v;    
  }
  for(i=0;i<n;i++){
    if(T[i].p==-1){
      root=i;
    }
  }
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  
  return 0;
}
    

Measured memory_bytes: 620
use std::io;
use std::io::prelude::*;

fn main () {
    let mut stdin = io::stdin();
    let mut buf = String::new();
    let _ = stdin.read_to_string(&mut buf);
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let l: Vec<u32> = (0..n).map(|_| iter.next().unwrap().parse().unwrap()).collect();
    let max: u32 = *l.iter().max().unwrap();
    let sum: u32 = l.iter().sum::<u32>();
    println!("{}", if max * 2 < sum {"Yes"} else {"No"});
}


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

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

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

  Sieve s(1000005);
  auto fs = s.factor(n);

  int ans = 0;
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7828
import java.util.Scanner;
class Main{
    int r,c,x,y;
    public void solve(){
        Scanner sc = new Scanner(System.in);
        r = sc.nextInt();
        c = sc.nextInt();
        int [][] a = new int [r+1][c+1];
        for(x = r; x < r+1; x++){
            for(y = c; y < c+1; y++){
                a[x][y] = 0;
            }
        }
        for(x = 0; x < r; x++){
            for(y = 0; y < c; y++){
                a[x][y] = sc.nextInt();
                a[x][c] += a[x][y];
                a[r][y] += a[x][y];
                a[r][c] += a[x][y];
            }
        }
        for(x = 0; x < r+1; x++){
            for(y = 0; y < c; y++){
                System.out.printf("%d ",a[x][y]);
            }
            System.out.printf("%d",a[x][y]);
            System.out.println();
        }
    }
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 52888
#include<stdio.h>
#include<algorithm>
using namespace std;
struct my{
int w,v;
}a[105];
int ans[100005];
int main(){
    int n,w;
    scanf("%d%d",&n,&w);
    for (int i=1;i<=n;i++)
        scanf("%d%d",&a[i].v,&a[i].w);
    for (int i=1;i<=n;i++){
        for (int j=w;j>=a[i].w;j--){
            ans[j]=max(ans[j],(ans[j-a[i].w]+a[i].v));
        }
    }
    printf("%d\n",ans[w]);
return 0;
}

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

using namespace std;
typedef long long ll;
int n , W;
ll dp[101][100001];
ll val[101],we[101];
ll OO=1e10;
ll solve(int i , int rem)
{
    if(rem<0)
    {
        return OO;
    }
    if(rem==0)
    {
        return 0;
    }
    if(i==n)
    {
        return OO;
    }
    ll &ret=dp[i][rem];
    if(ret!=-1)
        return ret;
    ret=OO;
    ret=min( solve(i+1 , rem), solve(i+1 , rem-val[i])+we[i]);
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> W;
    ll sum=0;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> we[i] >> val[i];
        sum+=val[i];
    }
    memset(dp , -1 , sizeof dp);
    for(int i=sum ; i>=0 ; i--)
    {
        
        if(solve(0, i)<=W)
        {
            cout << i;
            return 0;
        }
    }
    return 0;
}


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

int main() {
string a;
cin>>a;
int n=0;
  for(int i=0;i<a.size();i++){
if(a.at(i)=='o'){
n++;
}
}
if(n+15-a.size()>=8){
  cout <<"YES" << endl;
}
else{
  cout << "NO" << endl;
}
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<string> s(N);
    map<vector<ll>, ll> mp;
    for (ll i = 0; i < N; i++) {
        cin >> s[i];
        vector<ll> num(26);
        for (char c : s[i]) {
            num[c - 'a']++;
        }
        mp[num]++;
    }

    ll ans = 0;
    for (const auto& p : mp) {
        ans += (p.second - 1) * p.second / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 37760
#include <stdio.h>
#include <string.h>

#define MAX 100001

int main()
{
  char s[MAX];
  int ans1 = 0, ans2 = 0, i;

  scanf("%s", s);

  for (i = 0; i < strlen(s); i++) {
    if (i % 2 == 0 && s[i] == '0' || i % 2 == 1 && s[i] == '1') {
      ans1++;
    }
    if (i % 2 == 0 && s[i] == '1' || i % 2 == 1 && s[i] == '0') {
      ans2++;
    }
  }

  printf("%d\n", (ans1 < ans2 ? ans1 : ans2));

  return 0;
}

    

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,D,E,x,y,cou=0,v[3];
    char S[3],s[3],X,Y;
    scanf("%d",&A);
    if(A/100==A%10){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long A,B,K;
  cin >> A >> B >>K;
    if(A>=K){
        A=A-K;
        K=0;
    }else{
        K=K-A;
        A=0;
    }
    if(B>=K){
        B=B-K;
    }else{
        B=0;
    }

  cout << A << " " << B;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String[] line = in.nextLine().split(" ");
        final int n = Integer.parseInt(line[0]);
        final int k = Integer.parseInt(line[1]);
        final int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        in.nextLine();
        int low = 1, high = (int) 1e9;
        while (low < high) {
            final int mid = low + high >>> 1;
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                cnt += (arr[i] - 1) / mid;
            }
            if (k < cnt) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        System.out.println(low);
    }
}


Measured memory_bytes: 59808