akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
 
int main(){
  ll N;
  cin>>N;
  map<ll,int> P;
  ll N2=N;
  N--;
  rep(q,100){
    rep(i,sqrt(N)+1){
      if(N%(i+2)==0){
        P[i+2]++;
        N/=(i+2);
        break;
      }
    }
  }
  if(N!=1) P[N]++;
  ll ans=1;
  auto itr=P.begin();
  rep(i,P.size()){
    ans*=(itr->second+1);
    itr++;
  }
  map<ll,int> P2;
  N=N2;
  rep(q,50){
    rep(i,sqrt(N2)+1){
      if(N2%(i+2)==0){
        P2[i+2]++;
        N2/=(i+2);
        break;
      }
    }
  }
  if(N2!=1) P2[N2]++;
  VVL D(P2.size()+1);
  auto itr2=P2.begin();
  D[0].pb(1);
  rep(i,P2.size()){
    ll tmp=itr2->first;
    rep(j,itr2->second){
      rep(k,D[i].size()){
        D[i+1].pb(tmp*D[i][k]);
      }
      tmp*=itr2->first;
    }
    rep(j,D[i].size()){
      D[i+1].pb(D[i][j]);
    }
    itr2++;
  }
  rep(i,D[P2.size()].size()){
    ll X=D[P2.size()][i];
    ll Y=0;
    ll N3=N;
    if(X!=1 and X!=N3) rep(q,100){
      if(N3%X==0) N3/=X;
      else N3%=X;
      if(N3==1){
        Y=1;
        break;
      }
    }
    if(Y){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
int n,m,x;
scanf("%d %d %d",&n,&m,&x);
int a[m+1],i;
for(i=0;i<m;++i) scanf("%d",&a[i]);
//so far ok

int cost1=0;
for(i=0;i<m;++i)
	if(a[i]>x)	++cost1;


int cost2=0;
for(i=0;i<m;++i)
	if(a[i]<x)	++cost2;


if(cost1<cost2) printf("%d\n",cost1);
else printf("%d\n",cost2);
return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

int main(){
    int N,M;
    int sum=0;
    cin >> N >>M;
vector<int> A(N);
for(int i=0;i<N;i++){
    cin >> A[i];
    sum = sum+A[i];
}

if(sum>N)
cout <<"-1" <<endl;

else{
    cout << N-sum <<endl;
}

}

Measured memory_bytes: 7220
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

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

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

template<class T> ll upper(T n,T m){return (n+m-1)/m;};
template<class T> ll rounding(T n){return (long double)n+0.5;};

template<class T> bool inG(T x,T n){return 0<=x && 0<n;}
template<class T> bool outG(T x,T n){return x<0 || n<=x;}

inline int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int n;
  cin>>n;

  coutYn(!(n%dsum(n)));

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

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

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}

template <class T>
inline T Max(const T a,const T b) {
    return (a >= b) ? a : b;
}

template <class T>
inline T Min(const T a,const T b) {
    return (a <= b) ? a : b;
}

template <class T>
inline void show(T a) {
    cout << a << endl;
}

typedef struct{
    ll x;
    ll y;
}idx;


//------------------------main function-------------------------------
void Main(){
    set<int> a;
    int n; cin >> n;
    rep(i, n) {
        int temp;
        cin >> temp;
        a.insert(temp);
    }
    if(n == a.size()){
        cout << "YES"<<endl;
    }else{
        cout << "NO" <<endl;
    }
}
//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
     
    Main();
    return 0;
}



Measured memory_bytes: 9600
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
const ll inf = 1000000007;
int main() {
  double W,H,X,Y; cin  >>W>>H>>X>>Y;
  cout <<fixed<<setprecision(11)<<(W*H)/2<<" ";
  if(X==W/2&&Y==H/2)cout <<1<<endl;
  else cout <<0<<endl;
}

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

int main() {
    int n,x,count = 0, t = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x != t + 1) {
            count++;
        } else {
            t++;
        }
    }
    if (!t) {
        cout << -1 << endl;
    } else {
        cout << count << endl;
    }


    return 0;
}



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

