akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
using namespace std;
#define MOD 1000000007
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;

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

ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m % n);
}//gcd

class SegmentTree {
private:
	int n;
	Array node;

public:
	SegmentTree(Array &v) {
		int sz = v.size();
		n = 1; while (n < sz)n *= 2;
		node.resize(2 * n - 1, 0);
		REP(i, sz) {
			node[i + n - 1] = v[i];
		}
		for (int i = n - 2; i >= 0; i--) {
			node[i] = gcd(node[i * 2 + 1], node[i * 2 + 2]);
		}
	}
	ll getSum(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		if (r <= a || b <= l)return 0;
		if (a <= l && r <= b)return node[k];

		ll vl = getSum(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = getSum(a, b, 2 * k + 2, (l + r) / 2, r);
		ll ret = gcd(vl, vr);
		return ret;
	}
};


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

	ll n;
	cin >> n;
	Array a(n+2,0);
	REP(i, n)cin >> a[i+1];
	SegmentTree seg(a);
	ll ans = 0;
	REP(i, n) {
		ll temp = gcd(seg.getSum(0, i + 1), seg.getSum(i + 2, n + 2));
		chmax(ans, temp);
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>

int main(void)
{

        int a,b,c;

        scanf("%d%d%d",&a,&b,&c);

        if(a==b) printf("%d\n",c);
        else if(b==c) printf("%d\n",a);
        else printf("%d\n",b);
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int main() {
    int N;
    cin >> N;
    vector<P> v(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        v[i] = P(b, a);
    }
    vector<P> w(N);
    for (int i = 0; i < N; i++) {
        int c, d;
        cin >> c >> d;
        w[i] = P(c, d);
    }
    sort(v.begin(), v.end(), greater<P>());
    sort(w.begin(), w.end());
    vector<bool> check(N, false);
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (!check[j] && v[j].second < w[i].first &&
                v[j].first < w[i].second) {
                check[j] = true;
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define ZE '0'

int main()
{
    int len, i, count1=0, count2=0;
    char s[100000];

    scanf("%s", s);
    len = strlen(s);

    for(i=0; i<len; i++)
    {
        if(i%2==0)
        {
            if(s[i]==ZE)
            {
                count1++;
            }
            else
            {
                count2++;
            }
        }
        else
        {
            if(s[i]!=ZE)
            {
                count1++;
            }
            else
            {
                count2++;
            }
        }
    }

    if(count1>count2)
    {
        count1 = count2;
    }
    printf("%d\n", count1);
    return 0;
}

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

#define double long double
#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const int MOD = 1e9 + 7;

inline int mul(int a, int b)
{
	return ((a%MOD) * (b%MOD))%MOD;
}

inline int add(int a, int b)
{
	return ((a%MOD) + (b%MOD))%MOD;
}

inline int f(int x)
{
	int ans = x*(x-1)/2;
	ans %= MOD;
	return ans;
}


int32_t main(void)
{
    FASTER;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int n, k;
    DI(n, k);
    int inversions = 0;
    int a[n];
    
    F(i, 0, n)
    	SI(a[i]);
    
    int right = 0;
    F(i, 0, n)
    {
    	F(j, i + 1, n)
    	{
    		if(a[i] > a[j])
    			++inversions;
    	}
    	F(j, 0, n)
    		if(a[i] > a[j])
    			++right;
    }
    
    int ans = mul(inversions, k);
    ans = add(ans, mul(f(k), right));
    
    SO(ans);
    
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 2 * 1e6 + 10, MOD = 1e9 + 7, INF = 1e9;

vector<vector<pair<ll, ll>>> graph, nw;
map<pair<ll, ll>, ll> ch;
map<ll, ll> rv;
vector<vector<ll>> cols;
ll dist[SIZE];

int main() {
    fastInp;

    ll n, m;
    cin >> n >> m;

    cols.resize(n);
    graph.resize(n);
    for (int i = 0; i < m; i++) {
        ll u, v, c;
        cin >> u >> v >> c;
        u--; v--;
        cols[u].push_back(c);
        cols[v].push_back(c);
        graph[v].push_back({ u, c });
        graph[u].push_back({ v, c });
    }

    ll lst = -1;
    nw.resize((n + m) * 2);
    for (int i = 0; i < n; i++) {
        lst++;
        ch[{i, -1}] = lst;
        ll v = lst;
        for (auto cur : cols[i]) {
            lst++;
            ch[{i, cur}] = lst;
            nw[v].push_back({ lst, 1 });
            nw[lst].push_back({ v, 1 });
        }
    }

    for (int i = 0; i < n; i++) {
        for (auto cur : graph[i]) {
            ll k = ch[{i, cur.second}], k2 = ch[{cur.first, cur.second}];
            nw[ch[{i, cur.second}]].push_back({ ch[{cur.first, cur.second}], 0 });
        }
    }

    queue<ll> q;
    q.push(0);
    for (int i = 1; i <= lst; i++) dist[i] = INF;

    while (!q.empty()) {
        ll v = q.front();
        q.pop();
        for (auto to : nw[v]) {
            if (dist[to.first] > dist[v] + to.second) {
                q.push(to.first);
                dist[to.first] = dist[v] + to.second;
            }
        }
    }

    if (dist[ch[{n - 1, -1}]] == INF) {
        cout << "-1";
        return 0;
    }
    cout << dist[ch[{n - 1, -1}]] / 2;
    return 0;
}


Measured memory_bytes: 109868
#include<stdio.h>
#include<string.h>

int main(void){
	char str[128];
	int limit,i;
	scanf("%d%*c",&limit);
	scanf("%s%*c",str);
	if(strlen(str)<=limit){
		puts(str);
	}else{
		for(i=0;i<limit;i++){
			putc(str[i],stdout);
		}
		puts("...");
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    a.at(i) = A;
    b.at(i) = B;
  }
  int c =1;
  for (int i = 1; i < N; i++) {
    c *= i;
  }
  int d = c * N;
  c *= 2;
  double sum = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      sum += sqrt((a.at(i) - a.at(j)) * (a.at(i) - a.at(j)) + (b.at(i) - b.at(j)) * (b.at(i) - b.at(j)));
    }
  }
  printf("%.8f\n", sum * c / d);
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	multiset<string>st; 
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		st.insert(s); 
		
	}
	for(auto &v:st)
	cout<<v; 
	return 0;  
} 
		 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define pri(n) printf("%d",n)
#define lpri(n) printf("%lld",n)
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define F first
#define S second
const int mod=1e9+7;

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

    int arr[n+1][3];

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

    int dp[n+1][3]={0};

    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];

    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
        dp[i][1]=max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);
        dp[i][2]=max(dp[i-1][0]+arr[i][2],dp[i-1][1]+arr[i][2]);
    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 2560
mx = [0, 1, 0, -1]
my = [-1, 0, 1, 0]

while True:
    w, h = map(int, input().split())
    if w == h == 0:
        break
    tiles = [[i for i in input()] for j in range(h)]
    ax = ay = 0
    for i in range(h):
        for j in range(w):
            if tiles[i][j] == '@':
                ax, ay = j, i
    que = [(ax, ay)]
    tiles[ay][ax] = '#'
    cnt = 1

