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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int c;
  bool flag = false;
  if(s[0] == s[1]) c = 1;
  else if(s[0] == s[2]) c = 2;
  else if(s[0] == s[3]) c = 3;
  else flag = true;
  if(c == 1 && (s[2] != s[3] || s[0] == s[2])) flag = true;
  else if(c == 2 && (s[1] != s[3] || s[0] == s[1])) flag = true;
  else if(c == 3 && (s[2] != s[1] || s[0] == s[2])) flag = true;
  puts(flag ? "No" : "Yes");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        llong h, w;
        read h >> w;
        if ( h + w == 2 ) echo 1 fin;
        elif ( h == 1 || w == 1 ) {
            chmax(h, w);
            h -= 2;
            chmax ( h, 0 );
            echo h fin;
        }
        else {
            echo ( h*w - 2*w - 2*h + 4 ) fin;
        }

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); echo std::fixed << std::setprecision(8); int main_result = Rlyeh::call_of_Cthulhu(114514); return main_result;}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   ll ans = 0;
   rep(i,n){

      if(i==0) ans = k;
      else{
         ans *= k-1;
      }

   }

      cout << ans << endl;


   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int d;
  scanf("%d",&d);
  printf( "Christmas");
for(int i=d;i<25;i++) printf( " Eve");
printf("\n");
}
//#D=24 なら Christmas Eve, D=23 なら Christmas Eve Eve, D=22 なら Christmas Eve Eve Eve

Measured memory_bytes: 1736
#include <stdio.h>