using namespace std;

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

  for (int i = 0; i < n; i++) {
    string s, t;
    cin >> s >> t;
    reverse(s.begin(), s.end());

    int sz = s.size(), tz = t.size();
    for (int j = 0; j < sz; j++) {
      if (s[j] == 'C') {
        t = t.substr(1, tz - 1) + t[0];
      } else if (s[j] == 'J') {
        t = t[tz - 1] + t.substr(0, tz - 1);
      } else if (s[j] == 'E') {
        string a = t.substr(0, tz / 2), b = t.substr((tz + 1) / 2, tz / 2);
        if (tz & 1) t = t[tz / 2];
        else t = "";
        t = b + t + a;
      } else if (s[j] == 'A') {
        reverse(t.begin(), t.end());
      } else if (s[j] == 'M') {
        for (int k = 0; k < tz; k++) {
          if (!isdigit(t[k])) continue;
          t[k] = (t[k] - '0' + 1) % 10 + '0';
        }
      } else {
        for (int k = 0; k < tz; k++) {
          if (!isdigit(t[k])) continue;
          t[k] = (t[k] - '0' - 1 + 10) % 10 + '0';
        }
      }
    }

    cout << t << endl;
  }

  return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>

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

int n,k;
int aa[111111];

int getinput(){
	scanf("%d%d",&n,&k);
	if(n==0)return -1;
	rep(i,n)scanf("%d",&aa[i]);
	return 1;
}


int getfirstsum(int left,int right){
	if(left==right)return aa[left];
	return getfirstsum(left,(left+right)/2) +
			 getfirstsum((left+right)/2+1,right);
}

int main(void){
	while(1){
		if(getinput()==-1)break;
		
		int a = getfirstsum(0,k-1);
		int ans=a;
		rep(i,n-k){
			a = a-aa[i]+aa[i+k];
			if(ans<a){
				ans=a;
			}
		}
		
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
// AOJ 0174
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string str;
	while (1){
		cin >> str;
		if (str == "0") break;
		int kotori = 0, hanayo = 0;
		for (int i = 1; i < str.length(); i++){
			if (str[i] == 'A'){
				kotori++;
			}
			else hanayo++;
		}
		cin >> str;
		if (str[0] == 'A'){
			kotori++;
		}
		else hanayo++;
		cout << kotori << " " << hanayo << endl;

		kotori = 0, hanayo = 0;
		for (int i = 1; i < str.length(); i++){
			if (str[i] == 'A'){
				kotori++;
			}
			else hanayo++;
		}
		cin >> str;
		if (str[0] == 'A'){
			kotori++;
		}
		else hanayo++;
		cout << kotori << " " << hanayo << endl;

		kotori = 0, hanayo = 0;
		for (int i = 1; i < str.length(); i++){
			if (str[i] == 'A'){
				kotori++;
			}
			else hanayo++;
		}
		if (kotori < hanayo) hanayo++;
		else kotori++;
		cout << kotori << " " << hanayo << endl;
	}

	return 0;
}

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

namespace AtCoder_ABC089_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int n = int.Parse(s[0]);
            int x = int.Parse(s[1]);

            int[] m = new int[n];

            int sum = 0;
            int min = 1000000;

            for (int i = 0; i < n; ++i)
            {
                m[i] = int.Parse(Console.ReadLine());

                sum += m[i];

                if (m[i] < min)
                {
                    min = m[i];
                }
            }

            x -= sum;

            n += x / min;

            Console.WriteLine(n);
        }
    }
}


Measured memory_bytes: 13140
# -*- coding: utf-8 -*-
from collections import defaultdict
n,m = list(map(int, input().split()))

d=defaultdict(list)
for _ in range(m):
    a,b = list(map(int, input().split()))
    d[b].append(a)

for src in d[n]:
    if 1 in d[src]:
        print('POSSIBLE')
        exit()
        
print('IMPOSSIBLE')
    


Measured memory_bytes: 48468
#include <algorithm>
#include <iostream>
#include <memory>
#include <vector>

using namespace std;

int main() {
  int x1, x2, y1, y2;

  cin >> x1 >> y1 >> x2 >> y2;

    int dx = abs(x1-x2);
    int dy = abs(y1-y2);

    int x3, y3, x4, y4;

    if(x1 > x2){
        if(y1 > y2){
            //
            x3 = x2 + dy;
            y3 = y2 - dx;
            x4 = x1 + dy;
            y4 = y1 - dx;
        }else{
          //
          x3 = x2 - dy;
          y3 = y2 - dx;
          x4 = x1 - dy;
          y4 = y1 - dx;
        }
    }else{
        if(y1 > y2){
          //
          x3 = x2 + dy;
          y3 = y2 + dx;
          x4 = x1 + dy;
          y4 = y1 + dx;
        }else{
          //
          x3 = x2 - dy;
          y3 = y2 + dx;
          x4 = x1 - dy;
          y4 = y1 + dx;
        }
    }
    printf("%d %d %d %d\n", x3, y3, x4, y4);

  return 0;
}

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