    while 0 < len(que):
        new_que = []
        for x, y in que:
            for i in range(4):
                nx, ny = x + mx[i], y + my[i]
                if 0 <= nx <= w - 1 and 0 <= ny <= h - 1:
                    if tiles[ny][nx] == '.':
                        cnt += 1
                        new_que.append((nx, ny))
                        tiles[ny][nx] = '#'
        que = new_que
    print(cnt)

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

int main(){
  int N, M; // N:都市の数　M:道路の数
  cin >> N >> M;
  vector<int> num(N, 0);

  int a, b;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    // 道路の数を加算
    num.at(a - 1) += 1;
    num.at(b - 1) += 1;
  }

  // 各都市の道路の数を表示
  for(int i = 0; i < N; i++){
    cout << num.at(i) << endl;
  }
}

Measured memory_bytes: 256
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int n;cin>>n;
    map<string, int> d;
    rep(i, n){
        string s;cin>>s;
        d[s]++;
    }
    cout << "AC x " << d["AC"] << endl;
    cout << "WA x " << d["WA"] << endl;
    cout << "TLE x " << d["TLE"] << endl;
    cout << "RE x " << d["RE"] << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

int main()
{
  int a, b, k;
  cin >> a >> b >> k;
  int list[100] = {};
  REP(i, 100)
  {
    if (a % (i + 1) == 0 && b % (i + 1) == 0)
    {
      list[i] = 1;
    }
  }

  int count = 0;

  int ans = 0;
  for (int i = 99; i >= 0; i--)
  {
    if (list[i] == 1)
    {
      count++;
    }
    ans = i + 1;
    if (count == k)
    {
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>

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

    std::vector<int> w;
    for (int i = 0; i < N; i += 1) {
        int wi;
        std::cin >> wi;
        w.push_back(wi);
    }

    int min_value = 2147483647;
    for (int i = 0; i < N - 1; i += 1) {
        int s1 = std::accumulate(w.begin(), w.begin() + i + 1, 0);
        int s2 = std::accumulate(w.begin() + i + 1, w.end(), 0);
        int value = std::abs(s1 - s2);
        if (value < min_value) {
            min_value = value;
        }
    }

    std::cout << min_value << std::endl;

    return 0;
}


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

typedef int ut;
const int INF = 1<<29;

struct Node {
	ut value, minum;
	//ut sum;
	int size;
	Node* lch;
	Node* rch;
	Node(ut v) : value(v), minum(v), size(1),lch(NULL), rch(NULL) {
		//sum = v;
	}
};

typedef pair<Node*, Node*> npr;

struct RBST {
	Node* root;
	
	RBST(){
		srand(time(NULL));
	}
	
	int size(Node* t) { return !t ? NULL : t->size; }
	//int sum(Node* t) { return !t ? NULL : t->sum; }
	int minum(Node* t) { return !t ? INF : t->minum; }
	
	Node* update(Node* t){
		t->size = size(t->lch) + size(t->rch) + 1;
		t->minum = min(t->value, min(minum(t->lch), minum(t->rch)));
		//t->sum = sum(t->lch) + sum(t->rch) + t->value;
		return t;
	}
	
	Node* merge(Node* l, Node* r){
		if(!l || !r)
			return !l ? r : l;

		int m = l->size, n = r->size;
		if(rand() % (m + n) < m){
			l->rch = merge(l->rch, r);
			return update(l);
		}
		else{
			r->lch = merge(l, r->lch);
			return update(r);
		}
	}
	
	npr split(Node* t, int k){ // [0, k), [k, n)
		if(!t)
			return npr(NULL, NULL);
		if(k <= size(t->lch)){
			npr s = split(t->lch, k);
			t->lch = s.second;
			return npr(s.first, update(t));
		}
		else{
			npr s = split(t->rch, k - size(t->lch) - 1);
			t->rch = s.first;
			return npr(update(t), s.second);
		}
	}
	
	Node* insert(Node* t, int k, ut v){
		npr tmp = split(t, k);
		Node *p = new Node(v);
		return merge(merge(tmp.first, p), tmp.second);
	}
	
	Node* erase(Node* t, int k){
		npr tmp = split(t, k);
		return merge(tmp.first, split(tmp.second, 1).second);
	}
	
	void shift(int l, int r){
		npr a = split(root, r);
		npr b = split(a.first, l);
		npr c = split(a.second, 1);
		
		root = merge(merge(b.first, c.first), merge(b.second, c.second));
	}
	
	ut min_query(int l, int r){
		npr a = split(root, l);
		npr b = split(a.second, r-l+1);
		ut ans = b.first->minum;
		root = merge(a.first, merge(b.first, b.second));
		return ans;
	}
	
	void update_value(int k, int v){
		root = erase(root, k);
		root = insert(root, k, v);
	}
};

int main() {
	RBST* rbst = new RBST();
	int N, Q, a, x, y, z;
	cin >> N >> Q;
	for(int i = 0; i < N; ++i){
		scanf("%d", &a);
		rbst->root = rbst->insert(rbst->root, i, a);
	}
	
	for(int i = 0; i < Q; ++i){
		scanf("%d%d%d", &x, &y, &z);
		if(x == 0){
			rbst->shift(y, z);
		}
		else if(x == 1){
			printf("%d\n", rbst->min_query(y, z));
		}
		else{
			rbst->update_value(y, z);
		}
	}
	return 0;
}

Measured memory_bytes: 13744
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k = map(int,input().split())
for i in range(1,k+1):
    if n - k + 1 >= i:
      print(comb(n - k + 1,i) * comb(k-1,i-1) % (10**9 + 7))
    else:
      print(0)
    
  

Measured memory_bytes: 66264
import java.util.Scanner;
    
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        String labelStr = scanner.nextLine();
        String[] labelArr = labelStr.split(" ");
        int dice[] = new int[6];
        for (int i=0; i<6; i++) {
            dice[i] = Integer.parseInt(labelArr[i]);
        } 
        
        String orderStr = "";
        String questNum = scanner.nextLine();
        for(int i= 0;i<Integer.parseInt(questNum);i++ ){
            String input = scanner.nextLine();
            String inputArr[] = input.split(" ");

            int t = Integer.parseInt(inputArr[0]);
            int f = Integer.parseInt(inputArr[1]);
            
            if( (t==dice[1] && f==dice[2]) || (t==dice[2] && f==dice[4]) || (t==dice[3] && f==dice[1]) || (t==dice[4] && f==dice[3]) ){
                System.out.println(dice[0]);
            } else if( (t==dice[0] && f==dice[3]) || (t==dice[2] && f==dice[0]) || (t==dice[3] && f==dice[5]) || (t==dice[5] && f==dice[2]) ) {
                System.out.println(dice[1]);      
            } else if( (t==dice[0] && f==dice[1]) || (t==dice[1] && f==dice[5]) || (t==dice[4] && f==dice[0]) || (t==dice[5] && f==dice[4]) ) {
                System.out.println(dice[2]);      
            } else if( (t==dice[0] && f==dice[4]) || (t==dice[1] && f==dice[0]) || (t==dice[4] && f==dice[5]) || (t==dice[5] && f==dice[1]) ) {
                System.out.println(dice[3]);      
            } else if( (t==dice[0] && f==dice[2]) || (t==dice[2] && f==dice[5]) || (t==dice[3] && f==dice[0]) || (t==dice[5] && f==dice[3]) ) {
                System.out.println(dice[4]);      
            } else {
                System.out.println(dice[5]);      
            }
        }
    }
}



