akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Doll{
public:
    int h;
    int r;
    int have;
    // static bool Less(const Doll& l, const Doll& r){
    // 	return l.h < r.h;
    // }
    bool operator < (const Doll &d) const{
	if( r == d.r ) return h < d.h;
	else return r < d.r;
    }
    Doll(int x, int y, int z){
	h = x; r = y; have = z;
    }
};

typedef vector<Doll> Dolls;

int main(){
    int n, m, h, r, result=0;
    Dolls dolls;
    while(cin >> n, n){
	for(int i=0; i<n; ++i){
	    cin >> h >> r;
	    Doll temp(h,r,1);
	    dolls.push_back(temp);
	}
	cin >> m;
	for(int i=0; i<m; ++i){
	    cin >> h >> r;
	    Doll temp(h,r,1);
	    dolls.push_back(temp);
	}
//	sort(dolls.begin(), dolls.end(), Doll::Less);
	sort(dolls.begin(), dolls.end());
	for(Dolls::iterator it1=dolls.begin();it1 != dolls.end(); ++it1){
	    for(Dolls::iterator it2=dolls.begin();it2 != it1; ++it2){
		if(it2->h < it1->h && it2->r < it1->r && it1->have <= it2->have){
		    it1->have = it2->have + 1;
//		    result = max(result, it1->have);
		}
	    }
	}
	for(Dolls::iterator it=dolls.begin();it != dolls.end(); ++it)
	    result = max(result, it->have);
	cout << result << endl;
	dolls.clear();
	result = 0;
    }
    return 0;
}

Measured memory_bytes: 1204
n = str(input())
K = int(input())
dp=[[[0]*2 for j in range(4)] for i in range(len(n)+1)]

dp[0][0][0]=1

for i in range(len(n)):
    for j in range(4):
        for k in range(2):
            ntemp = int(n[i])
            for d in range(10):
                ni = i+1
                nj = j
                nk = k
                if d != 0: nj= nj+1
                if nj > K:continue
                if k == 0:
                    if d > ntemp:continue
                    if d < ntemp:nk = 1
                dp[ni][nj][nk] += dp[i][j][k]
ans = dp[len(n)][K][0] + dp[len(n)][K][1]
print(ans)