int main(){
  
  string s;
  cin >> s;
  int a[26];
  for(int i=0;i<26;i++) a[i]=0;
  for(int i=0;i < s.size();++i){
    a[s[i] - 'a']++;
  }
  bool ans = true;
  for(int i=0;i<26;i++){
    if(a[i]%2 != 0){
      ans =false;
      break;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); \
						 istream_iterator<string> _it(_ss); \
						 err(_it, args); }
#else
#define error(args...)		42
#endif


void err(istream_iterator<string> it) { cerr << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "; ";
	err(++it, args...);
}


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}

int ceil2(int a, int b){
    int c = a / b;
    if (c * b < a) c++;
    return c;
}

// int dp[21][2097152+1];

int32_t main()
{
	c_p_c();

	int n; cin>>n;

	bool a[n][n];

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			cin>>a[i][j];
		}
	}


	int sz = 1LL<<n;

	vector<vector<int>> dp(n, vector<int>(sz));
	// error(sz);

	// error(1LL<<22);


	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < (sz); ++j)
		{
			// error(i,j);
			dp[i][j] = 0;

			int mask=1LL<<(n-1);

			if(__builtin_popcountll(j) == i+1)
			{
				for (int k = 0; k < n; ++k)
				{
					if(a[i][k] == 1 && (j&(mask>>k)))
					{
						if(i-1 >= 0)
							dp[i][j] += dp[i-1][(j^(mask>>k))];
						else
							dp[i][j] = 1;

						dp[i][j] %= mod;
					}
				}
			}
		}
	}

	// for (int i = 0; i < n; ++i)
	// {
	// 	for (int j = 0; j < 1<<(n); ++j)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }
	
	cout << dp[n-1][(sz)-1];

	return 0;
}

Measured memory_bytes: 363776
#include<iostream>

using namespace std;
int A=0,B=0,a,b,n;
int main(){
    while(1){
    A=0;
    B=0;
cin >> n;
if(n==0)break;
for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a==b){
        A+=a;
        B+=b;
    }else if(a>b)A+=a+b;
    else B+=a+b;
}
cout << A <<' '<< B << endl;
    }
return 0;
}

Measured memory_bytes: 1160
sub a{my$r=$u[$_]=1;$u[$_]or$r+=&a for@$_;$r}($a)=sort{$a-$b}map{map{push@$_,$_[--$|]for@_=glob}<>;a}<>=~$",2;print$`*~-$`/2-$'-$a*($`-$a)

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

int main() {
  string s; cin>>s;
  if ((s[0]==s[s.size()-1])^(s.size()%2==0)) {
    cout<<"Second"<<endl;
  } else {
    cout<<"First"<<endl;
  }
  /*
  char a[2]={s[0],s[1]}; bool p=true;
  for(int i=2;i<s.size()&&p==true;i++) {
    if (!(s[i] == a[i%2])) p=false;
  }
  //cout<<p<<endl;
  if (p==false) {
    if (s.size()%2==0) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
  } else {
    // 一つも取れない
    cout<<"Second"<<endl;
  }*/
}

Measured memory_bytes: 512
import Control.Monad
import Control.Applicative

data Op = S | E | N | W deriving (Show, Eq, Enum)

fromChar c | c == 'S' = S
           | c == 'E' = E
           | c == 'N' = N
           | c == 'W' = W
           | otherwise = error $ "Invalid char " ++ [c]

fromString [] = []
fromString (x:xs) = (fromChar x):(fromString xs)

data Dice = Dice { top :: Int, front :: Int, right :: Int, left :: Int, back :: Int, bottom :: Int }
  deriving (Show, Eq)

makeDice [t, f, r, l, ba, bo] = Dice t f r l ba bo

roll (Dice t f r l ba bo) S = Dice ba t r l bo f
roll (Dice t f r l ba bo) N = Dice f bo r l t ba
roll (Dice t f r l ba bo) E = Dice l f t bo ba r
roll (Dice t f r l ba bo) W = Dice r f bo t ba l
rolls = foldl roll :: Dice -> [Op] -> Dice

equal dice1 dice2 = foldr (||) False [(> 0) $ length $ filter (\x -> x == dice2) $ scanl rolls d [[N, E, S], [N, E, S], [N, E, S]] | d <- ds]
  where ds = scanl roll dice1 [N, E, N, E, N]

someEqual xs = foldl1 (||) $ [equal x y | x <- xs, y <- xs, x /= y]

solve xs | someEqual xs = "No"
         | otherwise = "Yes"

main = do
  n <- readLn :: IO Int
  dices <- map (makeDice . map read . words) <$> replicateM n getLine :: IO [Dice]
  putStrLn . solve $ dices




