akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
const int INF=1e9;
int dp[50][1010][1010];
 
signed main()
{
  int N,X,Y; cin>>N>>X>>Y;
  vector<int> a(N),b(N),c(N);
  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
 
  for(int i=0;i<=N;i++){
    for(int j=0;j<=1000;j++){
      for(int k=0;k<=1000;k++){
        dp[i][j][k]=INF;
      }
    }
  }
  dp[0][0][0]=0;
 
  for(int i=0;i<N;i++){
    for(int j=0;j<=1000;j++){
      for(int k=0;k<=1000;k++){
        if(dp[i][j][k]==INF) continue;
 
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
        if(j+a[i]<=1000 and k+b[i]<=1000){
          dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
        }
      }
    }
  }
 
  int ans=INF;
  for(int r=1;;r++){
      int x=r*X;
      int y=r*Y;
      if(x<=1000 and y<=1000){
        ans=min(ans,dp[N][x][y]);
      }else break;
  }
  cout<<(ans==INF? -1:ans)<<endl;
 
  return 0;
}


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

void fnInput(vector<int> &rviTrg, vector<int> &rviSch)
{
  int iTrgCnt;
  cin >> iTrgCnt;

  rviTrg.resize(iTrgCnt);
  for (int i = 0; i < iTrgCnt; i++)
    cin >> rviTrg[i];

  int iSchCnt;
  cin >> iSchCnt;

  rviSch.resize(iSchCnt);
  for (int i = 0; i < iSchCnt; i++)
    cin >> rviSch[i];
}

void fnBinSch(const vector<int> &cnrviTrg, const vector<int> &cnrviSch, int &riFnd)
{
  for (int i = 0; i < cnrviSch.size(); i++)
  {
    int iLow  = 0;
    int iHigh = cnrviTrg.size();
    while (iLow < iHigh)
    {
      int iMid = (iLow + iHigh) / 2;
      if (cnrviSch[i] == cnrviTrg[iMid])
      {
        riFnd++;
        break;
      }
      else if (cnrviSch[i] < cnrviTrg[iMid])
        iHigh = iMid;
      else
        iLow  = iMid + 1;
    }
  }
}

void fnResult(int a_iFnd)
{
  cout << a_iFnd << endl;
}

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

  vector<int> viTrg, viSch;
  int iFnd = 0;

  fnInput(viTrg, viSch);
  fnBinSch(viTrg, viSch, iFnd);
  fnResult(iFnd);

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b, res = 0;
    cin >> a >> b;
    res += a - 1;
    if (b >= a)
        res++;
    cout << res << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Objects;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();

        int n = sc.nextInt();
        for(int i=1;i<=n;i++){
            int tmp = i;
            if(i%3==0)System.out.print(" "+i);
            else{
                while(tmp!=0){
                    if(tmp%10==3){
                        System.out.print(" "+i);
                        break;
                    }
                    tmp /= 10;
                }
            }
        }
        System.out.println();

    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

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

typedef long long LL;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;
typedef pair<int, int> Pii;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(int argc, char const *argv[]) {
  cin.tie(0); ios::sync_with_stdio(false);
  int H,tmp; std::cin >> H;
  Vi h; h.reserve(H);
  REP0(i,H){ std::cin >> tmp; h.PB(tmp); }

  REP1(i,H){
    std::cout << "node " << i << ": key = " << h[i-1] << ", ";
    if (i!=1) std::cout << "parent key = " << h[i/2-1] << ", ";
    if (i*2<=H) std::cout << "left key = " << h[i*2-1] << ", ";
    if (i*2+1<=H) std::cout << "right key = " << h[i*2] << ", ";
    std::cout << '\n';
  }

  return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n;
    cin >> n;
    int maxi = 1;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;
        if(mp.count(s)){
            mp.at(s)++;
            maxi = max(maxi,mp.at(s));
        }
        else mp[s] = 1;
    }

    for(auto x : mp){
        if(x.second == maxi) cout << x.first << endl;
    }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