Measured memory_bytes: 41200
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define pi acos(-1.0)
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main(int argc, char const *argv[])
{
   FastIO;
   int n;
   cin>>n;
   ll sum=0;
   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=n;j++)
       {
           for(int k=1;k<=n;k++)
           {
               //cout<<i<<" "<<j<<" "<<k<<endl;
               sum+=__gcd(i,__gcd(j,k));
           }
       }
   }
   cout<<sum<<endl;
   return 0;
}


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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    for (int i = A; i <= B; i++)
    {
        if(i < A + K || B - K < i) cout << i << endl; 
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,i;
	int ai[1000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&ai[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d",ai[i]);
		if(i){
			printf(" ");
		}
		else{
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll a, ll b, ll c) {
  cout << a+b+c-max({a,b,c}) << endl;
}

int main() {
  ll a;
  cin >> a;
  ll b;
  cin >> b;
  ll c;
  cin >> c;
  solve(a, b, c);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define asll unsigned long long
#define pii pair<int,int>
#define st first
#define nd second

asll M=1e9+7;//20190518
vector<int> v;

asll min(asll a,asll b){
	return a*(a<b)+b*(b<=a);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	srand(time(0));//20190709
	asll l,r;
	cin>>l>>r;
	/*
	for(int i=0;i<2019;i++){
		md[i]=0;
	}
	*/
	for(int i=l;i<=min(r,l+2018);i++){
		v.push_back(i%2019);
		//cout<<i%2019<<endl;
	}
	asll best=2019*2019;
	for(int i=0;i<v.size()-1;i++){
		for(int j=i+1;j<v.size();j++){
			best=min(best,(v[i]*v[j])%2019);
		}
	}
	cout<<best<<endl;
	
}



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

int gcd(int x, int y) {
    return (x % y ? gcd(y, x % y) : y);
}

int main(){

    int n;

    cin >> n;

    int ans = 0;
    rep(i, n) {
        rep(j, n) {
            rep(k, n) {
                ans += gcd(i+1, gcd(j+1, k+1));
            }
        }
    }

    cout << ans << endl;

    return 0;
} 


Measured memory_bytes: 3616
using System;
using System.Linq;

namespace Atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToArray();
            var a = input[0];
            var b = input[1];
            var c = input[2];
            var d = input[3];
            
            var turn1 =  Math.Ceiling(a / d);
            var turn2 =  Math.Ceiling(c / b);
            if(turn2 <= turn1) {Console.WriteLine("Yes");}
            else {Console.WriteLine("No");}
        }
    }
}


Measured memory_bytes: 28176
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner i=new Scanner(System.in);
		int a=i.nextInt();
		int b=i.nextInt();
		int c=i.nextInt();
		int ct=0;
		for(int s=a;s<=b;s++){
			if(c%s==0)ct++;
		}
		System.out.println(ct);
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, k, h[100000];

int main(int argc, char **argv) {
	cin >> n >> k;
	REP(i, n) cin >> h[i];
	sort(h, h+n);
	ll res = INF;
	REP(i, n-k+1) res = min(res, h[i+k-1] - h[i]);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4340
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}


int n;
int board[20][20];
int dp[1 << 16];

signed main() {
    while(cin >> n, n) {
        rep(i,0,n) rep(j,0,n+1) cin >> board[i][j];
        rep(i,0,1<<n) dp[i] = INF;
        dp[0] = 0;
        rep(bit,0,1<<n) {
            rep(i,0,n) {
                if(bit >> i & 1) continue;
                int nbit = bit | (1 << i);
                dp[nbit] = min(dp[nbit], dp[bit] + board[i][0]);
                rep(j,0,n) {
                    if(!(bit >> j & 1)) continue;
                    dp[nbit] = min(dp[nbit], dp[bit] + board[i][j+1]);
                }
            }
        }
        cout << dp[(1<<n) - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, X;
  cin >> N >> X;
  int x;
  int max_d;
  cin >> x;
  max_d = abs(X - x);
  for (int i = 0; i < N-1; i++) {
    cin >> x;
    max_d = __gcd(abs(X - x), max_d);
  }
  cout << max_d << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  string a, b;
  cin >> a >> b;
  string bi = b.substr(0, b.size() - 3);
  string bn = b.substr(b.size()-2, 2);
  ll ans = stoll(a) * stoll(bi);
  ans += stoll(a) * stoll(bn) / 100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
n,k = map(int,input().split())
mod = 1000000007
def comb(n,k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n]*finv[k]%mod*finv[n-k]%mod
fac = [1]*(n+1)
finv = [1]*(n+1)
for i in range(1,n+1):
    fac[i] = fac[i-1]*i%mod
    finv[i] = pow(fac[i],mod-2,mod)

ans = 0
for i in range(min(k+1,n)):
    ans += comb(n,i)*comb(n-1,i)%mod
    ans %= mod
print(ans)

Measured memory_bytes: 24624
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>
#include <queue>
#include <functional>

using namespace std;
typedef long long int ll;
//考察が詰めきれず難しかった.
//クソコードにより添字地獄が発生して無限バグらせ死亡
int main(){

    ll N = 0;
    cin >> N;
    vector<ll > v(N, 0);
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        cin >> v[i];
        if(i == 0) continue;
        if(v[i] == v[i-1]){
            v[i] = 10000;
            ans++;
        }
    }

    cout << ans << endl;

} 

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

int main() {
	int n, m;
	cin >> n >> m;
	string maps[50];
	REP(i, n) cin >> maps[i];
	
	int ans = INF;
	FOR(w, 1, n + 1) FOR(b, 1, n - w + 1) FOR(r, 1, n - w - b + 1) {
		int cnt = 0;
		FOR(i, 0, w) cnt += m - count(maps[i].c_str(), maps[i].c_str() + maps[i].size(), 'W');
		FOR(i, w, w + b) cnt += m - count(maps[i].c_str(), maps[i].c_str() + maps[i].size(), 'B');
		FOR(i, w + b, n) cnt += m - count(maps[i].c_str(), maps[i].c_str() + maps[i].size(), 'R');
		
		ans = min(ans, cnt);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3176
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}


// min
int main(void){
  char s[7];

  scanf("%s", s);

  if(s[0] == 'S'){
    printf("Cloudy\n");
  }else if(s[0] == 'C'){
    printf("Rainy\n");
  }else if(s[0] == 'R'){
    printf("Sunny\n");
  }

  return 0;
}


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

int main() {
int A,B;
char op;
cin >> A>>op>>B;

int sum=0;
if(op=='+'){
sum=A+=B;
}
else if(op=='-'){
sum=A-=B;
}
cout << sum << endl;
}

//1 + 2
//5 - 7

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
#include <utility>
#include <functional>
using namespace std;

#define INF 19980725

/** 割引券の枚数 */
static int c;
#define C 10
/** 町の数 */
static int n;
#define N 100
/** 路線数 */
static int m;
#define M 500
/** 出発地 */
static int s;
/** 目的地 */
static int d;

/** 路線情報 */
static int map[ N ][ N ];

/** 各探索先における状態 */
struct stat
{
  /** 到達先の町 */
  int pos;
  /** 現時点までの費用 */
  int cost;
  /** 割引券の残枚数 */
  int rem;

  stat (
    )
  {
    this->cost = INF;
    this->rem  = 0;
  }
  stat (
    int pos,
    int cost,
    int rem
    )
  {
    this->pos  = pos;
    this->cost = cost;
    this->rem  = rem;
  }
  bool operator> (
    const stat &a
    )
  const
  {
    return ( cost > a.cost
          || ( cost == a.cost && rem < a.rem ) );
  }
};

int
main (
  int   argc,
  char *argv[ ]
  )
{
  for ( ; ; )
  {
    priority_queue<stat, vector<stat>, greater<stat> > lis;
    int stats[ C + 1 ][ N ];
    int res;
    int i, j;

    /* 基本情報読み込み */
    scanf ( "%d%d%d%d%d", &c, &n, &m, &s, &d );
    if ( !( c | n | m | s | d ) ) break ;
    --s; --d;

    /* 路線情報初期化 */
    for ( i = 0; i < n; ++i )
    for ( j = 0; j < n; ++j )
      map[ i ][ j ] = INF;

    /* 路線情報読み込み */
    for ( i = 0; i < m; ++i )
    {
      int a, b, f;

      scanf ( "%d%d%d", &a, &b, &f );
      --a; --b;
      map[ a ][ b ] =
      map[ b ][ a ] = f;
    }

    /* s->d に対してダイクストラ法を適用 */
    for ( i = 0; i <= c; ++i )
    for ( j = 0; j < n; ++j )
      stats[ i ][ j ] = INF;
    lis.push ( stat ( s, 0, c ) );
    while ( !lis.empty ( ) )
    {
      const stat st = lis.top ( );
      lis.pop ( );

      /* 既に探索済みであれば処理しない */
      if ( stats[ st.rem ][ st.pos ] != INF )
        continue ;
      stats[ st.rem ][ st.pos ] = st.cost;

      for ( i = 0; i < n; ++i )
      {
        /* st.pos からi への経路が存在しなければ処理しない */
        if ( map[ st.pos ][ i ] == INF )
          continue ;

        /* 隣接する町の探索を予約する．割引券が使えればその探索も予約する． */
        lis.push ( stat ( i, st.cost + map[ st.pos ][ i ], st.rem ) );
        if ( st.rem > 0 )
          lis.push ( stat ( i, st.cost + map[ st.pos ][ i ] / 2, st.rem - 1 ) );
      }
    }

    /* s->d への最小費用を算出 */
    res = INF;
    for ( i = 0; i <= c; ++i )
      res = min ( res, stats[ i ][ d ] );
    printf ( "%d\n", res );
  }

  return ( EXIT_SUCCESS );
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, k;
  while (cin >> n >> k) {
    vector<lli> x(n);
    each (i, x) cin >> i;

    lli mn = 1LL << 60;
    for (int i = 0; i + k - 1 < x.size(); ++i) {
      const lli a = x[i];
      const lli b = x[i + k - 1];
      if (a <= 0 && 0 <= b) {
        // a<---0
        // a--------->b
        mn = min(mn, abs(a) + abs(a) + abs(b));
        //     0-->b
        //a<-------b
        mn = min(mn, abs(b) + abs(b) + abs(a));
      } else {
        if (0 <= a) {
          // 0-->a--->b
          mn = min(mn, abs(b));
        }
        if (b <= 0) {
          // a<---b<---0
          mn = min(mn, abs(a));
        }
      }
    }
    cout << mn << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace::std;

int main()
{
    long long A, B, N, i;
    cin >> A >> B >> N;
    if(N < B){
        cout << A*N/B - A*(N/B);
    }else if(A >= B){
        if(N%B == 0)
            cout << A*(N-1)/B - A*((N-1)/B);
        else
            cout << A*N/B - A*(N/B);
    }else{
        i = N/B*B - 1;
        cout << A*i/B - A*(i/B);
    }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>//coded by Nurstan ^_^

#define ll long long
#define pb push_back

#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define all(x) x.begin(), x.end()
#define F first
#define S second

// fixed << setprecision
// next_permutation(a, a + n)
// set <int> :: iterator it = x.begin(); it != x.end(); it ++

using namespace std;

inline void boost(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main(){
	boost();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	char a[n][m];
	for(int i = 0; i < n; i ++) {
		for(int j = 0; j < m; j ++) {
			cin >> a[i][j];
		}
	}
	if(a[0][0] != '#') {
		cout << "Impossible";
		return 0;
	}
	for(int i = 0; i < n; i ++) {
		for(int j = 0; j < m; j ++) {
			if(a[i][j] == '#') {
				if(j + 1 < m && i + 1 < n && a[i + 1][j] == '#' && a[i][j + 1] == '#') {
					cout << "Impossible";
					exit(0);
				}
				bool t = 0;
				if(j - 1 >= 0 && a[i][j - 1] == '#') {
					t = 1;
				}
				if(i - 1 >= 0 && a[i - 1][j] == '#') {
					t = 1;
				}
				if(t == 0) {
					if(i != 0 || j != 0) {
						cout << "Impossible";
						return 0;
					}
				}
			}
		}
	}
	cout << "Possible";
	exit(0);
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private String diceEyes1;
	private String diceEyes2;
	private String diceEyes3;
	private String diceEyes4;
	private String diceEyes5;
	private String diceEyes6;

	// ダイスのゲッター
	String getDiceEyes1() {
		return diceEyes1;
	}

	String getDiceEyes2() {
		return diceEyes2;
	}

	String getDiceEyes3() {
		return diceEyes3;
	}

	String getDiceEyes4() {
		return diceEyes4;
	}

	String getDiceEyes5() {
		return diceEyes5;
	}

	String getDiceEyes6() {
		return diceEyes6;
	}

	// ダイスのセッターメソッド
	void setDiceEyes1(String diceEyes1) {
		this.diceEyes1 = diceEyes1;
	}

	void setDiceEyes2(String diceEyes2) {
		this.diceEyes2 = diceEyes2;
	}

	void setDiceEyes3(String diceEyes3) {
		this.diceEyes3 = diceEyes3;
	}

	void setDiceEyes4(String diceEyes4) {
		this.diceEyes4 = diceEyes4;
	}

	void setDiceEyes5(String diceEyes5) {
		this.diceEyes5 = diceEyes5;
	}

	void setDiceEyes6(String diceEyes6) {
		this.diceEyes6 = diceEyes6;
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		// インスタンスの作成
		Main dice = new Main(scan.next(), scan.next(), scan.next(), scan.next(), scan.next(), scan.next());
		// サイコロを振り、上に来る目を変えるメソッド
		dice.diceRoll(scan.next());
		System.out.println(dice.getDiceEyes1());
		scan.close();
	}

	// ダイスのコンストラクタ
	Main(String one, String two, String three, String four, String five, String six) {
		getNumber(one, two, three, four, five, six);
	}

	// ダイスの目に数字を振り分けるメソッド
	void getNumber(String one, String two, String three, String four, String five, String six) {
		setDiceEyes1(one);
		setDiceEyes2(two);
		setDiceEyes3(three);
		setDiceEyes4(four);
		setDiceEyes5(five);
		setDiceEyes6(six);
	}

	// ダイスを振ったときに上に来る目を変えるメソッド
	void diceRoll(String direction) {
		for (int i = 0; i < direction.length(); i++) {
			String letterDirection = String.valueOf(direction.charAt(i));

			// サイコロが東側に転がったとき
			if (letterDirection.equals("E")) {
				String change = diceEyes1;
				diceEyes1 = diceEyes4;
				diceEyes4 = diceEyes6;
				diceEyes6 = diceEyes3;
				diceEyes3 = change;
				// サイコロが南側に転がったとき
			} else if (letterDirection.equals("S")) {
				String change = diceEyes1;
				diceEyes1 = diceEyes5;
				diceEyes5 = diceEyes6;
				diceEyes6 = diceEyes2;
				diceEyes2 = change;
				// ダイスが西側に転がったとき
			} else if (letterDirection.equals("W")) {
				String change = diceEyes1;
				diceEyes1 = diceEyes3;
				diceEyes3 = diceEyes6;
				diceEyes6 = diceEyes4;
				diceEyes4 = change;
				// ダイスが北側に転がったとき
			} else if (letterDirection.equals("N")) {
				String change = diceEyes1;
				diceEyes1 = diceEyes2;
				diceEyes2 = diceEyes6;
				diceEyes6 = diceEyes5;
				diceEyes5 = change;
			}

		}

	}

}



Measured memory_bytes: 26296
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(int, N);
    bool mat[105][105]{};
    rep(i, 0, N) mat[i][i] = true;

    {
        int v = N - 1 - (N & 1);
        rep(u, 0, N) {
            if (v < 0) break;
            mat[u][v] = mat[v][u] = true;
            --v;
        }
    }

    print((N * N - N - (N - (N & 1))) / 2);
    rep(i, 0, N) rep(j, i + 1, N) {
        if (!mat[i][j]) print(i + 1, j + 1);
    }

    return 0;
}


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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;

void solve1()
{
	int n, m, k = 0;
	cin >> n >> m;
	for(int i = 1; i < n; i++)
		k += i;
	for(int i = 1; i < m; i++)
		k += i;
	cout << k;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 256
<?php
$nl=(int)trim(fgets(STDIN));
$prtw=explode(' ',trim(fgets(STDIN)));
$intw=explode(' ',trim(fgets(STDIN)));
 
$pstw=array();
for($i=0;$i<$nl;$i++){$pstw[]=0;}
 
function to_pstw($pri,$ini,$psi,$nl){
    global $prtw,$intw,$pstw;
 
    $a=$prtw[$pri];
    $pstw[$psi+$nl-1]=$a;
 
    if($nl<=1){return;}
 
    $i=0;
    while($intw[$ini+$i]!=$a){++$i;}
 
    if($i>0){to_pstw($pri+1,$ini,$psi,$i);}
    if($nl-$i-1>0){to_pstw($pri+$i+1,$ini+$i+1,$psi+$i,$nl-$i-1);}
}
 
to_pstw(0,0,0,$nl);
printf($pstw[0]);
for($i=1;$i<$nl;$i++){printf(" %d",$pstw[$i]);}
?>

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

using namespace std;

long long  gcd( long long  a ,long long   b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}
long long findGCD(vector<long long >v)
{
    long long result = v.front();
    for (long long  i = 1; i < v.size(); i++)
        result = gcd(v[i], result);

    return result;
}

int main()
{
    long long n;
    cin>>n;
    vector<long long>v(n);
    for(long long i=0;i<n;i++)
    {
        cin>>v[i];
    }
    cout<<findGCD(v)<<endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

vector<int>G[100010];
int deg[100010];
vector<int>chi[100010];
bool used[100010];
int par[100010];
void No() {
	print("First"); exit(0);
}
void make(int n, int pre) {
	for (auto nxt : G[n]) {
		if (nxt == pre)continue;
		chi[n].push_back(nxt);
		par[nxt] = n;
		make(nxt, n);
	}
}
void solve() {
	int N; cin >> N;
	REP(i, N - 1) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		G[v].push_back(u);
		deg[u]++;
		deg[v]++;
	}
	make(0,0);
	vector<int>use;
	REP(i, N) {
		if (deg[i] == 1&&i!=0)use.push_back(i);
	}
	int cnt = 0;
	while (use.size() > 0) {
		vector<int>n_use;
		REP(i, use.size()) {
			int n = use[i];
			//DEBUG(n);
			if (used[n])continue;
			if (par[n] == n)No();
			if (used[par[n]])No();
			used[n] = used[par[n]] = true;
			cnt += 2;
			deg[par[par[n]]]--;
			if (deg[par[par[n]]] == 1)n_use.push_back(par[par[n]]);
		}
		use.clear();
		for (auto n : n_use)use.push_back(n);
	}
	if (cnt != N)No();
	print("Second");
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




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

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    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++){
            for(int k=j+1; k<n; k++){
                if(a[i]==a[j]||a[j]==a[k]||a[k]==a[i]) continue;
                if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[k]+a[j]>a[i]){
                    ans++;
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3648
N,x=map(int,input().split())
a=list(map(int,input().split()))

a.sort()
cnt=0
for i in range(N):
    if i==N-1:
        if x==a[i]:
            cnt+=1
    elif x>=a[i]:
        x=x-a[i]
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,blue=0,cnt=0,ans;
	cin>>a>>b>>c;
	ans=a/(b+c)*b;
	if (a%(b+c)>b)
		ans+=b;
	else
		ans+=a%(b+c);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int H, W;
    std::cin >> H >> W;


    boost::multi_array<bool, 2> mat(boost::extents[H][W]);
    for (auto p = mat.data(); p < (mat.origin() + mat.num_elements()); ++p) {
        char c;
        std::cin >> c;
        *p = (c == '#');
    }

    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
            if (!mat[h][w]) {
                continue;
            }
            constexpr std::pair<int, int> dir[] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
            bool ok = false;
            for (auto d: dir) {
                const int xx = w + d.first;
                const int yy = h + d.second;
                if (0 <= xx && xx < W && 0 <= yy && yy < H) {
                    if (mat[yy][xx]) {
                        ok = true;
                        break;
                    }
                }
            }
            if (!ok) {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "Yes" << std::endl;


    return 0;
}


Measured memory_bytes: 256
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
MOD = 10**9 + 7
YES, NO, IMP = "YES", "NO", "IMPOSSIBLE"
from collections import defaultdict as ddic

def solve(N,A):

    for i in xrange(N-2):
        for j in xrange(3):
            if A[i+j][0] != A[i+j][1]:
                break
        else:
            return 'Yes'
    return 'No'
N= rri()
A = rrmm(N)
print solve(N, A)


Measured memory_bytes: 65380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        // TODO ?????????????????????????????????????????????
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String tmpStr = br.readLine();
            if(tmpStr == null){
                break;
            }

            String[] tmpArray = tmpStr.split(" ");

            int num1 = Integer.parseInt(tmpArray[0]);
            int num2 = Integer.parseInt(tmpArray[1]);

            int sum = num1 + num2;

            System.out.println(Integer.toString(num1 + num2).length());
        }


    }

}

Measured memory_bytes: 24132
n,m,p,wa[100001],w,a;
char s,ac[100001];
main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%*c%c%*c%*c",&p,&s);
//		putchar(s);
		switch(s+ac[p]){
			case 'A':
			  ac[p]=1;
				break;
			case 'W':
			  wa[p]++;
				break;
		}
	}
	for(int i=1;i<=n;i++){
		if(ac[i]){
			a++;
			w+=wa[i];
		}
	}
	printf("%d %d\n",a,w);
}

Measured memory_bytes: 640
N,A,B = map(str, input().split())

ans = 0

for i in range(int(N)+1):
    sum = 0
    for j in range(len(str(i))):
        num = str(i)
        sum += int((num[j]))
    if int(A) <= sum and sum <= int(B):
        ans += i

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef vector <vector <ll>> vvl;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;
void read() {
  cin >> n;
}
void solve() {
  int sn = 0;
  int x = n;
  while(x) {
    sn += x % 10;
    x /= 10;
  }
  cout << (n % sn == 0 ? "Yes" : "No") << "\n";
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve(); 
  }
  return 0;
}


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

int main(){
  multiset<string> words;
  string wmuch,wlong,w;
  int msize = 0,mcount=0;
  while(cin>>w){
    words.insert(w);
    if (mcount<words.count(w)){
      mcount = words.count(w);
      wmuch = w;
    }
    if (msize<w.size()){
      msize = w.size();
      wlong = w;
    }
  }
  cout << wmuch << " " << wlong << endl;
  return 0;
}

Measured memory_bytes: 0
def inpl(): return list(map(int, input().split()))


def num(i, j):
    if i == 0:
        return 0
    
    

N = int(input())

ans = [N] * (N+1)
ans[0] = 0
ans[1] = 1
for i in range(2, N+1):
    ans[i] = min(ans[i], ans[i-1]+1)
    for num in [6, 9]:
        tmp = num
        while i - tmp >= 0:
            ans[i] = min(ans[i], ans[i-tmp] + 1, ans[i-1]+1)
            tmp *= num
print(ans[-1])

Measured memory_bytes: 3828
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{

    public static class store implements Comparable<store> {

        long A, B;

        public store(long a, long b) {
            A = a;
            B = b;
        }

        public int compareTo(store o) {
            if (this.A > o.A) {
                return 1;
            } else if (this.A < o.A) {
                return -1;
            } else {
                return 0;
            }
        }
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        long N = Long.parseLong(st.nextToken());
        long  M = Long.parseLong(st.nextToken());
        store[] stores = new store[(int)N];
        for (int i=0; i<N; i++) {
            st = new StringTokenizer(br.readLine());
            stores[i] = new store(Long.parseLong(st.nextToken()), Long.parseLong(st.nextToken()));
        }
        Arrays.sort(stores);
        long drinks = 0;
        long money = 0;
        for (int i=0; i<N; i++) {
            for (int j=0; j<stores[i].B; j++) {
                drinks++;
                money+=stores[i].A;
                if (drinks==M) {
                    System.out.println(money);
                    return;
                }
            }
        }
    }
}




















Measured memory_bytes: 45936
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(a < b && b<c ){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26304
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
ll d[250025];
ll dd[505];
 
int main() {
  ll n;
  cin >> n;
  vector<pair<ll,ll> > v;
  rep(i, 0, n) {
    ll a;
    cin >> a;
    a--;
    v.pb(mp(a,i));
  }
  sort(all(v));
  clr(dd, 0);
  rep(i, 0, n) {
    dd[i] = n - 1;
  }
  clr(d, 0);
  rep(i, 0, v.sz) {
    ll p = v[i].fi;
    d[p] = v[i].se+1;
  }
  rep(i, 0, v.sz) {
    ll p = v[i].fi;
    ll c = v[i].se;
    rep(j, 0, p) {
      if (c == 0)break;
      if (d[j] == 0) {
        d[j] = v[i].se + 1;
        dd[i]--;
        c--;
      }
    }
    if (c != 0) {
      cout << "No" << endl;
      return 0;
    }
    ll p1 = v[v.sz-1-i].fi;
    ll c1 = n-v[v.sz-1-i].se-1;
    per(j, p1 + 1, n * n) {
      if (c1 == 0)break;
      if (d[j] == 0) {
        d[j] = v[v.sz-1-i].se+1;
        dd[i]--;
        c1--;
      }
    }
    if (c1 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  rep(i, 0, n * n) {
    cout << d[i];
    if (i != n * n - 1)cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3200
# ABC 158 D
from collections import deque

S=list(input())
q=deque(S)
Q=int(input())
inv=0
for _ in [0]*Q:
    s=input()
    if s=='1':
        inv+=1
    else:
        t,f,c=s.split()
        if ((f=='1') ^ (inv%2==1)):
            q.appendleft(c)
        else:
            q.append(c)
S=[]
if inv%2:
    while q:
        S.append(q.pop())
else:
    while q:
        S.append(q.popleft())
    
print(*S,sep='')

Measured memory_bytes: 128256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double EPS = 1e9 + 7;
const double PI = acos(-1);
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in(){int x;std::cin>>x;return x;}

using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int> >;
using vl = vector<long long>;
using vp = vector<pint>;

template <typename T> void print(T x) { std::cout << x << '\n'; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T*)array, (T*)(array + N), val);
}
signed main(){
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;

  vector<pair<int,string> > len;
  int i=0;
  while(i<N){
    int count=0;
    pair<int,string>p;
    if(S[i] =='0'){
      while(S[i] == '0' ){count++;i++;}
      p.fst = count;
      p.sec = '0';     
    }else if(S[i] =='1'){
      while(S[i] == '1' ){count++;i++;}
        p.fst = count;
        p.sec = '1';     
    }
    
    len.pb(p);
    
  }
  
  // rep(i,len.size())print(len[i].fst);
  // print(" ");
  
  int ans = 0;
  
  int sum =0;
  if( len.size() <= K  )ans=N;
  else{
    int zerocount = 0;
    int right =0;
    rep(left,len.size()){      
      //zerocount += len[left].sec =="0"?1:0;
      
      while(right<len.size() && zerocount <=K ){
        if(zerocount == K && len[right].sec == "0" )break;
        sum += len[right].fst;  
        if(len[right].sec == "0")zerocount++;
        right++;
        
      }
      ans = max(ans,sum);
      // print(ans);
      // cout<<sum<<endl;;
      if(right == left)right++;
      else{
        sum -= len[left].fst;
        if(len[left].sec == "0")zerocount--;
      }
    }
  }
  // print(" ");
  print(ans);
  return 0;
}


Measured memory_bytes: 6720
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

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

    int count = 0;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        std::cin >> a >> b;
        if (a == b)
        {
            count++;
        }
        else
        {
            count = 0;
        }
        if (count == 3)
        {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    
    std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 3620
A,B = map(str, input().split())


# Ar = int(A[::-1])
A = int(A)
B = int(B)

# print(Ar)
# print(A)
# print(B)

count = 0
while A <= B:
  As = str(A)
  Ar = int(As[::-1])

  if A == Ar:
    # print("Yes")
    count+=1
  A +=1

print(count)

Measured memory_bytes: 3060
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())

a.sort()

pre = 0
ans = 0
for i in range(n):
    count = 0
    if a[i] != pre:
        for j in range(i,n):
            if a[j] == a[i]:
                count += 1
            else:
                break
        if count % 2 == 0:
            pass
        else:
            ans += 1
        pre = a[i]
print(ans)


Measured memory_bytes: 7472
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#define re register
#define ll long long
using namespace std;
ll n,a[3005],s;
int main()
{
	cin>>n;
	for(re int i=1;i<=n;i++){
		cin>>a[i];
		s+=a[i];
	}
	s-=n;
	cout<<s<<endl;
}

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

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

  map<string, int> n_cards;

  string n_name[N];
  for (int i = 0; i < N; i++) {
    cin >> n_name[i];
    n_cards[n_name[i]] += 1;
  }

  int M;
  cin >> M;

  map<string, int> m_cards;

  string m_name[M];
  for (int i = 0; i < M; i++) {
    cin >> m_name[i];
    m_cards[m_name[i]] += 1;
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int tmp = n_cards[n_name[i]] - m_cards[n_name[i]];
    if (ans < tmp) {
      ans = tmp;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H, W, a[55], b[55], c[55]; string s[55];
int main() {
	cin >> H >> W;
	for(int i = 0; i < H; i++) cin >> s[i];
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			if(s[i][j] == 'W') a[i]++;
			if(s[i][j] == 'B') b[i]++;
			if(s[i][j] == 'R') c[i]++;
		}
	}
	int ret = H * W;
	for(int i = 1; i < H; i++) {
		for(int j = i + 1; j < H; j++) {
			int sum = 0;
			for(int k = 0; k < i; k++) sum += a[k];
			for(int k = i; k < j; k++) sum += b[k];
			for(int k = j; k < H; k++) sum += c[k];
			ret = min(ret, H * W - sum);
		}
	}
	cout << ret << endl;
	return 0;
}

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

const int P=1e9+7;

int main(){
  int N,M;
  cin >> N >> M;
  set<int> A;
  for(int i=0;i<M;i++){
    int a;
    cin >> a;
    A.insert(a);
  }
  vector<int> dp(100005,0);
  dp[0]=1;
  for(int i=0;i<=N;i++){
    if(!A.count(i)){
      dp[i+1]=(dp[i+1]+dp[i])%P;
      dp[i+2]=(dp[i+2]+dp[i])%P;
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 8220
n, m, Q = map(int, input().split())
data = [[0]*(n+2) for i in range(n+2)]
for i in range(m):
    l, r = map(int, input().split())
    data[l][r] += 1

for i in range(n+2):
    for j in range(n+1):
        data[i][j+1] += data[i][j]

for i in range(n+1, -1, -1):
    for j in range(n+2):
        data[i-1][j] += data[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    print(data[p][q])


Measured memory_bytes: 57432
#include <stdio.h>

int main(void){
    int N, X;
    scanf("%d %d", &N, &X);
    int m[N];
    int sum = 0;
    int min = 1000;
    for(int i = 0; i < N; i++){
        scanf("%d", &m[i]);
        sum += m[i];
        if(min > m[i]) min = m[i];
    }
    
    int ans = N + (X - sum) / min;
    printf("%d\n", ans);
    
    return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define llint long long int
#define ldouble long double

//setprecision()<<

using namespace std;

int main() {
    int N=100000;
    cin>>N;
    vector<long> A(N),B(N),C(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    for(int i=0;i<N;i++){
        cin>>B.at(i);
    }
    for(int i=0;i<N;i++){
        cin>>C.at(i);
    }

    llint sum=0;
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    
    for(int i=0;i<N;i++){
        auto itrA=lower_bound(A.begin(),A.end(),B.at(i));
        auto itrB=upper_bound(C.begin(),C.end(),B.at(i));
        //cout<<*itrA<<*itrB<<endl;
        //cout<<(itrA-A.begin())<<(C.end()-itrB)<<endl;
        sum+=(itrA-A.begin())*(C.end()-itrB);
    }
    cout<<sum<<endl;

return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int calc(int a, int b, char op)
{
	if(op == '+')
		a = a + b;
	if(op == '-')
		a = a - b;
	if(op == '*')
		a = a * b;
	if(op == '/')
		a = a / b;

	return (a);
}


int main(void)
{
	int a, b;		//Value a, b.
	char op;		//Value op. one character. [+ - * / ?]. ? is end.

	while(1)
	{
		scanf("%d %c %d", &a, &op, &b);
		if(op == '?')
			return (0);
		printf("%d\n", calc(a, b, op));
	}

	return (0);
}



Measured memory_bytes: 2144
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define M_PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int cnt[100000][26] = { 0 };

int main()
{
	string s;
	int l = -2, r = -2;

	cin >> s;
	rep(i, s.length() - 2) {
		if (s[i] == s[i + 1] ||
			s[i + 1] == s[i + 2] ||
			s[i + 2] == s[i]) {
			l = i;
			r = i + 2;
			break;
		}
	}
	if (s.length() == 2 && s[0] == s[1]) {
		l = 0;
		r = 1;
	}

	cout << l + 1 << ' ' << r + 1 << endl;

	return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-


from sys import stdin

import time
import numpy as np

############################################

# read data for n sequences.
temp = stdin.readline().split()
A = int(temp[0])
B = int(temp[1])
C = int(temp[2])
D = int(temp[3])

while True:
    C -= B
    if C<=0:
        print("Yes")
        break
    A -= D
    if A<=0:
        print("No")
        break

Measured memory_bytes: 26972
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int W,H,N;
    cin >> W >> H >> N;
    int x,y,a;
    int minx=0,maxx=W,miny=0,maxy=H;
    for (int i=0;i<N;i++){
        cin >> x >> y >> a;
        switch(a) {
            case 1:
                minx = max(minx,x);
                break;
            case 2:
                maxx = min(maxx,x);
                break;
            case 3:
                miny = max(miny,y);
                break;
            case 4:
                maxy = min(maxy,y);
                break;
            default:
                break;
        }
    }
    int width = max(0,maxx-minx);
    int hight = max(0,maxy-miny);
    cout << width*hight << endl;

    return 0;


}


Measured memory_bytes: 256