Measured memory_bytes: 5668
#include <bits/stdc++.h>
using namespace std;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long total = 0;
    for(int i = 1; i < n; i++){
        if(a[i] < a[i-1]){
            total += (long long)a[i - 1] - (long long)a[i];
            a[i] = a[i-1];
        }
    }
    
    cout <<  total << endl;
    
    
    return 0;
}


Measured memory_bytes: 4040
H, W = map(int, raw_input().split())
while H | W != 0:
    for i in range(H):
        s = ''
        for j in range(W):
            s += '#' if (j + i) % 2 == 0 else '.'
        print s
    print ''
    H, W = map(int, raw_input().split())

Measured memory_bytes: 4204
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

#define DIV 998244353

//高速べき乗(mod DIV)
long long mypow(long long k, long long n) {
	long long temp = 1;

	k = k % DIV;
	while (n) {
		if (n % 2) temp = temp * k % DIV;
		k = k * k % DIV;
		n = n / 2;
	}
	return temp % DIV;
}

int main(void) {
	long long n;
	long long d[100000] = { 0 };
	long long ans = 1, max = 0;
	long long cnt[100000] = { 0 };

	scanf("%lld", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &d[i]);
		cnt[d[i]]++;
		if (max < d[i])max = d[i];
	}
	if (d[0] != 0 || cnt[0] != 1)printf("0");
	else {
		for (int i = 1; i <= max; i++) ans = (ans * mypow(cnt[i - 1], cnt[i])) % DIV;
		printf("%lld", ans);
	}
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define int long long
#define M 1000000009
#define H 65
#define W 75
#define N 30
using namespace std;
typedef pair<int,int> P;

int w, h, n, idx;
int dp[W][H][W], ans[2][W];

void init(){

  memset(dp,0,sizeof(dp));

  for(int i=0;i<w;i++)
    for(int j=0;j<w;j++)
      if(abs(i-j)<=1) dp[i][1][j]=1;
  
  for(int j=1;j<H-1;j++)
    
    for(int i=0;i<w;i++){
      
      for(int k=0;k<w;k++)

	for(int l=0;l<w;l++)
	  dp[i][j+1][l]=(dp[i][j+1][l]+dp[i][j][k]*dp[k][j][l]%M)%M;

  }
  
}

void update(int num){

  int bit=1;
  
  while(num){
    
    if(num%2){
      
      for(int i=0;i<w;i++) ans[!idx][i]=0;
      
      for(int i=0;i<w;i++)

	for(int j=0;j<w;j++)
	
	  ans[!idx][j]=(ans[!idx][j]+ans[idx][i]*dp[i][bit][j]%M)%M;
      
      idx=!idx;
      
    }

    num/=2;
    
    bit++;
    
  }
  
}

main(){
  
  int T=1;
  
  while(1){
  
    cin>>w>>h>>n;
    if(!w&&!h&&!n) break;

    init();
    
    vector<P> point;
    vector<int> Y;
    
    for(int i=0;i<n;i++){

      int x, y;
      cin>>x>>y;
      
      x--, y--;
      
      if(y==0) continue;
      
      point.push_back(P(y,x));
    }

    sort(point.begin(),point.end());
    
    int py=-1;
    
    for(int i=0;i<point.size();i++)
      if(py!=point[i].first){
	py=point[i].first;
	Y.push_back(py);
      }
    
    memset(ans,0,sizeof(ans));
    
    ans[0][0]=1;

    idx=0;
    
    py=0;
    
    for(int i=0;i<Y.size();i++){
      
      update(Y[i]-py);
      
      for(int j=0;j<point.size();j++){
	
	if(point[j].first!=Y[i]) continue;

	ans[idx][point[j].second]=0;
      }
      
      py=Y[i];
    }

    update(h-1-py);
    
    cout<<"Case "<<T++<<": ";
    
    cout<<ans[idx][w-1]<<endl;
  }
  
}

Measured memory_bytes: 5928
#include <iostream>

using namespace std;

void rotate(int f[], int t[]) {
    t[0] = f[0];
    t[2] = f[2];
}

void rollf(int a[]) {
    int t = a[0];
    a[0] = a[1];
    a[1] = a[2];
    a[2] = a[3];
    a[3] = t;
}

void rollb(int a[]) {
    int t = a[3];
    a[3] = a[2];
    a[2] = a[1];
    a[1] = a[0];
    a[0] = t;
}