Measured memory_bytes: 26168
/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH RANJAN******************************************************
***********************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i,n) for(int i=0;i<(int)n;i++)
#define frs(i,a,b) for(int i = a;i<b;i++)
#define meme(a,b,c) memset(a,b,sizeof(c)); //works only for 0 and -1
int main(){
  fast();
 ll n,d;
  cin>>n>>d;
  int count = 0;
  while(n--){
  ll x,y;
    cin>>x>>y;
    ll dist = x*x+y*y;
    if(dist<=d*d)count++;
  }
  cout<<count;
 return 0;
  
}




Measured memory_bytes: 3648
import java.util.*;
public class Main{   
    static int n;
    static int[][] x;
    static int[][] y;
    static int[] a;
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      n = sc.nextInt();
      x = new int[n+1][n+1];
      y = new int[n+1][n+1];
      a = new int[n+1];
      for(int i=1;i<=n;i++){
        a[i]= sc.nextInt();
        for(int j=1;j<=a[i];j++){
          x[i][j]=sc.nextInt();
          y[i][j]=sc.nextInt();
        }
      }
      int ans = 0;
      for(int i=0;i<Math.pow(2,n);i++){
        String bit = Integer.toBinaryString(i);
        StringBuilder sb = new StringBuilder();
        for(int j=0;j<n-bit.length();j++)sb.append("0");
        sb.append(bit);
        boolean[] flag = new boolean[n+1];
        int cnt = 0;
        String s = sb.toString();
        for(int j=0;j<s.length();j++){
          if(s.charAt(s.length()-j-1)=='1'){
            flag[j+1]=true;
            cnt++;
          }
        }
        if(!muzyun(flag))ans = Math.max(ans,cnt);
      }
      System.out.println(ans);
    }
    public static boolean muzyun(boolean[] arr){
      for(int i=1;i<=n;i++){
        for(int j=1;j<=a[i];j++){
          if(y[i][j]==1&&arr[x[i][j]]==false&&arr[i]==true)return true;
          else if(y[i][j]==0&&arr[x[i][j]]==true&&arr[i]==true)return true;
        }
      }
      return false;
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}
class Pair{
    int a,b;