char* days[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
int ms[13] = {0,31,60,91,121,152,182,213,244,274,305,335,366};

int main(){
  int m,q;
  while(scanf("%d %d",&m,&q),m)
    printf("%s\n",days[(ms[m-1]+q)%7]);
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  int h,w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  REP(i,h) REP(j,w) cin >> a[i][j];
  int cnt = 0;
  vector<pair<int, int>> from, to, road(h*w);
  int ind = 0;
  REP(i,h){
    if(i%2==0){
      REP(j,w) road[ind++] = make_pair(i,j);
    }else{
      REPR(j,w-1) road[ind++] = make_pair(i,j);
    }
  }
  REP(k,h*w-1){
    int y = road[k].first;
    int x = road[k].second;
    if(a[y][x]%2==1){
      int ny = road[k+1].first;
      int nx = road[k+1].second;
      from.push_back(make_pair(y+1,x+1));
      to.push_back(make_pair(ny+1,nx+1));
      cnt++;
      a[y][x]--, a[ny][nx]++;
    }
  }
  cout << cnt << '\n';
  REP(k,cnt){
    cout << from[k].first << " " << from[k].second << " " << to[k].first << " " << to[k].second << '\n';
  }
  return 0;
}


Measured memory_bytes: 7276
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	int n, m; cin >> n >> m;
	vector<int> x(n), y(n),xsort,ysort;
	rep(i, 0, n) {
		cin >> x[i] >> y[i];
		xsort.push_back(x[i]);
		ysort.push_back(y[i]);
	}
	sort(xsort.begin(), xsort.end());
	sort(ysort.begin(), ysort.end());
	ll ans = INF;
	rep(i, 0, n)rep(j, i+1, n)rep(k, 0, n)rep(l,k+1, n) {
		int cnt = 0;
		int lx = xsort[i], rx = xsort[j];
		int ly = ysort[k], ry = ysort[l];
		rep(i, 0, n) {
			if (lx <= x[i] && x[i] <= rx && ly <= y[i] && y[i] <= ry) {
				cnt++;
			}
		}
		if (cnt >= m) ans = min(ans, 1LL * (rx - lx) * (ry - ly));
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int t=a.length();
	int i;
	for(i=0;i<t;i++)
	{
		if(a[i]!='1')
		{
			break;
			i++;
		}
	}
	int k;
	cin>>k;
	if(i>=k) printf("1\n");
	else
	{
		printf("%c\n",a[i]);
	 } 
	 return 0;
}

Measured memory_bytes: 256
N,M = gets.chomp.split.map(&:to_i)

from = 1
to = N

M.times do
  l, r = gets.chomp.split.map(&:to_i)
  from = [l, from].max
  to = [r, to].min
end

ans = to - from + 1
puts [ans, 0].max


Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int r,D,x;

int main() {
  INCANT;
  cin >> r >> D >> x;
  int tmp=x;
  rep(i, 10) {
    tmp*=r;
    tmp-=D;
    cout << tmp << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  int minus = 0, zero = 0;
  ll ans = 0;
  int mn = INF;
  rep(i,n){
    int a; cin >> a;
    if(a < 0) minus++;
    if(a == 0) zero++;
    ans += abs(a);
    chmin(mn,abs(a));
  }
  if(zero == 0 && minus % 2 == 1) ans -= mn*2;
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3668
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
template <typename T, typename E>
struct SegmentTree {
	typedef function<T(T, T)> F;
	typedef function<T(T, E)> G;
	int n;
	F f;
	G g;
	T d1;
	E d0;
	vector<T> dat;
	SegmentTree(){};
	SegmentTree(int n_, F f, G g, T d1, vector<T> v = vector<T>()) : f(f), g(g), d1(d1) {
		init(n_);
		if (n_ == (int)v.size()) build(n_, v);
	}
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		dat.clear();
		dat.resize(2 * n - 1, d1);
	}
	void build(int n_, vector<T> v) {
		for (int i = 0; i < n_; i++) dat[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	void update(int k, E a) {
		k += n - 1;
		dat[k] = g(dat[k], a);
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	inline T query(int a, int b) {
		T vl = d1, vr = d1;
		for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) vl = f(vl, dat[(l++) - 1]);
			if (r & 1) vr = f(dat[(--r) - 1], vr);
		}
		return f(vl, vr);
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	SegmentTree<int, int> gcdq(
	    n, [](int a, int b) { return __gcd(a, b); }, [](int a, int b) { return b; }, 0, v);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		gcdq.update(i, 0);
		ans = max(ans, gcdq.dat[0]);
		gcdq.update(i, v[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
int main(void)
{
	double w;
	while (scanf("%lf", &w) != EOF) {
		if (w <= 48.00)
			printf("light fly\n");
		else if (w > 48.00 && w <= 51.00)
			printf("fly\n");
		else if (w > 51.00 && w <= 54.00)
			printf("bantam\n");
		else if (w > 54.00 && w <= 57.00)
			printf("feather\n");
		else if (w > 57.00 && w <= 60.00)
			printf("light\n");
		else if (w > 60.00 && w <= 64.00)
			printf("light welter\n");
		else if (w > 64.00 && w <= 69.00)
			printf("welter\n");
		else if (w > 69.00 && w <= 75.00)
			printf("light middle\n");
		else if (w > 75.00 && w <= 81.00)
			printf("middle\n");
		else if (w > 81.00 && w <= 91.00)
			printf("light heavy\n");
		else if (w > 91.00)
			printf("heavy\n");
	}
	return 0;
}



Measured memory_bytes: 2064
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}
long long gcd(long long a,long long b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
long long lcm(long long a,long long b){
  long long g=gcd(a,b);
  return a/g*b;
}
long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}







int main(){
  int X;
  cin>>X;
  int sum=0;
  int ans=0;
  for(int i=1;;i++){
    sum+=i;
    if(sum>=X){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int h,w,i,j;
    scanf("%d%d\n",&h,&w);
    char e[h][w+1];
    for(i=0;i<h;i++){
        for(j=0;j<w+1;j++){
            scanf("%c",&e[i][j]);        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(e[i][j]=='#'){
                int count=0;
                if(j!=0){if(e[i][j-1]=='#'){count++;}}
                if(j!=w){if(e[i][j+1]=='#'){count++;}}
                if(i!=0){if(e[i-1][j]=='#'){count++;}}
                if(i!=h-1){if(e[i+1][j]=='#'){count++;}}
                if(count==0){printf("No\n");return 0;}
            }
        }
    }
    printf("Yes\n");
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int>p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  int num=0;
  for(int i=0;i<N-1;i++){
    if(p[i]!=i+1)num++;
  }
  if(num<=2){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int a[N],f[N],ans,n;
int main()
{
	scanf("%d",&n);
	for(int i=n;i>=1;i--)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		if(f[ans]<=a[i])f[++ans]=a[i];
		else f[upper_bound(f+1,f+1+ans,a[i])-f]=a[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

int main() {
    int a, b;
    cin >> a >> b;
    std::vector<std::string> s(100);
    for (int i = 0; i < 50; ++i) {
        s[i] = std::string(100, '#');
    }
    for (int i = 50; i < 100; ++i) {
        s[i] = std::string(100, '.');
    }
    a -= 1; b -= 1;

    int i = 0, j = 0;
    while (a > 0) {
        s[i][j] = '.';
        j += 2;
        if (j >= 100) {
            i += 2;
            j = 0;
        }
        a -= 1;
    }
    i = 99; j = 0;
    while (b > 0) {
        s[i][j] = '#';
        j += 2;
        if (j >= 100) {
            i -= 2;
            j = 0;
        }
        b -= 1;
    }
    cout << 100 << ' ' << 100 << endl;
    for (const auto& line: s) {
        cout << line << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int main(){
    int n,k;
    cin >> n >> k;
    int ans = 0;
    while(n){
        ans ++;
        n/= k;
    }
    cout << ans;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextInt();
    long m = sc.nextInt();
    long mod = 1000000007;
    sc.close();
    long ans = 1;
    if (Math.abs(n-m) < 2){
      for (long i =1;i<=n;i++){
        ans = (ans*i)%mod;
      }
      for (long i =1;i<=m;i++){
        ans = (ans*i)%mod;
      }
      if (n == m){
        ans = ans*2%mod;
      }
    }else{
      ans = 0;
    }
    System.out.println(ans);
  }
}

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

int a[10004], b[504], c[504];
int dp[10004]; //個数
int main(){
	int m, n;
	scanf("%d%d", &n, &m);
	for(int i = 1;i <= n;i++)scanf("%d", &a[i]);
	for(int i = 1;i <= m;i++)scanf("%d%d", &b[i], &c[i]);
	sort(a+1, a+n+1, greater<int>());
	for(int i = 1;i <= n;i++)a[i] += a[i-1];
	
	for(int i = 1;i <= m;i++){
		for(int j = n;j >= 1;j--){
			if(j < b[i]){
				dp[j] = max(dp[j], dp[0]+a[j]-c[i]);
				continue;
			}
			int p = a[j]-a[j-b[i]];
			dp[j] = max(dp[j], dp[j-b[i]]+p-c[i]);
		}
	}
	
	int ans = 0;
	for(int i = 1;i <= n;i++)ans = max(ans, dp[i]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long h,w,a,b,x1,x2,x3,x,r,i;
    cin>>h>>w;
    if (h%3==0 || w%3==0)
    {
        cout<<0<<endl;
        return 0;
    }
    x=min(h,w);
    for(i=1;i<w;i++)
    {
        x1=i*h;
        x2=(w-i)*(h/2);
        if (h%2==0) x3=x2;
        else x3=x2+(w-i);
        r=max(x1,max(x2,x3))-min(x1,min(x2,x3));
        x=min(r,x);
    }
    for(i=1;i<h;i++)
    {
        x1=i*w;
        x2=(h-i)*(w/2);
        if (w%2==0) x3=x2;
        else x3=x2+(h-i);
        r=max(x1,max(x2,x3))-min(x1,min(x2,x3));
        x=min(r,x);
    }
    cout<<x<<endl;
    return 0;
}

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


int main() {
  int a, b;
  cin >> a >> b;
  cout << max(a+b,max(2*a-1,2*b-1)) << endl;
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();

    if ((n % x) == 0) {
      System.out.println((n / x) * t);
    } else {
      System.out.println(((n / x) + 1) * t);
    }

  }
}

Measured memory_bytes: 35712
n, d = map(int, input().split()) 
arr = []
int_cnt = 0
mul = 0
for i in range(n):
  arr.append(list(map(int, input().split())))
for i in range(n-1):
  for j in range(i+1,n):
    mul = 0
    for k in range(d):
      mul += (arr[i][k]-arr[j][k])**2
    if((mul**0.5)%1 == 0):
      int_cnt += 1
print(int_cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
// dp
#define MAXN 3030
#define MOD 1000000007
int dp[MAXN][MAXN], sum[MAXN][MAXN];
// dp[previous i-th][tail number of sequence] = way
// {3, 1, 2, 7, 4, 6, 5} => add 3 to tail => {4, 1, 2, 8, 5, 7, 6, 3}
// if we add x to tail, make seq[i]++ which seq[i] >= x
int main() {
    char s[MAXN];
    int n;
    cin >> n;
    n -= 1;
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
        for (int i = 0; i <= n+1; i++)
            for (int j = 0; j <= n+1; j++)
                dp[i][j] = 0, sum[i][j] = 0;
        dp[0][1] = sum[0][1] = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= i+2; j++) {
                if (s[i] == '>')
                    dp[i+1][j] = (dp[i+1][j] + sum[i][j-1])%MOD;
                if (s[i] == '<')
                    dp[i+1][j] = (dp[i+1][j] + (sum[i][i+1] - sum[i][j-1])%MOD + MOD)%MOD;
                sum[i+1][j] = (sum[i+1][j-1] + dp[i+1][j])%MOD;
//                printf("%d %d %d\n", i+1, j, dp[i+1][j]);
            }
        }
        cout << sum[n][n + 1] << "\n";
    return 0;
}


Measured memory_bytes: 71936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll ara[200002];

int main()
{
    ll n,i,a,ans;
    scanf("%lld",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%lld",&ara[i]);
        ara[i]=(ara[i]+ara[i-1])%mod;
    }
    ans=0;
    for(i=1; i<=n; i++)
    {
        a=ara[i]-ara[i-1];
        ans=(ans+(a*(ara[n]-ara[i]))%mod)%mod;
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5284
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Jan 12 20:58:18 2019
//
package main

import "fmt"

func main() {
	var N, H, W int
	fmt.Scan(&N, &H, &W)

	fmt.Println((N - H + 1) * (N - W + 1))
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		Scanner scanner = new Scanner(System.in);
		int n = 12;
		int l = 12;
		while (scanner.hasNext()) {
			
			boolean[][] map = new boolean[l][n];
			for (int i = 0; i < l; i++) {
				String strs = scanner.next();
				for (int j = 0; j < n; j++) {
					if (strs.charAt(j) == '1') {
						map[i][j] = true;
					}
				}
			}
			int count = 0;
			for (int i = 0; i < l; i++) {
				for (int j = 0; j < n; j++) {
					if (map[i][j]) {
						count++;
						dfs(i, j, map, n, l);
					}
				}
			}
			System.out.println(count);
			if(scanner.nextLine().isEmpty()){
				continue;
			}
		}
	}

	private static void dfs(int y, int x, boolean[][] map, int n, int l) {
		int[] dx = { -1, 0, 0, 1 };
		int[] dy = { 0, 1, -1, 0 };
		Deque<int[]> deque = new ArrayDeque<int[]>();
		deque.push(new int[] { y, x });

		while (!deque.isEmpty()) {
			int[] a = deque.pop();
			int ny = a[0];
			int nx = a[1];
			map[ny][nx] = false;
			for (int i = 0; i < 4; i++) {
				int py = ny + dy[i];
				int px = nx + dx[i];
				if (0 <= px && px < n && 0 <= py && py < l && map[py][px]) {
					deque.push(new int[] { py, px });
				}
			}
		}
	}
}

Measured memory_bytes: 17228
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double menseki = r*r*Math.PI;
		double enshu = (r+r)*Math.PI;
		
		System.out.println(BigDecimal.valueOf(menseki)+" "+BigDecimal.valueOf(enshu));


	}
}



Measured memory_bytes: 28292
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const int N = 200001;

int n;
int a[N], b[N];
int aa[N], bb[N];

int main(){
    IOS

   	cin >> n;
   	for(int i = 1; i <= n; i++){
   		cin >> a[i];
   	} 
   	for(int i = 1; i <= n; i++){
   		cin >> b[i];
   	}
   	int val = 0;
   	for(int i = 0; i <= 29; i++){
   		int t = (1<<i);
   		t <<= 1;
   		for(int j = 1; j <= n; j++){
            aa[j] = a[j] % t;
            bb[j] = b[j] % t;
        }
        sort(aa + 1, aa + n + 1);
        sort(bb + 1, bb + n + 1);
        int cnt = 0;
        t >>= 1;
        for(int j = 1; j <= n; j++){
            int p1 = lower_bound(aa + 1, aa + n + 1, t - bb[j]) - aa;
            int p2 = lower_bound(aa + 1, aa + n + 1, 2 * t - bb[j]) - aa;
            int p3 = lower_bound(aa + 1, aa + n + 1, 3 * t - bb[j]) - aa;
            int p4 = lower_bound(aa + 1, aa + n + 1, 4 * t - bb[j]) - aa;
            cnt +=max(0, p2 - p1) + max (0, p4 - p3);
        }
        if(cnt&1)
            val += t;
    }
 	cout << val;

    return 0;
}

Measured memory_bytes: 6720
#include<stdio.h>
#include<algorithm>
#include<functional>

int main(){
  int n, ans=1;
  int *a;
  scanf("%d", &n);
  a = new int[n];
  for(int i=0;i<n;++i){
    scanf("%d", &a[i]);
  }
  std::sort(a, a+n, std::greater<int>());
  for(int i=1;i<n;++i){
    if(a[i-1] > a[i]){
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int kusa;
int ki;
int ushi;
int uma;
long int yagi[100010];
long int shika[100010];
int kaba;
int i;
int j;
int kame;
int main(){
  cin>>kusa;
  for(int ki;ki<kusa;ki++){
  cin>>ushi;
  cin>>uma;
  uma=uma-1;
  for(int i=0;i<ushi;i++){
    cin>>yagi[i];
  }
      if(ushi<uma+1){
          cout<<0<<endl;
      }else{
  for(int j=0;j<ushi-1;j++){
    shika[j]=yagi[j+1]-yagi[j];
    kaba=kaba+shika[j];
  }
  sort(shika,shika+ushi-1);
  for(int kame=0;kame<uma;kame++){
    kaba=kaba-shika[ushi-2-kame];
  }
          cout<<kaba<<endl;
      }
  ushi=0;
  uma=0;
  kaba=0;
  long int yagi[100010]={0};
  long int shika[100010]={0};
  i=0;
  j=0;
  kame=0;
  }
}

Measured memory_bytes: 2740
#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>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll kabu = 0;
    ll ans = 1000;

    for (int i = 0; i < n; i++) {
        if (i == n-1) {
            ans += a[i] * kabu;
            cout << ans << endl;
        }
        if (a[i] < a[i+1]) {
            kabu += ans / a[i];
            ans -= a[i] * (ans / a[i]);
        } else { 
            ans += a[i] * kabu;
            kabu = 0;
        }   
    }

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;
#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif
typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  auto cnt = map<pair<int, int>, int>();
  REP(i, N) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    for(int h = max(0, a - 2); h <= min(a, H - 3); h++) {
      for(int w = max(0, b - 2); w <= min(b, W - 3); w++) {
        cnt[{h, w}]++;
      }
    }
  }

  ll ans[10] = {0};
  ll sum = 0;
  for(auto x : cnt) {
    auto v = x.second;
    ans[v]++;
    sum++;
  }
  ans[0] = (ll)(H - 2) * (W - 2) - sum;
  REP(i, 10) { cout << ans[i] << endl; }
}


Measured memory_bytes: 56448
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>

#define cmax(_a, _b) (_a < (_b) ? _a = (_b), 1 : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b), 1 : 0)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))

#define maxn 10010
typedef long long ll;
typedef double ld;

int a[maxn];
int main()
{
	int n; scanf("%d", &n);
	int num = 0;
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", a + i);
		while (a[i] % 2 == 0) a[i] /= 2, ++num;
	}
	printf("%d\n", num);
	return 0;
}

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

ll f(ll n, ll x) {
    ll r = 0;
    
    if (n >= 0) {
        r = n / x + 1;
    }
    
    return r;
}

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = f(b, x) - f(a - 1, x);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long x = in.nextLong();

        long[] a = new long[n+1];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = in.nextLong();
        }

        long count = 0;
        for (int i = 1; i <= n; i++) {
            long sum = a[i] + a[i - 1];

            if (sum > x) {
                long t = sum - x;
                count += t;
                a[i] -= t;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 61088
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		for (int i=0; i*2 <= y; i++){
			int tempY = y;
			tempY -= i*2;
			if (tempY == 4*(x-i)){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}

}

Measured memory_bytes: 35716
n = int(input())
t,a = map(int,input().split())

for i in range(n-1):
    ti, ai = map(int,input().split())
    cand = set()
    cand.add( 1 + (t+a-1)//ti+ai )
    cand.add( 1 + (a-1)//ai )
    cand.add( 1 + (t-1)//ti )

    tn,an = 10**18,10**18
    for i in cand:
        tt,at = ti*i, ai*i
        if(t<=tt)&(a<=at):
            tn = min(tn, tt)
            an = min(an, at)
    t,a = tn, an

print(t+a)

Measured memory_bytes: 3188
#include <stdio.h>

int main(void){
	int n;
	char s[5];
	scanf("%d", &n);
	int a = 0, w = 0, t = 0, r = 0;
	for(int i = 0; i < n; i++){
		scanf("%s", s);
		switch(s[0]){
			case 'A': a++;
					  break;
			case 'W': w++;
					  break;
			case 'T': t++;
					  break;
			case 'R': r++;
					  break;
		}
	}
	printf("AC x %d\n", a);
	printf("WA x %d\n", w);
	printf("TLE x %d\n", t);
	printf("RE x %d\n", r);
	return 0;
}


Measured memory_bytes: 2132
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

ll r[3000000];

void f(ll *A, ll X, ll *B, ll Y, ll K, ll *t){
    ll k = 0;
    for(ll i = 0; i < X; i++){
        for(ll j = 0; j < Y; j++){
            r[k] = A[i] + B[j];
            k++;
        }
    }
    sort(r, r + X*Y, greater<ll>());
    for(ll i = 0; i < K; i++){
        t[i] = r[i];
    }
}

int main(){
    ll X, Y, Z, K;
    ll A[1000], B[1000], C[1000], D[3000], E[3000];
    scanf("%lld %lld %lld %lld", &X, &Y, &Z, &K);
    for(int i = 0; i < X; i++){
        scanf("%lld", &A[i]);
    }
    for(int i = 0; i < Y; i++){
        scanf("%lld", &B[i]);
    }
    for(int i = 0; i < Z; i++){
        scanf("%lld", &C[i]);
    }
    f(A, X, B, Y, K, D);
    f(C, Z, D, K, K, E);
    for(int i = 0; i < K; i++){
        printf("%lld\n", E[i]);
    }
    return 0;
}

Measured memory_bytes: 23808
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			while (true) {
				int n = sc.nextInt();
				int x = sc.nextInt();

				if ((n == 0) && (x == 0)) break;

				int a = Count(n,x);
				System.out.println(a);
			}
		}
	}


	static int Count(int n, int x) {
		int pattern = 0;
		for (int i=1; i <n; i++) {
			for (int j=i+1; j<n; j++) {
				int s = x - i - j; //差を求める
				if ((s!=i) && (s!=j)) {  //同じ数字を排除
					if (((s<=n) && (s>0)) && (s>j)) {  //条件：0<差<n と 差はjより大きい（前の数字は計算済み）
							//System.out.println(i +" " + j+" "+s);
							pattern++;
					}
				}
			}
		}
		return pattern;
	}
	
}



Measured memory_bytes: 26432
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    string S;
    cin >> S;

    int ans =700;
    rep(i,3){
        if(S[i] == 'o') ans +=100;
    }
    cout << ans << endl;
}

    


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

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;

int n;
ll a[N], sum[N];
map<ll, int> s;

int main() {
  scanf("%d", &n);
  ll ans = 0;
  s[0]++;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = sum[i - 1] + a[i];
    ans += s[sum[i]];
    s[sum[i]]++;
  }
  printf("%lld\n", ans);
  return 0; 
}

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

int n,x[222],y[222],h[222];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d%d%d",&x[i],&y[i],&h[i]);
    for(int i=0;i<101;i++)for(int j=0;j<101;j++){
        int H=0,f=1;
        for(int k=1;k<=n;k++)if(h[k])H=h[k]+abs(i-x[k])+abs(j-y[k]);
        for(int k=1;k<=n;k++)if(max(0,H-abs(i-x[k])-abs(j-y[k]))!=h[k])f=0;
        if(f){printf("%d %d %d",i,j,H);return 0;}
    }
    return 0;
}

Measured memory_bytes: 256
base = int(input())

data = [[0 for i in range(3)] for j in range(base)]

for num in range(base):
    _num = input()
    _num = _num.split()
    data[num][0] = int(_num[0])+int(_num[1])
    data[num][1] = int(_num[0])
    data[num][2] = int(_num[1])

takahashi = 0
aoki = 0
data.sort()
data.reverse()

_num = 0
for num in range(base):
    if(_num == 0):
        takahashi += data[num][1]
        _num = 1

    elif(_num == 1):
        aoki += data[num][2]
        _num = 0

print(takahashi-aoki)

Measured memory_bytes: 24752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
const ll INF = 1e12;
struct Edge {
	int from, to;
	ll cost;
	Edge() {}
	Edge(int f, int t, ll c) : from(f), to(t), cost(c) {}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

vector<ll> Dijkstra(const Graph& G, int s) {
	int n = G.size();
	vector<ll> res(n, INF);
	priority_queue<P, vector<P>, greater<P>> pq;
	pq.emplace(0, s);
	while (!pq.empty()) {
		auto p = pq.top(); pq.pop();
		if (res[p.second] != INF) continue;
		res[p.second] = p.first;
		for (auto e : G[p.second]) {
			if (res[e.to] == INF) {
				pq.emplace(e.cost + p.first, e.to);
			}
		}
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int V, E, r;
	cin >> V >> E >> r;
	Graph G(V);
	for (int i = 0, s, t, d; i < E; i++) {
		cin >> s >> t >> d;
		G[s].emplace_back(s, t, d);
	}
	auto res = Dijkstra(G, r);
	for (auto ans : res) {
		if (ans == INF) puts("INF");
		else printf("%d\n", (int)ans);
	}
	return 0;
}

Measured memory_bytes: 21260
import statistics

N = int(input())
X = [int(i) for i in input().split()]
X.sort()
mid = statistics.mean(X)
ans = 0
ans1 = 0
ans2 = 0

for i in range(N):
    ans1 += (X[i] - int(mid)) ** 2
    ans2 += (X[i] - int(mid) - 1) ** 2
ans = min(ans1, ans2)

print(ans)

Measured memory_bytes: 5272
using System;

class A{
  public static void Main(){
    int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int l = Ar[0] + Ar[1];
    int r = Ar[2] + Ar[3];
    if(l == r) Console.WriteLine("Balanced");
    else if (l > r) Console.WriteLine("Left");
    else Console.WriteLine("Right");
  }
}

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

using namespace std;

int main()
{
    string s,t;
    int c=0;

    cin>>s;
    cin>>t;

    for(int i=0; i<s.size();i++)
    {
        if(s[i] == t[i])
        {
            c++;
        }
    }

    cout<<c<<endl;

    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll h, w, x, y;cin >> w >> h >> x >> y;
	bool flag = ((2 * x == w) && (2 * y == h));
	cout << Decimal << (double)(h * w) / 2 << " " << flag << endl; 

	return 0;
}


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

int main(){
    int cnt = 0;
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if (S[i]-'0') {
            cnt += 1;
        }
    }
    
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  int n = s.length();

  string keyence = "keyence";
  int p = 0;
  for (int i = 0; i < 7; i++) {
    if (s[i] == keyence[p]) p++;
    else break;
  }
  for (int i = n-7+p; i < n; i++) {
    if (s[i] == keyence[p]) p++;
    else break;
  }

  if (p == 7) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 384
let a = read_int()
let b = read_int()
let c = read_int()
let d = read_int()
let e = read_int()
let l = [a; b; c; d; e]

let rec f lst = match lst with
    [] -> []
  | first :: rest ->
     let h x = ((x / 10) + 1) * 10 in
     let rec hojo x lst = match lst with
         [] -> [x]
       | first :: rest -> if x mod 10 = 0 then x :: hojo first rest
                          else if (first mod 10) = 0 then first :: hojo x rest
                          else if (x mod 10) < (first mod 10)
                          then (h first) :: hojo x rest
                          else (h x) :: hojo first rest in
     hojo first (f rest)

let () = print_int (List.fold_right (+) (f l) 0)

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

using namespace std;

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

int map[5002][5002];

int main() {
  int n, m;
  cin >> n >> m;
  int x[n], y[n], xx[n + 2], yy[n + 2];
  rep (i, n) cin >> x[i] >> y[i];
  rep (i, n) xx[i] = x[i];
  rep (i, n) yy[i] = y[i];
  xx[n] = 2e9;
  yy[n] = 2e9;
  xx[n + 1] = -2e9;
  yy[n + 1] = -2e9;
  sort(xx, xx + n + 2);
  sort(yy, yy + n + 2);
  rep (i, n + 2) rep (j, n + 2) map[i][j] = 0;
  rep (i, n) {
    int nx, ny;
    rep (j, n + 2) if (x[i] == xx[j]) nx = j;
    rep (j, n + 2) if (y[i] == yy[j]) ny = j;
    ++map[ny][nx];
    --map[n + 1][nx];
    --map[ny][n + 1];
    ++map[n + 1][n + 1];
  }
  rep (i, n + 2) rep (j, n + 1) map[i][j + 1] += map[i][j];
  rep (i, n + 1) rep (j, n + 2) map[i + 1][j] += map[i][j];
  rep (i, m) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int xx1 = lower_bound(xx, xx + n + 2, x1) - xx - 1;
    int yy1 = lower_bound(yy, yy + n + 2, y1) - yy - 1;
    int xx2 = upper_bound(xx, xx + n + 2, x2) - xx - 1;
    int yy2 = upper_bound(yy, yy + n + 2, y2) - yy - 1;
    cout << map[yy2][xx2] - map[yy2][xx1] - map[yy1][xx2] + map[yy1][xx1] << endl;
  }
  return 0;
}

Measured memory_bytes: 98992
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

const int MAX_N = 200000;

struct SegSum {
  int bit[MAX_N], n;
  SegSum(int n) : n(n) {
    memset(bit, 0, sizeof(bit));
  }
  int sum(int i) {              // [1,i]テ」ツ?ョテ・ツ陳?
    int s = 0;
    while(i > 0) {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
  int sum2(int a, int b) {      // [a,b]テ」ツ?ョテ・ツ陳?
    return sum(b)-sum(a-1);
  }
  void add(int i, int x) {      // i(>=1)テ」ツ?ォxティツカツウテ」ツ??
    while(i <= n) {
      bit[i] += x;
      i += i & -i;
    }
  }
  void addSeg(int a, int b, int x) {   // [a,b]テ」ツつ遅テ・ツ?凝・ツ環?」ツ?暗」ツつ?
    add(a, x);
    add(b+1, -x);
  }
};

struct StarrySky {
  SegSum ss1, ss2;
  StarrySky(int n) : ss1(n), ss2(n) {}
  int sum(int i) {
    return ss1.sum(i) + ss2.sum(i) * i;
  }
  int sum2(int a, int b) {
    return sum(b) - sum(a-1);
  }
  void addEach(int a, int b, int x) {
    ss1.add(a, -x*(a-1));
    ss1.add(b+1, x*b);
    ss2.addSeg(a, b, x);
  }
};


int main() {
  int n;
  cin >> n;
  StarrySky bit(100002);
  REP(i,n) {
    int a, b;
    cin >> a >> b;
    bit.addEach(a,b,1);
  }
  int ans = 0;
  for (int i=1; i<=100000; ++i) {
    int s = bit.sum2(i+1,i+1);
    // if (i < 10)
    //   cout << i << " "<< s << endl;
    if (s >= i) ans = max(ans, i);
  }
  cout << ans << endl;
}

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

int x[2];

int main() {
  while(1) {
    cin >> x[0] >> x[1];
    if(x[0] == 0 && x[1] == 0) break;
    sort(x,x+2);
    cout<<x[0]<<" "<<x[1]<< endl;
  }
}

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

int n,w;

int arr[105][2];
ll dp[105][1000005];
const int ILF=-1e9;

ll solve(int pos,int weight)
{
    ll &ret=dp[pos][weight];
    if(ret!=-1)return ret;
    if(pos==n)return 0;
    if(weight<0)return ILF;
    ret=0;
    ret=solve(pos+1,weight);
    if(weight-arr[pos][0]>=0)
        ret=max(ret,solve(pos+1,weight-arr[pos][0])+arr[pos][1]);
    return ret;
}



int main()
{
    cin>>n>>w;
    for(int i=0;i<n;i++)
        cin>>arr[i][0]>>arr[i][1];
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,w);
}


Measured memory_bytes: 820608
#include<bits/stdc++.h>
#define range(i,a,b) for(long long i = (a); i < (b); i++)
#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
 
template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int match[] = {0,  2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 };

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

	vector<int> a(m);
	cin >> a;
	sort(all(a));

	vector<int> dp(n + 1, -1e5);
	dp[0] = 0;
	rep(i,n){
		for(auto a_j : a){
			if(i + match[a_j] >= n + 1) continue;
			dp[i + match[a_j]] = max(dp[i + match[a_j]], dp[i] + 1);
		}
	}
	//cout << dp << endl;

	reverse(all(a));
	//cout << a << endl;
	int digit = dp[n];
	rep(i,digit){
		for(auto a_j : a){
			if(n - match[a_j] < 0) continue;
			if(dp[n] != dp[n - match[a_j]] + 1) continue;
			cout << a_j;
			n -= match[a_j];
			break;
		}
	}
	cout << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;
#define int long long int

const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 2e9;


signed main(){
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	int n;
	cin>>n;
	if(n>81)cout<<"No";
	else if(n<10)cout<<"Yes";
	else {
		int f=0;
		for(int i=1;i<10;i++){
			if(n%i==0 && n/i<10){f=1;break;}
		}
		if(f)cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256