akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()

int main(){
    int a, b;
    cin >> a >> b;

    if(a<9 && b<9){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
using namespace std;
int main() {
	string in[9];
	int x = 0, y = 0, d = 0;
	//d..direction  0→、1↓、2←、3↑
	for (int i = 0; i < 9; i++)
		cin >> in[i];
	do {
		if (d == 0) {
			if (y > 0) {
				if (in[2 * y - 1][x] == '1') {
					cout << "U";
					d = 3;
					y--;
					continue;
				}
			}
			if (x < in[0].size()) {
				if (in[2 * y][x] == '1') {
					cout << "R";
					x++;
					continue;
				}
			}
			if (y < 4) {
				if (in[2 * y + 1][x] == '1') {
					cout << "D";
					d = 1;
					y++;
					continue;
				}
			}
			cout << "L";
			x--;
			d = 2;
			continue;
		}
		if (d == 1) {
			if (x < in[0].size()) {
				if (in[2 * y][x] == '1') {
					cout << "R";
					d = 0;
					x++;
					continue;
				}
			}
			if (y < 4) {
				if (in[2 * y + 1][x] == '1') {
					cout << "D";
					y++;
					continue;
				}
			}
			if (x > 0) {
				if (in[2 * y][x - 1] == '1') {
					cout << "L";
					d = 2;
					x--;
					continue;
				}
			}
			cout << "U";
			d = 3;
			y--;
			continue;
		}
		if (d == 2) {
			if (y < 4) {
				if (in[2 * y + 1][x] == '1') {
					cout << "D";
					d = 1;
					y++;
					continue;
				}
			}
			if (x > 0) {
				if (in[2 * y][x - 1] == '1') {
					cout << "L";
					x--;
					continue;
				}
			}
			if (y > 0) {
				if (in[2 * y - 1][x] == '1') {
					cout << "U";
					d = 3;
					y--;
					continue;
				}
			}
			cout << "R";
			d = 0;
			x++;
			continue;
		}
		if (d == 3) {
			if (x > 0) {
				if (in[2 * y][x - 1] == '1') {
					cout << "L";
					d = 2;
					x--;
					continue;
				}
			}
			if (y > 0) {
				if (in[2 * y - 1][x] == '1') {
					cout << "U";
					y--;
					continue;
				}
			}
			if (x < in[0].size()) {
				if (in[2 * y][x] == '1') {
					cout << "R";
					d = 0;
					x++;
					continue;
				}
			}
			cout << "D";
			d = 1;
			y++;
			continue;
		}
	}while (x != 0 || y != 0);
	cout << endl;
	return 0;
}


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

using namespace std;

#ifdef ACMTUYO
struct RTC{~RTC(){cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC <<" seconds\n";}} runtimecount;
#define DBG(X) cerr << #X << " = " << X << '\n';
#else
struct RTC{};
#define DBG(X)
#endif

#define fast_io() ios_base::sync_with_stdio(false)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(c) (c).begin(),(c).end()
#define forn(i, n) for (int i = 0; i < (n); i++)
typedef long long int number;

int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  if (abs(a - c) <= d or (abs(b-a) <= d and abs(c-b) <= d)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
    int key;
    struct Node *next;
    struct Node *prev;
};

typedef struct Node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
    NodePointer cur = nil->next; // 番兵の次の要素から辿る
    while(cur->key != key && cur != nil){
        cur = cur->next;
        
    }
    return cur;
}

void init(){
    nil = malloc(sizeof(struct Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    NodePointer cur = nil->next;
    int isf = 0;
    while(1){
        if (cur == nil) break;
        if (isf ++ > 0)printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
       
    }
    printf("\n");
}
void deleteNode(NodePointer t){
    if(t==nil) return; // t が番兵の場合は処理しない
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
void deleteFirst(){
    deleteNode(nil->next);
}
void deleteLast(){
    deleteNode(nil->prev);
}
void deleteKey(int key){
    // 検索したノードを削除
    deleteNode(listSearch(key));
}
void insert(int key){
   NodePointer x = malloc(sizeof(struct Node));
    x->key = key;
    // 番兵の直後に要素を追加
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}
int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d", com, &key);
        if (com[0] == 'i') {
            insert(key);
            np++;
            size++;
            
        }
        else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            } else {
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
    
}






Measured memory_bytes: 33116
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();

		if ( a+b>=c ) {
			System.out.println("No");
			System.exit(0);
		}

		long n = (c-a-b)*(c-a-b);
		long m = a*b*4l;
		if ( m < n ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)



int main() {
	int n, m,cnt=0,ta;
	cin >> n >> m;
	bool flag = false;
	VS s1(n+m+1),s2(m);
	rep(i, n) cin >> s1[i];
	rep(i, m) cin >> s2[i];

	rep(yo, n - m + 1) {
		rep(ta,n - m + 1){
			rep(j, m) {
				rep(k, m) {
					if (s1[j+ta][k+yo] == s2[j][k]) {
						cnt++;
					}
				}
			}
			if (cnt == m * m) flag = true;
			cnt = 0;
		}
	}

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




Measured memory_bytes: 256
s = input()
y = int(s[:4])
m = s[5:7]
if m[0] == "0":
    m = int(m[1])
else:
    m = int(m)
d = int(s[8:])

state = True

if y > 2019:
    state = False
elif y == 2019:
    if m > 4:
        state = False
if state:
    print("Heisei")
else:
    print("TBD")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
using PL = pair<ll , ll> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

struct UnionFind {
    vector<int> d ;
    UnionFind (int n = 0) : d(n, -1) {}
    int find (int x){
        if(d[x] < 0) return x ;
        return find(d[x]) ;
    }
    bool unite (int x, int y){
        x = find(x) ;
        y = find(y) ;
        if(x == y) return false ;
        if(d[x] > d[y]) swap(x, y) ;
        d[x] += d[y] ;
        d[y] = x ;
        return true ;
    }
    int size (int x){
        return -d[find(x)] ;
    }
};


int main(){
    int n ;
    cin >> n ;
    UnionFind uf (n) ;
    vector<P> px ;
    vector<P> py ;
    int ans = 0 ;
    vector<pair<int, P>> vec ; 
    rep(i, n){
        int x ;
        int y ;
        cin >> x >> y ;
        px.push_back(P(x, i)) ;
        py.push_back(P(y, i)) ;
    }
    sort(px.begin(), px.end()) ;
    sort(py.begin(), py.end()) ;
    for(int i = 1; i < n ; i++){
        P px1 = px[i] ;
        P px2 = px[i - 1] ;
        int dx = abs(px1.first - px2.first) ;
        P py1 = py[i] ;
        P py2 = py[i - 1] ;
        int dy = abs(py1.first - py2.first) ;
        P x = P(px1.second, px2.second) ;
        P y = P(py1.second, py2.second) ;
        pair<int, P> pp1 = pair<int, P> (dx, x) ;
        pair<int, P> pp2 = pair<int, P> (dy, y) ;
        vec.push_back(pp1) ;
        vec.push_back(pp2) ;
    }
    sort(vec.begin(), vec.end()) ;
    int k = vec.size() ;
    rep(i, k){
        int m = vec[i].second.first ;
        int q = vec[i].second.second ;
        if(uf.unite(m, q)){
            ans += vec[i].first ;
        }
    }
    cout << ans << endl ;
}

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

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	cint(n);
	cint(m);
	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;


	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N;
string s;
ll state[100100];
int main(){
  cin >> N;
  ll output_num = 0;
  ll left = 0;
  ll right = N;
  rep(i,20){
    if(i>0) output_num = (right + left) / 2;
    cout << output_num << endl;
    cin >> s;
    if(s[0] == 'M'){
      state[output_num] = 1;
    }
    else if(s[0] == 'F'){
      state[output_num] = 2;
    }
    else{
      return 0;
    }
    if(i == 0){
      state[N] = state[output_num];
    }
    else{
      ll now_state = state[output_num];
      ll left_state = state[left];
      ll right_state = state[right];
      if(now_state != left_state && (output_num + left)%2 == 0){
        right = output_num;
      }
      else if(now_state == left_state && (output_num + left)%2 == 1){
        right = output_num;
      }
      else if(now_state != right_state && (output_num + right)%2 == 0){
        left = output_num;
      }
      else if(now_state == right_state && (output_num + right)%2 == 1){
        left = output_num;
      }
    }
  }
}


Measured memory_bytes: 852
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


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

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n; ll cnt[n+9]={0}, b[n+9];
    ll a[n+9] ;

    for(i=1; i<=n; i++){
        cin>>a[i];
        cnt[a[i]]++;
    }

    x = 0;
    for(i=1; i<=n; i++)
    {
        v = (cnt[i]*(cnt[i]-1))/2;
        b[i] = v; x+=v;
       // cout<<b[i]<<" ";
    }

    for(i=1; i<=n; i++)
    {
        v = x; v-=b[a[i]];
        u = cnt[a[i]]; u--;
        u = (u*(u-1))/2;
        v+=u;
        cout<<v<<endl;
    }

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 7296
//file_name:ABC66_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;


    srep(i,1,s.size()){
        if((s.size()-i)%2==1)continue;
        int flag = 0;
        rep(j,(s.size()-i)/2){
            if(s[j]!=s[(s.size()-i)/2+j]){
                flag=1;
                break;
            }
        }
        if(flag==0){
            cout << s.size()-i << endl;
            break;
        }
    }

    return 0;
}



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

using namespace std;

int main(void){
	string s;
	cin >> s;
	int slen = s.size();
	int aleft = 200000;
	int zright= 0;
	for(int i=0;i<slen;i++){
		if(s[i]=='A'){
			aleft = std::min(i,aleft);
		}
		if(s[i]=='Z'){
			zright = std::max(zright,i);
		}
	}
	cout << zright - aleft + 1;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    if( b < 0 ) {
        if( !( (b - a) % 2 ) ) cout << "Negative";
        else cout << "Positive";
    } else if( a < 0 ) {
        cout << "Zero";
    } else if( a == 0 ){
        cout << "Zero";
    } else {
        cout << "Positive";
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


int n;

void solve()
{
    cin >> n;
    if (n>=30) nout("Yes");
    else nout("No");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
S=input()
T=input()
s=[]
t=[]
for i in range(len(S)):
    s.append(S[i])
for i in range(len(T)):
    t.append(T[i])
flg=False
for i in range(len(S)):
    s=[s[-1]]+s[:-1]
    if s==t:
        flg=True
print("Yes" if flg else "No")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;    }
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;    }


//Variables Declaration


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

     int r;
     cin>>r;
     cout<<2*PI*r<<endl;





    return 0;
}


Measured memory_bytes: 3764
N, K = [int(_) for _ in input().split()]
TD = [[int(_) for _ in input().split()] for i in range(N)]
 
# print(TD)
 
xs = sorted(TD, key=lambda x:-x[1])
 
#print(xs)
 
baset = 0
ts = set()
ds = []
 
for t, d in xs[:K]:
    baset += d
    if not t in ts:
        ts.add(t)
    else:
        ds.append(d)
result = baset + len(ts)**2
r = result

for t, d in xs[K:]:
    if not ds:
        break
    if t not in ts:
        r += 2*len(ts) + 1
        r += d - ds.pop()
        ts.add(t)
        result = max(r,result)

print(result)

Measured memory_bytes: 26880
a, b, x = [int(i) for i in input().split()]

ht = x/(a*a)
from math import atan, pi
if ht <= b/2:
    print(90 - (atan((2*a*ht)/(b*b))*180)/pi)
else:
    print((atan((2*(b-ht))/a))*180/pi)


Measured memory_bytes: 2940
while 1:
  l=[list(map(int,input().split())) for i in range(int(input()))]
  if not l:break
  le=len(l)
  for (i,j) in enumerate(l):
    l[i].append(sum(j))
  l.append([sum([l[k][i] for k in range(le)]) for i in range(le+1)])
  [print("".join([str(j).rjust(5) for j in i])) for i in l]


Measured memory_bytes: 5612
import java.io.*;
import java.util.*;

/**
 * Created by fcdkbear on 15.10.16.
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Set<Integer> colors = new HashSet<>();
        for (int i = 0; i < 3; ++i) {
            int color = in.nextInt();
            colors.add(color);
        }
        out.println(colors.size());
        out.close();
    }

    static class Pair {
        private long first;
        private int second;

        public Pair(long first, int second) {
            this.first = first;
            this.second = second;
        }

        public long getFirst() {
            return first;
        }

        public void setFirst(long first) {
            this.first = first;
        }

        public int getSecond() {
            return second;
        }

        public void setSecond(int second) {
            this.second = second;
        }
    }

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

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

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

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

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

    }

}


Measured memory_bytes: 8404
#include<bits/stdc++.h>
#define MM 1000000007
using namespace std;
long long rsk[200002];
int main(void){
	int n,i;
	long long x,sum;
	int box[200001];
	cin >> n;
	rsk[0] = 0;
	for(i = 0; i < n; i++){
		cin >> box[i];
		rsk[i + 1] = rsk[i] + box[i];
	}
	sum = 0;
	for(i = 0; i < n - 1; i++){
		x = (rsk[n] - rsk[i + 1]) % MM;
		sum += x * box[i];
		sum %= MM;
	}
	cout << sum % MM << endl;
	return 0;
}

Measured memory_bytes: 5840
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long

int a, b, c, steps;

bool same() {
	if (a == b && b == c) return true;
	else return false;
}

void solve() {
	if (a < b && c < b) {++a; ++c;}
	else if (b < a && c < a) {++b; ++c;}
	else if (a < c && b < c) {++a; ++b;}
	else if (b == c && a < b) {
		a += 2;
	}
	else if (a == c && b < a) {
		b += 2;
	}
	else if (a == b && c < a) {
		c += 2;
	}
	++steps;
}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	steps = 0;
	cin >> a >> b >> c;
	while(!same()) {
		solve();
	}
	cout << steps;
}

Measured memory_bytes: 3580
#include <stdio.h>

#define mod 1000000007
#define ll long long


ll n,k;
ll ans[100010];


ll quickpow(ll a,ll b){ 
        ll ans = 1;
        while(b != 0){ 
                if(b%2 == 1){ 
                        ans = (ans%mod*a%mod)%mod;
                }   
                b = b/2;
                a = (a%mod*a%mod)%mod;
        }   
        return ans;
}


int main(void){

        scanf("%lld %lld",&n,&k);
        for(ll i=k;i>=1;i--){
                ans[i] = quickpow(k/i,n);

                for(ll j=(ll)2*i;j<=k;j+=i){
                        ans[i] = (ans[i]-ans[j]+mod)%mod;
                }   
        }   

        ll res = 0;
        for(ll i=1;i<=k;i++){
                res = (res+i*ans[i])%mod;
        }   
        printf("%lld\n",res);
return 0;
}



Measured memory_bytes: 2508
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        x: i32,
    }
    println!("{}",
        if a <= x && x-a <= b {"YES"} else {"NO"});
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair

using namespace std;

typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll sol=a*c;
  sol=max(sol,a*d);
  sol=max(sol,b*c);
  sol=max(sol,b*d);
  cout<<sol<<endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
	ll n;
	cin >> n;
	ll ans = 3;
	for(ll i = 0; i < n; i++){
		char c;
		cin >> c;
		if(c == 'Y') ans = 4;
	}
	cout << (ans == 3 ? "Three" : "Four") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll inf=1e18;
const ll maxs = 201;
const ll mod = 1e9+7;

#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define line cout<<endl;
#define fr(i,b) for(ll i=1;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

ll n,W;

void solve()
{
    ll val[n+1],w[n+1];
    ll dp[n+1][W+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>w[i]>>val[i];
        
    }
    memset(dp,0,sizeof dp);
    for(ll i=1;i<=n;i++)
    {
        ll curr_w = w[i];
        ll curr_val = val[i];
        for(ll j=1;j<=W;j++)
        {
            if(j<curr_w)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-curr_w]+curr_val);
        }
    }
    cout<<dp[n][W];
}

int main()
{
    fastio();
     ll t=1;
     // cin>>t;
     while(t--){
        cin>>n>>W;
        solve();          
     }
    return 0;
}



Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long i, j, k, l, a, c=0, b;
    vector<long long > vec;

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

    cout<<c;


    return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    s_sunuke = set()
    d = [-1] * K
    A = [None] * K
    for i in range(1, K + 1):
        d[i-1] = int(input())
        s_sunuke = s_sunuke | set([int(x) for x in input().split()])
    
    print(N - len(s_sunuke))




if __name__ == "__main__":
    main()

Measured memory_bytes: 67800
#include <stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>b){
    a^=b;
    b^=a;
    a^=b;
  }
  while(b-->0)
    printf("%d",a);
  printf("\n");
  return 0;
}

Measured memory_bytes: 1680
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int N, P;
string S;
ll sum[202020], cnt[10101];

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

	cin >> N >> P >> S;
	reverse(all(S));
	ll ans = 0;
	if (P != 5 && P != 2) {
		ll mul = 1;
		for (int i = 0; i < N; i++) {
			sum[i + 1] = (sum[i] + mul * (S[i] - '0')) % P;
			mul *= 10LL;
			mul %= P;
		}
		for (int i = 0; i <= N; i++)cnt[sum[i]]++;
		for (int l = 0; l < N; l++) {
			cnt[sum[l]]--;
			ans += cnt[sum[l]];
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			if ((S[i]-'0') % P == 0)ans += N - i;
		}
	}
	puts(ans);


	return 0;
}

Measured memory_bytes: 2196
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
minus,plus=[],[]
for i in range(n):
    if lis[i]==0:
        k-=1
    elif lis[i]<0:
        minus.append(lis[i]*(-1))
    else:
        plus.append(lis[i])
minus=list(reversed(minus))
if k<=0:
    print(0)
    exit(0)
'''print(minus)
print(plus)'''
'''m=list(accumulate(minus))
p=list(accumulate(plus))'''
m=minus
p=plus
p=[0]+p
m=[0]+m
'''print(m)
print(p)'''
lens=[]

for i in range(k+1):
    im=i
    ip=k-i
    if im<len(m) and ip<len(p):
        dis=min(m[im],p[ip])*2+max(m[im],p[ip])
        lens.append(dis)
print(min(lens))

Measured memory_bytes: 60184
#include<stdio.h>
int main(void)
{
	int a,b,sum;
	scanf("%d %d",&a,&b);
	sum=a+b;
	if(a%3==0){
		printf("Possible\n");
	}
	else if(b%3==0){
		printf("Possible\n");
	}
	else if(sum%3==0){
		printf("Possible\n");
	}
	else{
		printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int make(int w,int p);

vector<string> a(50);

int main(){
  int n;
  scanf ("%d",&n);
  while(n){
    for(int t=0;t<n;t++){
      //scanf ("%s",a[t]);
      cin >> a[t];
    }
    for(int t=n;t<50;t++){
      //scanf ("%s",a[t]);
      a[t]="";
    }
    int end=0;
    int k=0;
    for(k=0;k<n;k++){
      int q=k;
      if(make(q,5)>=0){
        q=1+make(q,5);
        if(make(q,7)>=0){
          q=1+make(q,7);
          if(make(q,5)>=0){
            q=1+make(q,5);
            if(make(q,7)>=0){
              q=1+make(q,7);
              if(make(q,7)>=0){
                end=1;
                //printf("qwqw\n");
              }
            }
          }
        }
      }
      if(end==1) break;
    }
    k++;
    printf("%d\n",k);
    scanf ("%d",&n);
  }
}


int make(int w,int p){
  int l=a[w].size();
  if(l==p){
    return w;
  }
  else{
    if(l<p){
      //printf("%d\n",r);
      return make(w+1,p-l);
    }
    else{
      return -1;
    }
  }
}



Measured memory_bytes: 3308
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
int ans=0;
int a[55],b[55],c[55];
rep(i,1,n)cin>>a[i];
rep(i,1,n)cin>>b[i],ans+=b[i];
rep(i,1,n-1)cin>>c[i];

rep(i,2,n)if(a[i]==1+a[i-1])ans+=c[a[i]-1];

ol(ans);
return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

vector<int> queries;
ll temp[N<<2],st[N<<2];
int upd[N<<2];
void build(int id,int l,int r) {
  if(r-l==1) {
    st[id] = temp[id] = 1;
    return;
  }
  int mid = (l+r)/2;
  build(id<<1,l,mid);
  build(id<<1|1,mid,r);
  temp[id] = st[id] = (st[id<<1] * power(10,r-mid) + st[id<<1|1]) % mod;
}
void apply(int id, int val) {
  st[id] = (temp[id] * queries[val-1]) % mod;
  upd[id] = val;
}
void push(int id) {
  if(upd[id]) {
    apply(id<<1,upd[id]);
    apply(id<<1|1,upd[id]);
    upd[id] = 0;
  }
}
void update(int id,int l,int r,int x,int y,int d) {
  if(r<=x || l>=y) {
    return;
  }
  else if(l>=x && r<=y) {
    upd[id] = (int)queries.size();
    st[id] = (temp[id] * d) % mod;
    return;
  }
  int mid = (l+r)/2;
  push(id);
  update(id<<1,l,mid,x,y,d);
  update(id<<1|1,mid,r,x,y,d);
  st[id] = (st[id<<1] * power(10,r-mid) + st[id<<1|1]) % mod;
}
void solve() {
    int n,q;
    cin>>n>>q;
    build(1,1,n+1);
    int l,r,d;
    while(q--) {
      cin>>l>>r>>d;
      queries.pb(d);
      update(1,1,n+1,l,r+1,d);
      cout<<st[1]<<"\n";
    }
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    // cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        // cout<<"\n";
    }
}


Measured memory_bytes: 14524
import scala.io.StdIn._

object Main extends App {
  val n = readInt
  val sticks = readLine.split(" ").map(_.toInt).sorted

  def binSearch(n: Int, min: Int, max: Int): Int = {
    if (max - min <= 1) min
    else {
      val mid = (min + max) / 2
      if (sticks(mid) < n) binSearch(n, mid, max)
      else binSearch(n, min, mid)
    }
  }

  val result = for {
    i <- 0 until n
    j <- (i + 1) until n
  } yield binSearch(sticks(j) + sticks(i), j, n) - j
  println(result.sum)
}

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

typedef long long ll;
ll arr[2000005] ;
ll MOD = 1e9 + 7;

int big_mod(ll base, ll power, ll mod)
{
  if(power == 0)  return 1;
  else if(power % 2 == 1) {
    ll p1 = base % mod;
    ll p2 = (big_mod(base, power-1, mod) ) % mod;
    return (p1 * p2) % mod;
  }
  else if(power % 2 == 0) {
    ll p1 = (big_mod(base, power/2, mod) ) % mod;
    return (p1 * p1) % mod;
  }
}

struct Point{
  ll L;
  ll R;
  ll hit;
};

//This is a custom Compare function for Priority Queue. Return statements are reversed.
struct customComp_priorityQueue {
  bool operator()(Point const& x, Point const& y) {
    if(x.L != y.L)  return (x.L > y.L);
    else  return  (x.R < y.R);
  }
};

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

  stack<char> st;

  for(int i = 0; i < n; i++){
    if(!st.empty()){
      if(s[i] != st.top())  st.push(s[i]);
    }
    else  st.push(s[i]);
  }
  cout<<st.size()<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;

const int maxn = 9e5+100;
typedef pair<int,int> P;
P ma[maxn];
LL sum[maxn];
int main(void)
{

    int W,H,D;
    cin>>W>>H>>D;
//    cout<<W<<H<<D<<endl;
    int tmp;
    for(int i = 0;i < W; ++i)
    {
        for(int j = 0;j < H; ++j)
        {
            scanf("%d",&tmp);
            ma[tmp] = P(i,j);
        }
    }

    for(int i = 1;i <=D ; ++i)
        sum[i] = 0;
    for(int i = D+1; i <= W*H; ++i)
        sum[i] = sum[i-D] + abs(ma[i].first-ma[i-D].first)+abs(ma[i].second-ma[i-D].second);
    int Q;
    cin>>Q;
    while(Q--)
    {
        int L,R;
        scanf("%d %d",&L,&R);
        printf("%lld\n",sum[R]-sum[L]);
    }
    return 0;
}


Measured memory_bytes: 3840
#include "bits/stdc++.h"
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")

using namespace std;

using ll = long long;
#define all(x) begin(x), end(x)
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100005;

void solve(){
    int n;
    cin>>n;
    vector<ll> vec(MAX, 0);
    ll sm = 0;
    for(int i = 0; i < n; i++){
        int p;
        cin>>p;
        vec[p]++;
        sm += p;
    }
    int q;
    cin>>q;
    while(q--){
        int b, c;
        cin>>b>>c;
        sm -= vec[b]*b;
        sm += vec[b]*c;
        vec[c] += vec[b];
        vec[b] = 0;
        cout<<sm<<"\n";
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	ll t;
    t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 








}


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

const int N = 105;
string grid[N];
int dp[N][N];

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        cin >> grid[i];
        grid[i] = "&" + grid[i];
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            dp[i][j] = 1e9;
            if(grid[i][j] == '#') {
                if(i > 1 && grid[i-1][j] == '#') {
                    dp[i][j] = min(dp[i][j], dp[i-1][j]);
                }
                else if(i > 1) {
                    dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
                }

                if(j > 1 && grid[i][j-1] == '#') {
                    dp[i][j] = min(dp[i][j], dp[i][j-1]);
                }
                else if(j > 1) {
                    dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
                }
            }
            else {
                if(i>1) dp[i][j] = min(dp[i][j], dp[i-1][j]);
                if(j>1) dp[i][j] = min(dp[i][j], dp[i][j-1]);
            }
            if(i == 1 && j == 1) dp[i][j] = (grid[i][j] == '#');
        }
    }
//    for(int i = 1; i <= n; i++) {
//        for(int j = 1; j <= m; j++) {
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }
    cout << dp[n][m] << endl;
    return 0;
}



Measured memory_bytes: 384
p=print
while 1:
    m,f,r=map(int,input().split())
    x=m+f
    if m==f==r==-1:break
    elif m==-1 or f==-1 or x<30:p('F')
    elif x>=80:p('A')
    elif 65<=x<80:p('B')
    elif 50<=x<65 or r>=50:p('C')
    else:p('D')

Measured memory_bytes: 7704
#!/usr/bin/env python3
N, Q = map(int, input().split())
S = input()
cumsum = [0] * (N + 1)
for i in range(1, N):
    cumsum[i + 1] = cumsum[i] + (S[i - 1:i + 1] == 'AC')

for i in range(Q):
    l, r = map(int, input().split())
    print(cumsum[r] - cumsum[l])


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

const int MX =  1000000007;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> freq(n+1);
  freq[0]=3;

  mint res = 1;
  rep(i,n) {
        cin>>a[i];
        freq[a[i]+1]++;
        res*=(freq[a[i]]-freq[a[i]+1]+1);
  }
  
  cout << res.x << endl;

}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            long lN = long.Parse(Console.ReadLine().Trim());

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            long lSq = (long)Math.Sqrt(lN);
            List<int> lstSmp = new List<int>();
            for (long i = 1; i <= lSq; i++)
            {
                if (lN % i == 0)
                {
                    int iA = i.ToString().Length;                       // Aの桁数
                    int iB = ((long)(lN / i)).ToString().Length;        // Bの桁数
                    if (iA >= iB) { lstSmp.Add(iA); }                   // 大きい方を保持
                    else { lstSmp.Add(iB); }
                }
            }
            if (lstSmp.Count > 1) { lstSmp.Sort(); }                    // 昇順にソート

            //出力
            Console.WriteLine("{0}", lstSmp[0].ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    ll sum=0;
    vector<ll> a(n+1);
    vector<ll> b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll rest=0;
    for(int i=0; i<n; i++){
        sum += min(a[i]-rest, b[i]);
        rest = min(a[i]-rest, b[i]);
        sum += min(a[i+1], b[i]-rest);
        rest = min(a[i+1], b[i]-rest);
    }
    out(sum);
}

Measured memory_bytes: 1792
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, a, b = MAP()
x = LIST()
ans = 0
for i in range(1, n):
    tmp = x[i] - x[i - 1]
    if tmp * a < b:
        ans += tmp * a
    else:
        ans += b
print(ans)


Measured memory_bytes: 16324
n = int(input())
abc = [list(map(int,input().split())) for _ in range(n)]
dp =[]
for i in range(n+1):
  dp.append([0,0,0])
for j in range(0,n):
  for k in range(0,3):
    for l in range(0,3):
      if k != l:
        dp[j+1][k] = max(dp[j+1][k],dp[j][l]+abc[j][k])
print(max(dp[-1][m] for m in range(0,3)))

Measured memory_bytes: 79064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt();
			int count = 0;
			for(int i = A; i <= B; i++) {
				if(String.valueOf(i).charAt(0) == String.valueOf(i).charAt(4) && String.valueOf(i).charAt(1) == String.valueOf(i).charAt(3)) {
					count++;
				}
			}
			out.println(count);
		}
	}
		
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

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

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

Measured memory_bytes: 32212