    Pair(int a, int b){
      this.a = a;
      this.b = b;
    }
}

Measured memory_bytes: 32532
/*input
5 3
###
..#
###
#..
###
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 100
#define INF 0x3f3f3f3f

int n , m;
string s[MAX];
int cmp(PII x , PII y){ return x.A + x.B < y.A + y.B; }
int32_t main(){
	IOS;
	cin >> n >> m;
	vector<PII> v;
	REP(i , 0 , n) cin >> s[i];
	REP(i , 0 , n) REP(j , 0 , m) if(s[i][j] == '#') v.pb(i , j);
	sort(ALL(v) , cmp);
	REP(i , 1 , v.size()) if(v[i].A + v[i].B != v[i - 1].A + v[i - 1].B + 1)
		return cout << "Impossible" << endl , 0;
	REP(i , 1 , v.size()){
		int xx = v[i].A - v[i - 1].A;
		int yy = v[i].B - v[i - 1].B;
		if(xx == 1 && yy == 0 || xx == 0 && yy == 1);
		else return cout << "Impossible" << endl , 0;
	}
	cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i, q, a, b;
	char str[1001], order[11], p[1001], wk;
	
	scanf("%s", str);
	scanf("%d", &q);
	for(i = 0; i < q; i++){
		scanf("%s%d%d", order, &a, &b);
		if(!strcmp(order, "print")){
			memcpy(p, &str[a], b-a+1);
			p[b-a+1] = 0x00;
			printf("%s\n", p);
		}else if(!strcmp(order, "reverse")){
			for(; a < b; a++, b--){
				wk = str[a];
				str[a] = str[b];
				str[b] = wk;
			}
		}else{
			scanf("%s", p);
			memcpy(&str[a], p, b-a+1);
		}
	}
	
	return(0);
}



Measured memory_bytes: 1784
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
//B - Card Game for Three
#if 01
/*
일단 스트링으로 카드를 쭉 받아준다.
받아준 스트링에서 맨 처음에는 앨리스의 것을 확인해준다.
앨리스의 것을 확인해준 이후에 앨리스에 해당하는 애의 인덱스를 넥스트로 보내준다.
*/
int main(void)
{
    string a, b, c;
    cin >> a >> b >> c;
    int aidx, bidx, cidx;
    aidx = bidx = cidx = 0;
    char curr = 'a';
    while(aidx <= a.size() && bidx <= b.size() && cidx <= c.size())
    {
        if (curr == 'a')
        {
            curr = a[aidx++];
        }
        else if (curr == 'b')
        {
            curr = b[bidx++];
        }
        else 
        {
            curr = c[cidx++];
        }
    }

    if (aidx > a.size()) cout << 'A' << '\n';
    else if (bidx > b.size()) cout << 'B' << '\n';
    else cout << 'C' << '\n';


    return 0;
}