int main() {
    int v[] = { 1, 2, 6, 5 };
    int h[] = { 1, 4, 6, 3 };
    int fs[6];
    string cmd;

    for (int i=0; i<6; ++i) {
        cin>>fs[i];
    }
    cin>>cmd;

    for (int i=0; i<cmd.size(); ++i) {
        if (cmd[i] == 'N') {
            rollf(v);
            rotate(v, h);
        } else if (cmd[i] == 'S') {
            rollb(v);
            rotate(v, h);
        } else if (cmd[i] == 'E') {
            rollf(h);
            rotate(h, v);
        } else if (cmd[i] == 'W') {
            rollb(h);
            rotate(h, v);
        }
    }

    int i = v[0] - 1;
    cout<<fs[i]<<endl;

    return 0;
}



Measured memory_bytes: 3204
/**
 * Created by hiroqn on 13/10/04.
 */
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
var temp, n, m, p, arr;
function solve(n, m, p, xl) {
  if (xl[m] === 0) {
    return 0;
  }
  var sum = xl.reduce(function (p, c) {
    return p + c
  });
  sum *= 100 - p;
  return ~~(sum / xl[m]);
}
while (input[0] !== '0 0 0') {
  temp = input.shift().split(' ');
  arr = [];
  n = temp[0] - 0;
  m = temp[1] - 1;
  p = temp[2] - 0;
  for (var i = 0; i < n; i++) {
    arr[i] = input.shift() - 0;
  }
  console.log(solve(n, m, p, arr));
}

Measured memory_bytes: 9868
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

string s;
ll k;
int main(){
    cin>>s>>k;
    int n=s.size();
    rep(i,n){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            break;
        }
        else{
           if(i+1==k){
               cout<<1<<endl;
               break;
           } 
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define MAX 105000
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
ll ar[MAX];
void divisor(){
    for (int i = 1; i <= MAX; i++)
    {
        for (int j = i; j <= MAX;j+=i)
        {
            ar[j]++;
            
        }
        
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    ll a,b;
    cin >> a >> b;
    if(a > b){
    for (int i = 0; i < a; i++)
        {
            cout << b;
        }
        cout << endl;
    }else
    {
        for (int i = 0; i < b; i++)
        {
            cout << a;
        }
        cout << endl;
        
    }
    
        
}

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

int a[1005];

int main(){
  
  while(1){
  
    int n, m;
    cin>>n>>m;
    
    if( !n && !m ) break;
    
    for(int i=0;i<n;i++) cin>>a[i];
  
    int ans = 0;
  
    for(int i=0;i<n;i++){
    
      for(int j=i+1;j<n;j++){
      
	int sum = a[i] + a[j];
      
	if( sum <= m ) ans = max( ans, sum );
      
      }
    
    }
  
    if( ans == 0 ) cout<<"NONE"<<endl;
    else cout<<ans<<endl;

  }
  
  return 0;
}



Measured memory_bytes: 3096
open Batteries
class union_find n = object (self)
  val mutable par = ( [| |] : int array)
  method init = 
    par <- Array.init n (fun a -> a)
  method get_par = par

  method root s = 
    let rec loop x =
      if par.(x) = x then x else (par.(x) <- loop par.(x); par.(x))
    in loop s

  method rank s =
    let rec loop x n =
      if par.(x) = x then n else loop par.(x) (n+1)
    in loop s 1

  method unite x y =
    let xrank = self#rank x in
    let yrank = self#rank x in
    let rx = self#root x in
    let ry = self#root y in
    if rx != ry then (if xrank < yrank then par.(rx) <- ry else par.(ry) <- rx)

  method unite2 x y =
    let rx = self#root x in
    let ry = self#root y in
    if rx != ry then par.(rx) <- ry

  method same x y = self#root x = self#root y
end

let nm = Scanf.sscanf (read_line()) "%d %d" (fun n m ->
  [n; m]
)
let n = List.hd nm
let m = List.nth nm 1
let p = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a))

let tree = new union_find n
let _ = tree#init
let rec loop i =
  match i with
  | i when i = m -> ()
  | _ -> Scanf.scanf "%d %d\n" (fun x y -> tree#unite (x-1) (y-1)); loop (i+1)
let _ = loop 0
let _ = List.map (fun k -> tree#root k) @@ Array.to_list tree#get_par
let rec ans i = 
  match i with
  | i when i = n -> 0
  | _ -> if tree#same i ( p.(i) - 1) then 1 + ans (i+1) else ans (i+1)
let _ = Printf.printf "%d\n" @@ ans 0


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int Atim,Btim;
    Atim = B-A;
    Btim = D-C;

    int start = max(A, C);
    int endtime = min(B, D);

    if (endtime - start > 0){
        cout << endtime - start << endl;
    } 

    else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
n, q = gets.chomp.split.map(&:to_i)
start = 0
q.times{
    a, b = gets.chomp.split.map(&:to_i)
    case a
    when 0
        x = (b + start) % n
        x = n if x == 0
        puts x
    when 1
        start = (b + start) % n
    end
}


Measured memory_bytes: 6876
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef  long long ll;


int main(){
  int N;
  vector<int>C,S,F;
  ll sum = 0;
  cin >> N;

  for(int i = 0; i < N-1; i++){
    int a, b, c;
    cin >> a >> b >> c;

    C.push_back(a);
    S.push_back(b);
    F.push_back(c);
  }

  
  for(int j = 0; j < N-1; j++){
    for(int i = j; i < N-1; i++){
      int box;
      if(sum > S[i]){
        box = (sum-S[i])/F[i];
        if((sum-S[i]) % F[i])
          ++box;
        sum = S[i]+F[i]*box+C[i];
      }
      else{
        sum = S[i] + C[i];
      }
    }
    cout << sum <<endl;
    sum = 0;
  }
  cout << 0 << endl;
  

  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

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

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(i, n) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if ((x % 3 == 0) || (x % 5 == 0)) {
				continue;
			} else {
				cout << "DENIED\n";
				return 0;
			}
		}
	}
	cout << "APPROVED\n";
}

Measured memory_bytes: 256
from sys import stdin
S=(stdin.readline().rstrip())
ans=0
for i in range(0,len(list(S))+1):
    for j in range(0,len(list(S))+1):
        if set(list(S)[i:j]) <= {"A","T","C","G"}:
            if len(list(S)[i:j]) > ans:
                ans=len(list(S)[i:j])
print(ans)

Measured memory_bytes: 3064
import copy
import collections

N = int(input())
A=[]
for j in range(N): 
    A.append(collections.deque(int(i) for i in input().split()))

day = 0
empty = [0] * N 
s = [i for i in range(N)]

#whileループ一回を一日と考える
while N==N:
    #print(A)
    q = []
    day +=1
    for i in s:
        #print(A)
        #print(i)
        #i行目が空なら空であることを示すemptyリストを1に
        if len(A[i]) == 0:
            empty[i] = None
        #iが既にqに入っていればパス
        elif i in q:
            pass
        #i行目の末尾の数字で示された相手方が一致していればキューに追加
        elif int(A[int(A[i][0])-1][0]) == i+1:
                #print(i, int(A[i][-1]))
                q.append(i)
                q.append(int(A[i][0])-1)
                s = copy.copy(q)
    #ループ後にqが空ならそれ以上進めないので判定
    if len(q) == 0:
        if not(0 in empty):
            print(day-1)
            exit()
        else:
            print(-1)
            exit()
    
    #そうでなければキューに追加されている行の末尾を削除する
    else:
        for d in q:
            #print(d)
            A[d].popleft()

Measured memory_bytes: 78300
using System;
using System.Text.RegularExpressions;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            // かず
            int m;
            int[] N = new int[32] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
            m = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(N[m-1]);
        }
    }
}