const int N=500005;
int n,q,a[N],l[N],r[N],b[N],c[N],ans[N];
vector<pair<int,int>>x[N];
void add(int x,int v)
{
	for(int i=x;i<=n;i+=i&(-i))
		b[i]+=v;
}
int sum(int x)
{
	int v=0;
	for(int i=x;i;i-=i&(-i))
		v+=b[i];
	return v;
}
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&l[i],&r[i]);
		x[r[i]].emplace_back(l[i],i);
	}
	for(int i=1;i<=n;i++)
	{
		if(c[a[i]])
			add(c[a[i]],-1);
		c[a[i]]=i;
		add(i,1);
		for(auto zh:x[i])
			ans[zh.second]=sum(i)-sum(zh.first-1);
	}
	for(int i=1;i<=q;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 37160
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  double a, b;

  while ( scanf ( "%lf%lf", &a, &b ) == 2 )
  {
    if      ( a < 35.5 && b < 71.0  ) puts ( "AAA" );
    else if ( a < 37.5 && b < 77.0  ) puts ( "AA" );
    else if ( a < 40.0 && b < 83.0  ) puts ( "A" );
    else if ( a < 43.0 && b < 89.0  ) puts ( "B" );
    else if ( a < 50.0 && b < 105.0 ) puts ( "C" );
    else if ( a < 55.0 && b < 116.0 ) puts ( "D" );
    else if ( a < 70.0 && b < 148.0 ) puts ( "E" );
    else                              puts ( "NA" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int n,k;
int main()
{
    cin>>n>>k;
   // int dp[k+4]={0};
    int a[n+1];
    cin>>a[0]; 
    for(int i=1;i<n;++i)
        {cin>>a[i];}
   
    int dp1[k+1]={0};
     dp1[0] = 0;
    for(int i=1;i<=k;i++)
    {
    	dp1[i] = 0;
    	for(int j=0;j<n;j++)
    	{
    		if(i-a[j]>=0){
    			if(!dp1[i-a[j]]){
    				dp1[i] = 1;
    				break;
    			}
    		}
    	}
    }
      cout<<(dp1[k]?"First":"Second")<<endl;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    int x, y;
    cin >> x >> y;
    if(y % 2 != 0 || x * 4 < y || y < x * 2){
        cout << "No" << endl;
    }else{
        cout  << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B) = Slice2<long>();
            if (A * B % 2 == 0)
                WriteLine("No");
            else
                WriteLine("Yes");
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27420
package main

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

func main() {
	nextReader = newScanner()
	a, b, k := nextInt(), nextInt(), nextInt()

	ans1 := max(a-k, 0)
	ans2 := max(b-max(k-a, 0), 0)
	fmt.Printf("%d %d\n", ans1, ans2)
}

func max(n, m int) int {
	if n >= m {
		return n
	}
	return m
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    int k;
    cin >> s >> k;
    int cnt = 1, res1 = 0;
    rep(i, s.size() - 1)
    {
        if (s[i] == s[i + 1])
            cnt++;
        else
        {
            res1 += cnt / 2;
            cnt = 1;
        }
    }
    if (cnt == s.size())
    {
        cout << (cnt * k) / 2 << endl;
        return 0;
    }
    res1 += cnt / 2;
    cnt = 1;
    s += s;
    int res2 = 0;
    rep(i, s.size() - 1)
    {
        if (s[i] == s[i + 1])
            cnt++;
        else
        {
            res2 += cnt / 2;
            cnt = 1;
        }
    }
    res2 += cnt / 2;
    int ans = (k - 1) * res2 - (k - 2) * res1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll>
#define pic pair<ll,char>
#define vi vector< ll >
#define vvi vector< vi >
#define vpi vector< pii >
#define vvpi vector< vpi >
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii >
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ll fact[1000001];
ll inv[1000001];
void factorial()
{
  ll i;
  fact[0] = 1;
  inv[0] = power(fact[0],mod-2);
  for(i=1;i<=1000000;i++)
  {
    fact[i] = (i*fact[i-1])%mod;
    inv[i] = power(fact[i],mod-2);
  }
}
ll ncr(ll x,ll y)
{
  if(x<y)
    return 0;
  ll temp = fact[x];
  temp = (temp*inv[y])%mod;
  temp = (temp*inv[x-y])%mod;
  return temp;
}
signed main()
{
    fast;
    factorial();
    ll h,w,n;
    cin>>h>>w>>n;
    pair< ll ,ll > arr[n+1];
    ll dp[n+1];
    ll i,j;
    for(i=0;i<n;i++)
        cin>>arr[i].fi>>arr[i].sec;
    arr[n].fi = h,arr[n].sec = w;
    sort(arr,arr+n+1);
    dp[0] = ncr(arr[0].fi+arr[0].sec-2,arr[0].fi-1);
    for(i=1;i<=n;i++)
    {
        ll tot = ncr(arr[i].fi+arr[i].sec-2,arr[i].fi-1);
        ll j;
        for(j=0;j<i;j++)
        {
            ll temp = dp[j] * ncr(arr[i].fi+arr[i].sec-arr[j].fi-arr[j].sec,max(arr[i].fi-arr[j].fi,arr[i].sec-arr[j].sec))%mod;
            tot = (tot-temp+mod)%mod;
        }
        dp[i] = tot;
    }
    cout<<dp[n];
  }




Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

int main(){
    long long n,a,b; cin >> n >> a >> b;
    long long c = a+b;
    long long x = n/c;
    long long y = n%c;
    long long z = min(a,y);
    cout << x*a + z << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int count=0;
  ll a;
  rep(i,n){
    cin>>a;
    while(a%2==0){
      count++;
      a/=2;
    }
  }
  cout<<count<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include<unordered_set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <math.h>

#define lli long long int
#define ld long double
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    lli n, m;
    cin>>n>>m;
    string s;
    for(int i = 0; i < n; i ++)
        s += '0';
    lli XX[3];
    XX[0] = XX[1] = XX[2] = -1;
    bool ok = 1;
    while(m --) {
        lli idx, val;
        cin>>idx>>val;
        idx --;
        if(XX[idx] != -1 && XX[idx] != val)
            ok = 0;
        s[idx] = '0' + val;
        if(XX[idx] == -1)
            XX[idx] = val;
    }
    if(ok == 0 || (XX[0] == 0 && n != 1)) {
        cout<<-1;
        return ;
    }
    if(s[0] == '0' && n != 1)
        s[0] = '1';
    cout<<s;
    cout<<'\n';
    return ;
}

/*
*/

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

//    pre();

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}
/*
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n;
  cin>>n;
  cout<<(n-2)*180<<endl;
  return 0;
}


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];
std::vector<long long> primeFactors(long long n){
	std::vector<long long > f;
	for(long long i=2;i*i<=n;i++){
		while(n%i==0){
			f.push_back(i);
			n/=i;
		}
	}
	if(n>1)f.push_back(n);
	return f;
}

ll hh(ll n){
	ll x = sqrt(4LL*2LL*n+1LL);
	x -= 1;
	return x/2;
}

int solve() 
{
	//happy coding

	ll n;
	cin>>n;

	vll v = primeFactors(n);
	//vout(v);
	std::map<ll, ll> m;
	for(ll i: v){
		m[i]++;
	}
	ll cnt = 0LL;
	for(auto i: m){
		cnt += hh(i.second);
	}
	cout<<cnt<<endl;
	
	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 3724
#include<stdio.h>
int main (){
int a,b;
scanf ("%d%d",&a,&b);
  if (a==2 || b==2){
  printf ("No");
  }
  else {
  if (a==4 || a==6 || a==9 || a==11){
  if (b==4 || b==6 || b==9 || b==11){
  printf ("Yes");
  }
  else {printf ("No");}
  }
  else{
  if(b==4 || b==6 || b==9 || b==11){
  printf ("No");
  }
    else{
    printf ("Yes");
    }
  }
  }
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<iterator>
#include<string>
#include<algorithm>
using namespace std;
#define INF int(2e9)
typedef pair<int, int> P;
inline int in() {
	int temp;
	scanf("%d", &temp);
	return temp;
}
int sx, sy, ty, tx;
string ans;
void print(int a, char c)
{
	for (int i = 0; i < a; i++)
	{
		ans+= c;
	}
}
int main(){
	cin >> sx >> sy >> tx >> ty;
	print(ty - sy, 'U');
	print(tx - sx, 'R');
	print(1, 'U');
	print(tx - sx + 1, 'L');
	print(ty - sy + 1, 'D');
	print(1, 'R');
	print(tx - sx, 'R');
	print(ty - sy, 'U');
	print(1, 'R');
	print(ty - sy + 1, 'D');
	print(tx - sx + 1, 'L');
	print(1, 'U');
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

using namespace std;

int main()
{
	int sum = 0;
	for (int i = 0; i < 10; i++) {
		int s;
		cin >> s;
		sum += s;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3084
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <random>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>
#include <unordered_set>
#include <unordered_map>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const long double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll M = 1000000007;
const ll LLINF = 1000000000000000000;
const double EPS = 1e-8;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    vector<int> x(n);
    map<int, int> mp = {};
    FOR(i, 0, n) {
        cin >> x[i];
        mp[x[i]] = i;
    }
    int l;
    cin >> l;
    vector<vector<int> > st(n, vector<int>(21));
    FOR(i, 0, n)
        st[i][0] = mp[*(--upper_bound(x.begin(), x.end(), x[i] + l))];
    FOR(j, 1, 21) {
        FOR(i, 0, n) {
            st[i][j] = st[st[i][j - 1]][j - 1];
            // cout << i << ' ' << j << ' ' << st[i][j] << endl;
        }
    }
    int m, a, b, cr, ans;
    cin >> m;
    while (m--) {
        cin >> a >> b;
        if (a > b)
            swap(a, b);
        --a; --b;
        ans = 0;
        cr = a;
        ROF(j, 20, -1) {
            if (st[cr][j] < b) {
                cr = st[cr][j];
                ans += (1 << j);
            }
        }
        ++ans;
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 29800
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n){
    cin>>a[i];
  }

  int save=1,cnt=0;
  rep(i,n){
    if(a[i]!=save)cnt++;
    else save++;
  }

  if(save==1)cout<<"-1";
  else cout<<cnt;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	bool flag=false;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			for(int j=i;j<s.size();j++)
			{
				if(s[j]=='F'){
					flag=true;
//					cout<<"gada";
				}
			}
		}
	}
	if(flag==true)
		printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 384
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

//Author: Jiangsu Nanjing Li Zongtai
//强壮标记*10000,手牌*10000,血量10000 lyl+hzj也打不死我哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈~~~~
//注意要不要long long

const int inf=2147483647;

int num[111111];
int n;
int ans;

int main()
{
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		x++;
		num[x]++;
	}
	
	for(int i=1;i<=100000;i++)
	{
		ans=max(ans,num[i-1]+num[i]+num[i+1]);
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<vector>
#include<iostream>

using namespace std;
vector<int>v[1005];
int main(){
// 	freopen("1.in","r",stdin);
	int n,q,p,t,x;
	scanf("%d%d",&n,&q);
	while(q--){
		scanf("%d",&p);
		if(p==0){
			scanf("%d%d",&t,&x);
			v[t].push_back(x);
		}
		else if(p==1){
			scanf("%d",&t);
			int temp=v[t].size();
			if(temp==0) printf("\n");
			else if(temp==1) printf("%d\n",v[t][temp-1]);
			else{
				for(int i=0;i<temp-1;i++) printf("%d ",v[t][i]);
					printf("%d",v[t][temp-1]);
					printf("\n");
			}
		}
		else{
			scanf("%d",&t);
			if(!v[t].empty()) v[t].clear();
		}
	}
	return 0;
}


Measured memory_bytes: 5952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main()
{
    ll N;
    cin >> N;
    string ans;
    while (1)
    {
        if (N < 0)
        {
            N *= -1;
            if (N % 2)
            {
                ans.push_back('1');
                N = N / 2 + 1;
            }
            else
            {
                ans.push_back('0');
                N = N / 2;
            }
        }
        else
        {
            if (N % 2)
            {
                ans.push_back('1');
                N = -N / 2;
            }
            else
            {
                ans.push_back('0');
                N = -N / 2;
            }
        }
        if (0 <= N && N <= 1)
            break;
    }
    if (N == 1)
        ans.push_back('1');
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, std::vector<long long> A)
{
  double hoge = 1;
  LL result = 1;
  for (auto elem : A)
  {
    hoge *= elem;
    result *= elem;
    if (hoge >= 2e18)
      hoge = 2e18;
  }
  if (hoge >= 2e18 || result > 1000000000000000000LL)
  {
    result = -1;
  }
  cout << result << endl;
}

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


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll INF = 1e15;

struct edge {
	ll to;
	ll cost;
	ll time;
};

struct Data {
	ll node;
	ll cost;
	ll time;
	Data(ll node, ll cost, ll time) : node(node), cost(cost), time(time){}
	bool operator < (const Data& data) const{
		return cost > data.cost;
	}
	bool operator > (const Data& data) const {
		return cost < data.cost;
	}
};

int main(void)
{
	ll n, m,s;
	cin >> n >> m >> s;
	s = min(s, 50LL * 100);

	vector<vector<edge>> edges(n + m);
	rep(i, m) {
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		edges[u].push_back({v, -a, b});
		edges[v].push_back({u, -a, b });
	}
	rep(i, n) {
		ll c, d;
		cin >> c >> d;
		edges[i].push_back({ i, c, d });
	}
	vector<vector<ll>> dp(n, vector<ll>(50*101, INF));
	priority_queue<Data> q;
	q.emplace(0, s, 0);
	dp[0][s] = 0;
	while (q.size()) {
		auto t = q.top(); q.pop();
		for (auto& e : edges[t.node]) {
			auto to = e.to;
			auto cost = t.cost + e.cost;
			cost = min(cost, 50LL * 100);
			auto time = t.time + e.time;
			if (cost < 0) continue;
			if (dp[to][cost] <= time) continue;
			dp[to][cost] = time;
			q.emplace( to, cost, time );
		}
	}	
	vector<ll> r(n, INF);
	rep(i, n - 1) {
		rep(j, 50 * 101) {
			r[i + 1] = min(r[i + 1], dp[i + 1][j]);
		}
	}
	rep(i, n - 1) {
		cout << r[i + 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 6200
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
	ll s; cin >> s;
	ll ans = s / 11 * 2;
	ans += (s % 11 ? (s % 11 <= 6 ? 1 : 2) : 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N, H, A;
    cin>>H>>N;
  int x;
    for(int i=0; i<N; i++){
        cin>>x;
      H-=x;
          
    }
  if(H<=0){
   cout<<"Yes";
  }
  else if(H>0){
   cout<<"No";
  }
  // put your code here
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner (System.in);
        
		String a=in.next();
		String b=in.next();
		String c=in.next();
		String d="A"+b.charAt(0)+"C";
		System.out.println(d);
	}
}

Measured memory_bytes: 26968
#include <iostream>

using namespace std;

int main() {
	int q1, b, c1, c2, q2;
	while (cin >> q1) {
		if (q1 == 0) {
			break;
		} 
		cin >> b >> c1 >> c2 >> q2;
		if (b < c1) {
			cout << "NA" << endl;
		} else {
			int counter = 0;
			while (q2 > 0 && b >= c1) {
				b -= c1;
				q1--;
				q2--;
				counter++;
			}
			int counter2 = 0;
			while (b >= c2) {
				b -= c2;
				q1--;
				counter2++;
			}
			if (q1 > 0) {
				while (q1 > 0) {
					counter--;
					b += c1;
					q1++;
					if (counter == 0) {
						break;
					}
					while (b >= c2) {
						b -= c2;
						q1--;
						counter2++;
					}
				}
				if (counter > 0) {
					cout << counter << " " << counter2 << endl;
				} else {
					cout << "NA" << endl;
				}
			} else {
				cout << counter << " " << counter2 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	long n, a, b, c, d, e;
	while (readf (" %s %s %s %s %s %s", &n, &a, &b, &c, &d, &e) > 0)
	{
		long res = 0;
		res = max (res, (n + a - 1) / a);
		res = max (res, (n + b - 1) / b);
		res = max (res, (n + c - 1) / c);
		res = max (res, (n + d - 1) / d);
		res = max (res, (n + e - 1) / e);
		res += 4;
		writeln (res);
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) {
        cin>>arr[i];
    }
    if(n==1 && arr[0]!=1)
    {
        cout<<1<<endl;
        return 0;
    }
    unordered_map<int,int>u;
    for(int i=0;i<n;i++) {
        u[arr[i]]++;
    }
    int ans = 0;
    for(int i=0;i<n;i++) {
        if(u.find(arr[i])!=u.end()) {
            if(u[arr[i]] == arr[i] )
            {
                
            }
            else if(u[arr[i]] > arr[i])
            {
                ans = ans + (u[arr[i]]-arr[i]);
            }
            else {
                ans = ans + u[arr[i]];
            }
            u.erase(arr[i]);
        }
        // u[arr[i]]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4644
#include<stdio.h>
int main(void)
{
int a,b,c,s;
scanf("%d%d%d",&a,&b,&c);
s=0;
if(a>=b && a>=c){
s=b+c;
printf("%d",s);
}
else if(b>=a&&b>=c){
s=a+c;
printf("%d",s);
}
else{
s=a+b;
printf("%d",s);
}
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    ll n,in,sumi=0,suma=0,mic=9999999999999999,mac=9999999999999999;
    bool si=true,sa=true;
    cin>>n;
        mic=0;
        mac=0;
        sumi=0;
        suma=0;
        si=!false;
        sa=!true;
        for(int i=0;i<n;i++){
            cin>>in;
            sumi+=in;suma+=in;
            if((sumi<1&&!si)||(sumi>-1&&si)){
                mic+=(si?sumi+1:1-sumi);
                sumi=(si?-1:1);
            }
            if((suma<1&&!sa)||(suma>-1&&sa)){
                mac+=(sa?suma+1:1-suma);
                suma=(sa?-1:1);
            }
            si=!si;
            sa=!sa;
        }
    cout<<min(mac,mic);

}


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

typedef struct data
{
  int k;
  int s;
  int p;
} DATA;

int count_bit(int n)
{
  int count = 0;

  while(n)
  {
    count += n & 1;
    n >>= 1;
  }

  return count;
}

int main(int argc, char **argv)
{
  int i = 0;
  int j = 0;
  int n = 0;
  int m = 0;
  DATA d[10] = {0};
  int s = 0;
  int count = 0;

  scanf("%d %d", &n, &m);

  for(i = 0; i < m; i++)
  {
    scanf("%d", &d[i].k);
    for(j = 0; j < d[i].k; j++)
    {
      scanf("%d", &s);
      d[i].s |= (1 << (s - 1));
    }
  }
  for(i = 0; i < m; i++)
  {
      scanf("%d", &d[i].p);
  }

  for(i = 0; i < (1 << n); i++)
  {
    for(j = 0; j < m; j++)
    {
      if((count_bit(i & d[j].s) & 1) != d[j].p)
      {
        break;
      }
    }
    if(j == m) count++;
  }
  printf("%d\n", count);

  return 0;
}


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

int main(){

  string S;
  cin >> S;

  // int year;
  // int month;
  // int day;

  // year = atoi(S.substr(0, 3).c_str());
  // month = atoi(S.substr(5, 6).c_str());
  // day = atoi(S.substr(8, 9));

  string year = S.substr(0,4);
  string month = S.substr(5,2);
  string day= S.substr(8,2);

  int yyyy = atoi(year.c_str());
  int mm = atoi(month.c_str());
  int dd = atoi(day.c_str());

  // cout << year << "\t" << month << "\t" << day << endl;

  // cout << yy << endl;

  if(yyyy >= 2019 && mm >= 5 && dd >= 1) cout << "TBD" << endl;
  else  cout << "Heisei" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define rep2(n) for(ll j=0 ; j<n ; ++j )
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define pii pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 0x3f3f3f3f
#define sz(a) a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000

int main() {

  int n,m; cin >> n >> m;
  int s=0;
  int a[n]; for(int i=0;i<n;++i) cin >>a[i],s+=a[i]; 
  int c=0;
  for(int i=0;i<n;++i) if( a[i]*4*m >=s) ++c;
  if(c>=m) cout <<"Yes";
  else cout <<"No";
	return 0;
}


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

int main() {
  string s;
  map<char,int> memo;
  cin>>s;
  for(int i=0;i<s.size();i++) memo[s[i]]++;
  bool ans=true;
  for(auto it=memo.begin();it!=memo.end();it++){
    if((it->second)>=2) ans=false;
  }
  if(ans) cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  return 0;
}

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

int main() {
	char  a[100];
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	for (int j = 0; j < n; j++) {
		if (a[j] == 'Y') {
			std::cout << "Four" << std::endl;
			return 0;
		}
	}
	std::cout << "Three" << std::endl;
}

Measured memory_bytes: 256
from functools import lru_cache

n,k = list(map(int, input().split()))

# 2000までの階乗（MOD:10^9+7）とその逆元を計算しておく
MOD = 10**9+7
fact = [1, 1]
fact_inv = [1, 1]

for i in range(2, n+1):
    fact.append(fact[i-1] * i % MOD)
    fact_inv.append(pow(fact[i], MOD-2, MOD))

@lru_cache(maxsize=None)
def combi(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact[n] * fact_inv[k] * fact_inv[n-k] % MOD

for i in range(1, k+1):
    print(combi(n-k+1, i) * combi(k-1, i-1) % MOD)

Measured memory_bytes: 10476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
//#include <bits/stdc++.h>


#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i=0; i<(n); ++i)
#define pb push_back

using namespace std;

typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int H, W;

void dfs(vector<string>& mp, int i, int j, char c) {
    mp[i][j] = '-';
    REP(k, 4) {
        int ni = i + dx[k];
        int nj = j + dy[k];
        if(0 <= ni && ni < H && 0 <= nj && nj < W && mp[ni][nj] == c) {
            dfs(mp, ni, nj, c);
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    // =============================
    while(cin >> H >> W) {
        int ans = 0;
        if(H == 0 && W == 0) break;
        vector<string> mp;
        REP(i, H) {
            string tmp;
            cin >> tmp;
            mp.pb(tmp);
        }
        REP(i, H) {
            REP(j, W) {
                if(mp[i][j] != '-') {
                    ++ans;
                    dfs(mp, i, j, mp[i][j]);
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4124
n=int(input())
h=list(map(int,input().split()))

dp=[float('inf')]*n
dp[0]=0
dp[1]=abs(h[0]-h[1])

for i in range(2,n):
      dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
#include<stdio.h>

int main(void) {
    int n;
    scanf("%d", &n);
    int i, j, w[n], s=0, s1, s2, min=10000;
    for(i=0; i<n; i++)
        scanf("%d", &w[i]);
    for(i=0; i<n-1; i++) {
        s1=0;
        s2=0;
        for(j=0; j<=i; j++) {
            s1+=w[j];
        }
        while(j<n) {
            s2+=w[j];
            j++;
        }
        s=s1-s2;
        if(s<0)
            s*=(-1);
        if(s<=min)
            min=s;
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 128
from operator import itemgetter

N = int(input())
a = []
for i in range(N):
    a.append(list(map(int, input().split())))

a = sorted(a, key=itemgetter(1))
work = 0
for i in range(N):
    work = work + a[i][0]
    if work > a[i][1]:
        print("No")
        break
else:
    print("Yes")


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

int main() {
    int a, b, c, n;
    while(cin >> a >> b >> c >> n, a){
    const int normal = 1;
    const int malfunction = 0;
    const int ambiguous = 2;
    vector <int> state(a + b + c, ambiguous);

    vector <tuple <int, int, int>> passed, failure;
    rep (i, n) {
        int ii, j, k, r;
        cin >> ii >> j >> k >> r;
        ii--, j--, k--;
        r ? passed.emplace_back(ii, j, k) : failure.emplace_back(ii, j, k);
    }

    for (auto in : passed) {
        int i, j, k;
        tie(i, j, k) = in;
        state[i] = state[j] = state[k] = normal;
    }

    vector <int> copy_state = state;
    for (auto in : failure) {
        int i, j, k;
        tie(i, j, k) = in;
        if ((copy_state[i] == ambiguous) + (copy_state[j] == ambiguous) + (copy_state[k] == ambiguous) == 1) {
            if (state[i] == ambiguous) state[i] = malfunction;
            if (state[j] == ambiguous) state[j] = malfunction;
            if (state[k] == ambiguous) state[k] = malfunction;
        }
    }

    /*
    for (;;) {
        bool changed = false;
        for (auto in : failure) {
            int i, j, k;
            tie(i, j, k) = in;
            if (((state[i] == ambiguous) + (state[j] == ambiguous) + (state[k] == ambiguous)) == 1) {
                cout << i << " " << j << " " << k << endl;
                if (state[i] == ambiguous) changed = true, state[i] = malfunction;
                if (state[j] == ambiguous) changed = true, state[j] = malfunction;
                if (state[k] == ambiguous) changed = true, state[k] = malfunction;
                cout << state[i] << " " << state[j] << " " << state[k]  << endl;
            }
        }
        cout << endl;
        if (!changed) break;
    }
    */

    for (auto in : state) cout << in << endl;

    }
    return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>

int kai(long a, int i);

int main(void)
{
	long  s = 1;
	int n;
	scanf("%ld", &n);
	printf("%ld\n", kai(s, n));
	return (0);
}

int kai(long a, int i)
{
	a *= i;
	i--;
	if (i == 1) return (a);
	else return (kai(a, i));
}

Measured memory_bytes: 592
w = list(input())

a = 0
for i in range(3):
  if w[i] == "R":
    a += 1

if w == ["S", "S", "S"]:
    print("0")
else:
    if w == ["R", "R", "R"]:
      print("3")
    elif w[1] == "R" and a == 2:
      print("2")
    else:
      print("1")

Measured memory_bytes: 9016
from collections import deque
n, u, v = map(int,input().split())
tree = [[] for _ in range(n+1)]
for _i in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)


def solve(x):
    visit = [-1 for _ in range(n+1)]
    visit[x] = 0
    q = deque([x])
    while q:
        p = q.popleft()
        for i in tree[p]:
            if visit[i] < 0:
                visit[i] = visit[p]+1
                q.append(i)
    return visit

visit_a = solve(v)
visit_t = solve(u)

x, y = [], []
for i in range(1, n+1):
    if visit_a[i] >= visit_t[i]:
        x.append(visit_a[i])
        y.append(visit_t[i])
p = x.index(max(x))

print(x[p]-1)

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

long long int mod = 1e9 + 7;

long long int modpow(long long int val, long long int power) {
    long long int res = 1;
    while (power > 0) {
        if (power & 1) {
            res = res * val % mod;
        }
        val = val * val % mod;
        power >>= 1;
    }
    return res;
}


int main() {
    int N;
    std::cin >> N;

    long long int res = (modpow(10, N) - modpow(9, N) * 2 + modpow(8, N)) % mod;
    if (res < 0) {
        res += mod;
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 3632
import static java.lang.System.out;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import java.io.File;
import java.util.List;
import java.util.Scanner;

public class Main extends BaseExe {

    public static void main(String[] args) {
        new Main().exeSysIn();
    }

    @Override
    protected void execute() throws Exception {
        out.println(judgeNotInner(getNums()) ? "No" : "Yes");
    }

    private List<Integer> getNums() {
        return asList(nextLine().split(" ")).stream().map(Integer::parseInt).collect(toList());
    }

    private boolean judgeNotInner(List<Integer> nums) {
        return (nums.get(0) < nums.get(2) + nums.get(4))
                || (nums.get(1) < nums.get(3) + nums.get(4)) || (nums.get(2) - nums.get(4) < 0)
                || (nums.get(3) - nums.get(4) < 0);
    }
}

abstract class BaseExe {

    private Scanner scan;

    private String inData;

    public void exeSysIn() {
        try (Scanner scan = new Scanner(System.in)) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void exeFileIn(String inDataPath) {
        try (Scanner scan = new Scanner(new File(inDataPath))) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void exeCtrl(Scanner scan) throws Exception {
        this.scan = scan;
        execute();
    }

    protected abstract void execute() throws Exception;

    protected String nextLine() {
        return scan.nextLine();
    }

    protected boolean judgeInData() {
        return hasNextLine() && isNotEmptyInData();
    }

    protected boolean hasNextLine() {
        return scan.hasNextLine();
    }

    protected boolean isNotEmptyInData() {
        inData = nextLine();
        return !inData.isEmpty();
    }

    protected String getInData() throws Exception {
        if (inData.isEmpty())
            throw new Exception("inData is Empty.");
        return inData;
    }
}

Measured memory_bytes: 32232