#endif

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int INF=12345678;

struct state{ int x,y,d; };

int main()
{
    int dx[4]={0,1,0,-1}, dy[4]={-1,0,1,0};

    int w,h;
    while(cin >>w >>h,w)
    {
        int s[30][30];
        int c[4];

        rep(i,h)rep(j,w) scanf(" %d", &s[i][j]);
        rep(i,4) scanf(" %d", &c[i]);

        int dist[30][30][4];
        rep(i,30)rep(j,30)rep(k,4) dist[i][j][k]=INF;
        dist[0][0][1]=0;
        queue<state> que;
        que.push(state{0,0,1});
        #define IN(x,y) (0<=x && x<w && 0<=y && y<h)
        while(!que.empty())
        {
            state now=que.front();
            que.pop();
            if(now.x==w-1 && now.y==h-1) continue;

            rep(i,4)
            {
                int cost=c[i];
                if(s[now.y][now.x]==i) cost=0;

                int nd=(now.d+i)%4;
                int nx=now.x+dx[nd], ny=now.y+dy[nd];
                if(IN(nx,ny) && dist[ny][nx][nd]>dist[now.y][now.x][now.d]+cost)
                {
                    dist[ny][nx][nd]=dist[now.y][now.x][now.d]+cost;
                    que.push(state{nx,ny,nd});
                }
            }
        }

        int ans=INF;
        rep(i,4) ans=min(ans,dist[h-1][w-1][i]);
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
long long int  mod=1000000007;

int main()
{

 int n;
 cin>>n;


 long long int a=0;
 long long int sum=0;
 long long int ans=0;
 for(int i=0;i<n;i++)
 {
     cin>>a;
     a=a%mod;
     long long b=((sum%mod)*(a%mod))%mod;
     ans=(ans+(b))%mod;
     //ans=ans%mod;
     sum+=a;
 }
 cout<<(ans)<<endl;
return 0;
}


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

const int mod = 1e9+7;

int a[3*100000];

int cmp(int a, int b) {
    return abs(b) > abs(a);
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int t, sn = 0;
   
        int n, k;
        cin >> n >> k;
     	sn += n;
        bool zero = 0;
        for(int i = 0; i < n; ++i) {
            cin >> a[i];
            zero |= (a[i] == 0);
        }
        sort(a, a+n, cmp);
        sn = 1;
        vector<int> nums;
        int gneg = -1e9-1, gpos = 1e9+1;
        for(int i = 0, id = n-1; i < k; ++i, id--) {
            if (a[id] < 0) sn *= -1;
            nums.push_back(a[id]);
            if (a[id] < 0)
                gneg = max(gneg, a[id]);
            else
                gpos = min(gpos, a[id]);
        }
        
        if (sn > 0) {
            int ans = 1;
            for(auto x : nums)
                ans = (ans * 1ll * x) % mod;
            cout << (ans + mod) % mod << "\n";
        } else {
            int mn = 1, mx = -1;
            for(int i = 0; i < n-k; ++i) {
                mn = min(mn, a[i]);
                mx = max(mx, a[i]);
            }
            
            bool g1 = gneg != -1e-9-1 && mx != -1;
            bool g2 = gpos != 1e9+1 && mn != 1;
            if (g1 && g2) {
                int val, repl;
                if (mx * 1ll * gpos > mn * 1ll * gneg)
                    val = gneg, repl = mx;
                else
                    val = gpos, repl = mn;
                
                for(int i = 0; i < k; ++i)
                    if (nums[i] == val) {
                        nums[i] = repl;
                        break;
                    }
                int ans = 1;
                for(auto x : nums)
                    ans = (ans * 1ll * x) % mod;
                cout << (ans + mod) % mod << "\n";
            } else if (g1) {
                for(int i = 0; i < k; ++i)
                    if (nums[i] == gneg) {
                        nums[i] = mx;
                        break;
                    }
                int ans = 1;
                for(auto x : nums)
                    ans = (ans * 1ll * x) % mod;
                cout << (ans + mod) % mod << "\n";
            } else if (g2) {
                for(int i = 0; i < k; ++i)
                    if (nums[i] == gpos) {
                        nums[i] = mn;
                        break;
                    }
                int ans = 1;
                for(auto x : nums)
                    ans = (ans * 1ll * x) % mod;
                cout << (ans + mod) % mod << "\n";
            } else {
                if (zero)
                    cout << "0\n";
                else {
                    int ans = 1;
                    for(int i = 0; i < k; ++i)
                        ans = (ans * 1ll * a[i]) % mod;
                    cout << (ans + mod) % mod << "\n";
                }
            }
        }
    return 0;
}


Measured memory_bytes: 6808
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

//////////

signed main()
{
    fastio;
    int k,a,b;
    cin>>k>>a>>b;
    if(b-a<=2||k+1<=a)
    {
        cout<<1+k;
    }
    else
    {
        int ans=a;
        k-=a-1;
        ans+=(k/2)*(b-a);
        if(k%2==1)
            ans++;
        cout<<ans;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int R;
  cin >> R;
    if (R<1200) cout << "ABC" << endl;
    else if (R<2800 && R>=1200) cout << "ARC" << endl;
    else if (R>=2800) cout << "AGC" << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
p = [int(i)-1 for i in input().split() ]


tree=[[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

from collections import deque

groups=[]
been=[0]*n
for i in range(n):
    if been[i]==0:
        group=[i]
        been[i]=1
        q = deque([(i,togo) for togo in tree[i]]) 
        while q:
            parent,x = q.popleft()
            if been[x]==1:
                continue
            been[x]=1
            group.append(x)
            for y in tree[x]:
                if y == parent:#親ノードを飛ばし
                    continue
                q.append((x,y))#子ノードを追加
        groups.append(group)

ans=0
for group in groups:
    ans+= len( set(group) & set(p[g] for g in group) )

print(ans)

Measured memory_bytes: 94956
import sys
input = sys.stdin.readline

N=int(input())
A = list(map(int, input().split()))

def SelectionSort(N):
    count=0
    for i in range(N):
        minj=i
        for j in range(i,N):
            if A[j]<A[minj]:
                minj=j
        A[i],A[minj]=A[minj],A[i]
        if i!=minj:
            count+=1
    print(*A)
    print(count)
SelectionSort(N)


Measured memory_bytes: 5612
n, k = map(int, input().split())
d = list(map(int, input().split()))

n_str = str(n)
# print(n_str)

l = list(({0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(d)))

# print(l)

ans = n
found = False
while not found:
  found = True
  ans_str = str(ans)
  for i in range(len(ans_str)):
    if int(ans_str[i]) not in l:
      # print("NOT FOUND", ans_str[i])
      found = False
  ans +=1

ans -= 1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void)
{
    int h,n,i,sum = 0;
    scanf("%d%d",&h,&n);
    int a[n];
    for(i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
        sum += a[i];
    }
    if(h <= sum)
        printf("Yes");
    else
        printf("No");
 
 
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
map<ll, queue<int>> qup,qdown;
map<ll, int> cup,cdown;
map<P, bool> mp;
int n, a, b;
P loc[1 << 17];
ll cnt[1 << 17];

struct uf {
	vector<int> par, r;
	uf(int n) {
		par.resize(n); r.resize(n, 0);
		rep(i, n)par[i] = i;
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return find(par[x]);
	}
	int unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return 0;
		if (r[x] < r[y]) {
			par[x] = y;
			return x;
		}
		else {
			par[y] = x;
			if (r[x] == r[y])r[x]++;
			return y;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
queue<int> up, down;
int main() {
	cin >> n >> a >> b; a--; b--;
	uf u(n);
	rep(i, n) {
		cin >> loc[i].first >> loc[i].second;
		mp[loc[i]] = true;
	}
	P memo = loc[a];
	ll d = abs(loc[a].first - loc[b].first) + abs(loc[a].second - loc[b].second);
	sort(loc, loc + n);
	int sta;
	rep(i, n) {
		if (loc[i] == memo) {
			sta = i;
		}
	}
	int ri = 0;
	rep(i, n) {
		while (ri < n&&loc[i].first + d >= loc[ri].first) {
			qup[loc[ri].first + loc[ri].second].push(ri);
			cup[loc[ri].first + loc[ri].second]++;
			qdown[loc[ri].first - loc[ri].second].push(ri);
			cdown[loc[ri].first - loc[ri].second]++;
			ri++;
		}
		ll sumup = loc[i].first + loc[i].second;
		ll sumdown = loc[i].first - loc[i].second;
		if (qup[sumup].front()==i) qup[sumup].pop();
		cup[sumup]--;
		if(qdown[sumdown].front()==i)qdown[sumdown].pop();
		cdown[sumdown]--;
		sumup += d; sumdown += d;
		up = qup[sumup];
		down = qdown[sumdown];
		cnt[i] = cup[sumup] + cdown[sumdown] - mp[{loc[i].first + d, loc[i].second}];
		while (!up.empty()) {
			u.unite(i, up.front()); 
			if (up.size() == 1)qup[sumup] = up;
			up.pop();
		}
		while (!down.empty()) {
			if (down.size() == 1)qdown[sumdown] = down;
			u.unite(i, down.front()); down.pop();
		}
	}
	ll ans = 0;
	rep(i, n) {
		if (u.same(i, sta)) {
			ans += cnt[i];
			//cout << i << " " << cnt[i] << endl;
		}
	}
	cout << ans << endl;
	//stop
	return 0;
}


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

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

    int res = 1001001001;
    for(int k=1; k<(1<<12); ++k) {
        vector<int> r(M, 0);
        int sum = 0;
        for(int i=0; i<N; ++i) {
            if((k >> i) & 1) {
                sum += C[i];
                for(int j=0; j<M; ++j) {
                    r[j] += A[i][j];
                }
            }
        }

        bool ok = true;
        for(int j=0; j<M; ++j) {
            if(r[j] < X) ok = false;
        }
        if(ok) res = min(res, sum);
    }

    if(res == 1001001001) cout << "-1\n";
    else cout << res << '\n';
}

Measured memory_bytes: 3632
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	numT := scanner.Text()
	num, _ := strconv.ParseInt(numT, 10, 64)
	n := float64(num)
	c := 0
	j := float64(1)
	target := float64(0)

	for i := float64(1); i <= n; i++ {
		target = n - i

		for j = 1; j <= target; j++ {
			k := target / j
			if j > k {
				break
			}
			if k == float64(int(k)) {
				//fmt.Printf("%f,%f,%f\n", j, k, i)
				c += 2
				if j == k {
					c -= 1
				}
			}
		}
	}

	fmt.Println(c)
}


Measured memory_bytes: 1788
def gcd(a, b):
    if a > b:
        a, b = b, a
    if b % a == 0:
        return a
    else:
        return gcd(b % a, a)


abk = list(map(int, input().split()))
a = abk[0]
b = abk[1]
k = abk[2]
ab_gcd = gcd(a, b)
ab_div = []
for i in range(ab_gcd):
    if ab_gcd % (i + 1) == 0:
        ab_div.append(i + 1)
print(ab_div[-k])


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

const int MAXN = 3001;

ll n, s, a[MAXN], dp[MAXN][MAXN], cum[MAXN][MAXN], ans, mod = 998244353;

int main()
{
	FAST_IO;

	cin >> n >> s;
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) dp[i][0] = 1;
	for(int i=1;i<=s;i++) dp[n - 1][i] = 0;
	for(int i=0;i<n;i++) dp[i][a[i]] = 1;
	for(int i=0;i<=s;i++) cum[n - 1][i] = dp[n - 1][i];
    for(int i=n-2;i>=0;i--)
    {
    	for(int j=0;j<=s;j++)
    	{
    		if(j >= a[i])
    			dp[i][j] = (dp[i][j] + cum[i + 1][j - a[i]]) % mod;
    	}
    	for(int j=0;j<=s;j++) cum[i][j] = (cum[i + 1][j] + dp[i][j]) % mod;
    }
	for(ll i=0;i<n;i++) ans = (ans + ((i + 1) * dp[i][s]) % mod) % mod;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 140928
/*
 * I won't be broken
 * I won't be tortured
 * I won't be beaten down
 * I have the answer
 * I can take the pressure
 * I will turn it all around
 * Lift me up above this
 * The flames and the ashes
 * Lift me up and help me to fly away
*/
#include <bits/stdc++.h>
using namespace std;
int n;
set <int> s;
int main(){
        scanf("%d",&n);
        int x;
        while(n--){
                scanf("%d",&x);
                s.insert(x);
        }
        printf("%ld\n",s.size());
        return 0;
}


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int a, b;
  cin >> a >> b;

  int ans = 0;
  for (int i = 1; i <= a; ++i) {
    for (int j = 1; j <= 31; ++j) {
      if (i == a) {
        if (j > b) continue;
      }

      if (i == j) ++ans;
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {

  val n = scala.io.StdIn.readInt()
  val arr = scala.io.StdIn.readLine().split(" ").map(_.toInt)


  def solve() = {
    val default = arr.mkString(" ")
    val ans: Seq[String] = for(i <- 1 until n) yield {
      var v = arr(i)
      var j = i-1
      while(j >= 0 && arr(j) > v) {
        arr(j+1) = arr(j)
        j -= 1
      }
      arr(j+1) = v
      arr.mkString(" ")
    }
    (default +: ans).mkString("\n")
  }

  println(solve)

}



Measured memory_bytes: 45696
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
  int n, k, s;
  scanf("%d %d %d", &n, &k, &s);
  rep(i, k) printf("%d ", s);
  if (s >= 1000000000)
    rep(i, n - k) printf("%d ", s-1);
  else
    rep(i, n - k) printf("%d ", s+1);
  printf("\n");
  return 0;
}


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

const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
// 左 上 右 下

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) { cin >> s[i]; }
    int ans = 0;
    rep(si, h) rep(sj, w) {
        if(s[si][sj] == '#')
            continue;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x) {
            if(dist[i][j] != INF)
                return;
            dist[i][j] = x;
            q.push(P(i, j)); // .emplace(i,j)
        };
        update(si, sj, 0);
        while(!q.empty()) {
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            rep(dir, 4) {
                int ni = i + di[dir], nj = j + dj[dir];
                if(ni < 0 || ni >= h || nj < 0 || nj >= w)
                    continue;
                if(s[ni][nj] == '#')
                    continue;
                update(ni, nj, dist[i][j] + 1);
            }
        }

        rep(i, h) rep(j, w) {
            if(dist[i][j] == INF)
                continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

// a,b の最大公約数と、ax + by = gcd(a,b) となる x,y を求める
long long extgcd(long long a, long long b, long long &x, long long &y) {
    long long g = a;
    if(b != 0){
        g = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1;
        y = 0;
    }
    return g;
}

// ax ≡ gcd(a, m) (mod m) となる x を求める
// a, m が互いに素ならば、関数値は mod m での a の逆数となる
long long mod_inverse(long long a, long long m)
{
    long long x, y;
    extgcd(a, m, x, y);
    return (x % m + m) % m;
}

class FactorialCalculation
{
private:
    const int mod;
    vector<long long> factorial;
    vector<long long> invFactorial;
public:
    FactorialCalculation(int n, int mod) : mod(mod)
    {
        factorial.resize(n+1, 1);
        invFactorial.resize(n+1, 1);
        for(int i=1; i<=n; ++i){
            factorial[i] = factorial[i-1] * i % mod;
            invFactorial[i] = mod_inverse(factorial[i], mod);
        }
    }
    long long getFactorial(int n){
        return factorial[n];
    }
    long long getPermutation(int n, int r){
        if(n < r)
            return 0;
        return factorial[n] * invFactorial[n-r] % mod;
    }
    long long getCombination(int n, int r){
        if(n < r)
            return 0;
        return getPermutation(n, r) * invFactorial[r] % mod;
    }
    long long getHomogeneous(int n, int r){
        return getCombination(n+r-1, r);
    }
};

const int MOD = 1000000007;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    FactorialCalculation f(a+b+c, MOD);

    long long tmp = 1;
    long long ans = 1;
    for(int i=1; i<=b+c; ++i){
        tmp *= 2;
        tmp %= MOD;
        if(i > b){
            tmp -= f.getCombination(i - 1, b);
            tmp += MOD;
            tmp %= MOD;
        }
        if(i > c){
            tmp -= f.getCombination(i - 1, i - 1 - c);
            tmp += MOD;
            tmp %= MOD;
        }

        ans *= 3;
        ans += tmp * f.getCombination(a + i - 1, i);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14336
#include<cstdio>
int a[10][10],f[10][10],b[110],n;
int main() {
	for (int i=1;i<=3;++i) for (int j=1;j<=3;++j) scanf("%d",&a[i][j]);
	scanf("%d",&n);
	for (int k=1;k<=n;++k)  {
		scanf("%d",&b[k]);
		for (int i=1;i<=3;++i) for (int j=1;j<=3;++j) if (a[i][j]==b[k]) f[i][j]=1;
	}
	for (int i=1;i<=3;++i) {
		if (f[i][1]+f[i][2]+f[i][3]==3) {
			printf("Yes");
			return 0;
		}
		if (f[1][i]+f[2][i]+f[3][i]==3) {
			printf("Yes");
			return 0;
		}
	}
	if (f[1][1]+f[2][2]+f[3][3]==3) {
		printf("Yes");
		return 0;		
	}
	if (f[1][3]+f[2][2]+f[3][1]==3) {
		printf("Yes");
		return 0;		
	}
	printf("No");
	return 0;
} 

Measured memory_bytes: 128
# here you can test your code...


n = int(input())
flag = False
cnt=0
for i in range(n):
    x,y = map(int,input().split())
    if x!=y:
        if cnt>=3:
            flag = True
        cnt = 0
    else:
        cnt+=1
if cnt >=3:
    flag = True
if flag:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9184
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def divisor(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret

def MI(): return map(int, input().split())


def main():
    A, B, K = MI()
    common = []
    a = divisor(A)
    b = divisor(B)

    for i in range(len(a)):
        if a[i] in b:
            common.append(a[i])

    common.sort()

    print(common[len(common)-K])


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;

using namespace std;

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

int main(){
    while(true){
        ll w, d; cin >> w >> d;
        if(w==0 && d == 0) break;
        
        vector<ll> h(21, 0), g(21, 0);
        rep(i, w) {
            ll a; cin >> a;
            h[a]++;
        }
        
        rep(i, d) {
            ll a; cin >> a;
            g[a]++;
        }
        
        ll sum = 0;
        rep(i, 21){
            sum += max(h[i], g[i]) * i;
        }
        
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3016