Measured memory_bytes: 27452
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 410

int N, A[SIZE];
ll dp[SIZE][SIZE], sum[SIZE];

ll calc(ll A, ll B) {
  ll res = 0, c = 0;

  while (A || B || c) {
    res += (A % 10) * (B % 10) + c;
    c = ((A % 10) + (B % 10) + c) / 10;
    A /= 10;
    B /= 10;
  }

  return res;
}

int main() {
  scanf("%d", &N);

  for (int i = 0; i < N; i++) {
    scanf("%d", A + i);
    sum[i + 1] = sum[i] + A[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dp[i][j] = LLINF;
    }

    dp[i][i] = 0;
  }

  for (int w = 2; w <= N; w++) {
    for (int l = 0; l + w <= N; l++) {
      int r = l + w - 1;
      for (int c = l; c < r; c++) {
        ll A = sum[c + 1] - sum[l];
        ll B = sum[r + 1] - sum[c + 1];
        dp[l][r] = min(dp[l][r], dp[l][c] + dp[c + 1][r] + calc(A, B));
      }
    }
  }

  printf("%lld\n", dp[0][N - 1]);

  return 0;
}


Measured memory_bytes: 4172
#include<iostream>

using namespace std;

int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    
    if( (x-r) < 0  || (x+r) > w || (y-r) < 0 || (y+r) > h){
        cout << "No" << endl;
    } else{
        cout << "Yes" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3116
// Author : Naresh Bharasagar
// Instt. : Indian Institute of Technology Guwahati

//--------------------------------------------------------------------------------------------------------------------------------

#include<bits/stdc++.h>
using namespace std;
typedef long long int loo;
typedef long double ld;

#pragma GCC target ("sse4.2")
#define loop(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define loopset(it,val,dtype) for(set<dtype>::iterator it=val.begin(); it!=val.end(); it++)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vloo vector<loo>
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
#define ploo pair<loo,loo>
#define fillz(a) memset(a,0,sizeof(a))
#define outa(a,n) loop(i,0,n) cout << a[i] << " ";
#define pr(a) cout << a << "\n";
#define pb(l) push_back(l)
#define ff first
#define ss second
#define input(a) for(auto &i: a) cin >> i;
#define deb0(i) cout << "[" << #i << "=" << i << "]" << endl;
#define nl cout << "\n";
#define INF 1000000000
#define M 1000000007

string decToBin(loo n) {
	string s = "0";
	if(n == 0) return s;
	s = "";
    while (n > 0) { 
        s += (n % 2) + '0';
        n = n / 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
 
loo binToDec(string s) {
    loo ans = 0;
    reverse(s.begin(), s.end());
    loop(i, 0, s.size()) ans += pow(2, i)*(s[i] - '0');
    return ans;
}

// ----------------------------------------------------------------

void solve() {
    loo n;
    cin >> n;
    loo a[n];
    loo mx = 1;
    loop(i,0,n) {
        cin >> a[i];
        if(a[i]) mx = max(mx,loo(log2(a[i]))+1);
    }
    loo allxor = 0;
    loop(i,0,n) {
        allxor^=(a[i]^a[i+1]);
        i++;
    }
    if(allxor) mx=max(mx,loo(ceil(log2(allxor))));
    string allx = decToBin(allxor);
    allx = string(mx-allx.size(),'0')+allx;
    // deb0(allx);
    loop(i,0,n) {
        // deb0(i);
        string d = decToBin(a[i]);
        d = string(mx-d.size(),'0')+d;
        string res = string(mx,'0');
        // deb0(d);
        loop(j,0,mx) {
            if(allx[j]=='0') {
                res[j]=d[j];
            }
            else {
                if(d[j]=='1') res[j]='0';
                else res[j]='1';
            }
        }
        cout << binToDec(res) << " ";
    }
    nl;
}

int main() {
	fast_io

    // freopen("filename.in","r",stdin);
    // freopen("filename.out","w",stdout);

    loo q = 1;
    // cin >> q;
    while(q--) {
        solve();
    }

    return 0;
}

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    cout << (n / 100 * 105 >= n);
    return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
id = [0]*(n+1)

for _ in range(m):
    l,r = map(int, input().split())
    id[l-1] += 1
    id[r] -= 1

res = 0
x = 0
for i in range(n+1):
    x += id[i]
    if x==m:
        res += 1

print(res)


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

#define int long long

using namespace std;

const int MAXN = 3010;

int dp[MAXN][MAXN][4];

int A[MAXN][MAXN];

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int R, C, K;
    cin >> R >> C >> K;

    for(int i = 0 ; i < K ; i++)
    {
    	int x, y, v;
    	cin >> x >> y >> v;

    	A[x][y] = v;  
    }

    dp[1][1][0] = 0;
    dp[1][1][1] = A[1][1];

    for(int i = 1 ; i <= R ; i++)
    {
    	for(int j = 1 ; j <= C ; j++)
    	{
    		for(int k = 0 ; k <= 3 ; k++)
    		{
    			if(j)
    			{
    				dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k]);
    				if(k)dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + A[i][j]);
    			}
    			if(i)
    			{
    				dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k]);
    				if(k)dp[i][j][k] = max(dp[i][j][k], max({dp[i-1][j][0], dp[i-1][j][1], dp[i-1][j][2], dp[i-1][j][3]}) + A[i][j]);
    			}
    		}
    	}
    }

    cout << max({dp[R][C][0], dp[R][C][1], dp[R][C][2], dp[R][C][3]}) << '\n';

    return 0;
}

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

int main() 
{
    
    float a, b;
    cin >> a >> b;
    float x = (a+b)/2;
    // cout << x;
    if (x==(int)x)
        cout << x;
    else
        cout << (int)x+1;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    int n = in.ni(), m = in.ni();
    int[] h = new int[n + 1];
    boolean[] good = new boolean[n + 1];
    for (int i = 1; i <= n; i++) {
      h[i] = in.ni();
      good[i] = true;
    }
    for (int i = 0; i < m; i++) {
      int u = in.ni(), v = in.ni();
      if (h[u] > h[v]) {
        good[v] = false;
      } else if (h[u] < h[v]) {
        good[u] = false;
      } else {
        good[u] = good[v] = false;
      }
    }
    int result = 0;
    for (int i = 1; i <= n; i++) {
      if (good[i]) {
        result++;
      }
    }
    out.println(result);
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


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

int main()
{
    long long int n,m,i,j,k,b,tmp;
    char a[9999];
    while(scanf("%s",a)==1)
    {


    for(i=0,k=0;i<3;i++)
    {
        if(a[i]==a[i+1]){k++;}
    }
    if(k==0){printf("Good\n");}
    else{printf("Bad\n");}


    }

    return 0;

}


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

using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
    int n;
    cin >> n;
    string s, t; cin >> s >> t;
    int ans = n + n;
    for(int i = 0; i < n; i++){
        string sd = s.substr(n - i - 1, i + 1);
        string td = t.substr(0, i + 1);
        //    cerr << sd << " : " << td << endl;
        if(sd == td){
            ans = n + n - i - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int x,n;
    cin >>x>>n;
    int p[n];
    for(int i= 0;i<n;i++) cin>>p[i];
    int sai = 110;
    int ko = 110;
    for(int i = 0;i<110;i++){
      bool dame = false;
      int sa = 0;
      for(int j = 0;j<n;j++){
        if(p[j] == i){
          dame = true;
          break;
        }
      }
      if(dame == false){
        sa = abs(i-x);
        if(sa < sai){
          sai = sa;
          ko = i;
        }
      }
    
    }
    cout<<ko;
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    int n,d,x;
    cin >> n >> d >> x;

    int sum = x;
    for (int i = 0; i < n; i++)
    {
        int num = 0;
        cin >> num;

        int chocolate = 1;
        while (chocolate <= d)
        {
            sum++;
            chocolate += num;
        }
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 256
N = list(input())
lenN = len(N)
retN = []
toNext = 0
for n in reversed(N):
    n = int(n) + toNext
    lenN = lenN - 1
    toNext = 0
    if n < 9 and lenN != 0:
        toNext = -1
        retN.append(9)
        continue
    retN.append(n) 

print(sum(retN))

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

using namespace std;
using std::vector;

#define MAX_N 100

int selectionSort(vector<int>& A, int N) {
  int minj = 101;
  int sw = 0;
  for (int i = 0; i < N; i++) {
    minj = i;
    for (int j = i; j < N; j++) {
      if (A[j] < A[minj])
        minj = j;
    }
    if (i != minj)
      sw++;
    swap(A[i], A[minj]);
  }
  return sw;
}


int main() {

  vector<int> A;
  int N, sw;

  cin >> N;
  A.reserve(N);
  for (int i = 0; i < N; i++) {
    int v;
    cin >> v;
    A.push_back(v);
  }

  sw = selectionSort(A, N);
  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl
       << sw << endl;
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
     ll n, k;
    cin>>n>>k;
    ll h[n];
    for (ll i = 0; i < n; i++)
    {
        /* code */
        cin>>h[i];
    }
    vector<ll> dp(n, 1e10);
    dp[0] = 0;
    // dp[1] = abs(h[1] - h[0]);
    for(ll i=1; i<n; i++)
    {
        for(ll j = 1; j <= k; j++)
        {
            if(i>=j)
                dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i]);
        }
    }
    cout<<dp[n-1]<<'\n';
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
  std::cin >> s;
  int a = s[0]-'0', b = s[1]-'0', c = s[2]-'0', d = s[3]-'0';
  if  ((a+b+c+d)==7) return 0*printf("%d+%d+%d+%d=7\n", a,b,c,d);
  if  ((a+b+c-d)==7) return 0*printf("%d+%d+%d-%d=7\n", a,b,c,d);
  if  ((a+b-c+d)==7) return 0*printf("%d+%d-%d+%d=7\n", a,b,c,d);
  if  ((a+b-c-d)==7) return 0*printf("%d+%d-%d-%d=7\n", a,b,c,d);
  if  ((a-b+c+d)==7) return 0*printf("%d-%d+%d+%d=7\n", a,b,c,d);
  if  ((a-b+c-d)==7) return 0*printf("%d-%d+%d-%d=7\n", a,b,c,d);
  if  ((a-b-c+d)==7) return 0*printf("%d-%d-%d+%d=7\n", a,b,c,d);
  if  ((a-b-c-d)==7) return 0*printf("%d-%d-%d-%d=7\n", a,b,c,d);

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// nの約数を昇順に列挙したvectorを返す。計算量はO(√n)
vector<ll> yakusu(ll n) {
    vl res;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i == 0) {
            res.pb(i);
            if(i != n/i) {
                res.pb(n/i);
            }
        }
    }
    sort(all(res));
    return res;  
}

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

    vl v = yakusu(m);
    ll ans = 1;
    for(auto p : v) {
        if(p*n <= m) {
            ans = p;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256