akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

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

    MSG(max(c - (a - b), 0))
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll n;
	cin>>n;
	ll a[n];
	ll sum=0;
	map<ll, ll> mp;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		mp[a[i]]++;
	}
	ll q, b, c;
	cin>>q;
	while(q--){
		cin>>b>>c;
		sum-=b*mp[b];
		sum+=c*mp[b];
		mp[c] += mp[b];
		mp[b]=0;
		cout<<sum<<"\n";
	}

    return 0;
}


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

using namespace std;

int main() {

    int n;
    cin >> n;
    vector<char> data(n);
    string answer = "Three";
    
    for(int i = 0; i < n; i++){
        cin >> data.at(i);
    }

    for(int x: data){
        if(x == 'Y'){
            answer = "Four";
        }
    }

    cout << answer;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct SegTree{
	vi data;
	int size;
	SegTree(int _size){
		for(int i=1;;i*=2)
			if(i>=_size){
				size=i;
				break;
			}
		data.assign(size*2,0);
	}
	void add(int i,int x){
		for(int j=size+i;j;j/=2)
			data[j]+=x;
	}
	int sum(int a,int b,int i,int l,int r){
		if(r<=a || b<=l) return 0;
		if(a<=l && r<=b) return data[i];
		int m=(a+b)/2,res=0;
		if(a<m) res+=sum(a,b,i*2+0,l,m);
		if(m<b) res+=sum(a,b,i*2+1,m,r);
		return res;
	}
	int ith(int i){
		int j=1;
		while(j<size){
			if(data[j*2+0]>i)
				j=j*2+0;
			else{
				i-=data[j*2+0];
				j=j*2+1;
			}
		}
		return j-size;
	}
};

int main()
{
	//for(int q,l;cin>>q>>l,q|l;){
	for(int q,l;scanf("%d%d",&q,&l),q|l;){
		SegTree st(q);
		vi girls;
		map<int,int> m;
		rep(i,q){
			//int qu,x; cin>>qu>>x;
			int qu,x; scanf("%d%d",&qu,&x);
			if(qu==0){
				st.add(girls.size(),1);
				m[x]=girls.size();
				girls.push_back(x);
				if(st.data[1]>l){
					int j=st.ith(0);
					st.add(j,-1);
				}
			}
			if(qu==1){
				int j=st.ith(x-1);
				st.add(j,-1);
			}
			if(qu==2){
				int j=st.ith(x-1);
				//cout<<girls[j]<<endl;
				printf("%d\n",girls[j]);
			}
			if(qu==3){
				int j=m[x];
				st.add(j,-1);
			}
		}
		puts("end");
	}
	
	return 0;
}

Measured memory_bytes: 18000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
const ll l09=1000000000;
int main(){
    ll s; cin >> s;
    cout << 0 << " " << 0 << " ";
    if(s==1000000000000000000){
        cout << l09 << " " << 0 << " " << 0 << " "<< l09 << endl;
        return 0;
    }
    if(s<=l09){
        cout << 0 << " " << 1 << " " << s << " "<< 0 << endl;
        return 0;
    }
    else{
        ll c = l09-(s%l09);
        // if((s+c)%1000000000==0) cout << "ok" << endl;
        ll d = (s+c)/l09;
        cout << l09 << " " << 1 << " " << c << " " << d << endl;
    }
}


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

	#define E "\n"
	#define int long long 
	#define f(i,l,n) for(int i=l;i<n;i++)




	int solve()
	{
		int n;
		cin >> n;
		int a[n];
		f(i,0,n) cin >> a[i];

		map<int,int> mp;
		int ans=0;
		f(i,0,n)
		{
			int temp=i+1-a[i];
			if(mp[temp]!=0) ans+=mp[temp];
			mp[a[i]+i+1]++;
		}
		cout<<ans;
      return 0;
	}


	int32_t main()
	{


		  #ifndef ONLINE_JUDGE
		  freopen("input.txt","r",stdin);
		  freopen("output.txt","w",stdout);
		  #endif
	  int t=1;
	  //cin >>t;
	  while(t--) solve();

	}

Measured memory_bytes: 27840
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  // max ( (max(xi+yi)-min(xi+yi)), (max(xi-yi) - min(xi-yi)) )
  
  ll mx=0;
  
  ll n;
  
  cin>>n;
  
  ll a=-INF;
  
  ll b=INF;
  
  ll c=-INF;
  
  ll d=INF;
  
  
  for(ll i=0;i<n;i++){
      ll x,y;
      
      cin>>x>>y;
      
      a=max(a,x+y);
      
      b=min(b,x+y);
      
      c=max(c,x-y);
      
      d=min(d,x-y);
      
      mx=max(mx,max(a-b,c-d));
      
  }
  
  cout<<mx<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

//
// 高橋君はデータの加工が行いたいです。
// シカのAtCoDeerくんは二つの正整数 a,b を見つけました。 a と b の積が偶数か奇数か判定してください。
// 制約
// 1 < a,b < 10000
// 入力
// a b stdin
// 出力
// "Odd" / "Even"

int main () {

  int a;
  std::cin >> a;
  int b;
  std::cin >> b;

  if ( a & 1 && b & 1)
  {
    std::cout << "Odd" << std::endl;
  } else {
    std::cout << "Even" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
# ABC172 Making Triangle
N = int(input())
L = list(map(int,input().split()))
d = {i:L.count(i) for i in L}

L = sorted(list(set(L)))
num = len(L)
ans = 0

for i in range(num-2):
    for j in range(i+1,num-1):
        for k in range(j+1,num):
            if L[k] < L[i] + L[j]:
                ans += d[L[k]]*d[L[i]]*d[L[j]]
            else:
                break
print(ans)

Measured memory_bytes: 9164
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

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

	ll num[100];
	int max_num = 0, min_num = mod;
	REP(i, N) {
		int new_num;
		cin >> new_num;
		max_num = max(max_num, new_num);
		min_num = min(min_num, new_num);
	}
	cout << max_num - min_num;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
N = int(input())
d = list(map(int, input().split()))

if N % 2 == 1:
    print(0)
else:
    sed_d = sorted(d)
    sed_l = len(sed_d)
    l = sed_d[(sed_l//2)-1]
    r = sed_d[sed_l//2]
    K_list = list(range(l+1,r+1))
    print(len(K_list))

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
const int maxx = 2e5 + 7;
int n;
int a[maxx];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	if(n == 1) printf("%d\n", a[1]);
	else if(n == 2) printf("%d %d\n", a[2], a[1]);
	else {
		if(n & 1) {
			for(int i = n; i >= 1; i -= 2) printf("%d ", a[i]);
			for(int i = 2; i <= n; i += 2) {
				if(i + 2 > n) printf("%d\n", a[i]);
				else printf("%d ", a[i]);
			}
		}
		else {
			for(int i = n; i >= 1; i -= 2) printf("%d ", a[i]);
			for(int i = 1; i <= n; i += 2) {
				if(i + 2 > n) printf("%d\n", a[i]);
				else printf("%d ", a[i]);
			}
		}
	}
}

Measured memory_bytes: 2944
/**
 *   author: sahushivam
 *   created: 08 December 2019 (Sunday)  17:29:28
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,a,b) for(int i = a; i<b; i++)
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t=1;
    string s;
    cin>>s;
    int i=0, c=0,j=s.length()-1;
    while(i<j)
    {
    	if(s[i]!=s[j])
    		c++;
    	i++; j--;
    }
    cout<<c;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N, a[100000];
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &a[i]);

	int on = 0;
	int i;
	bool def = false;
	for(i = 1; i <= N; i++){
		on = a[on];
		if(on == 2){
			def = true;
			break;
		}
		on--;
	}
	if(def) printf("%d\n", i);
	else printf("-1\n");
	return 0;
}


Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def M(n): return ModInt(n)
def MI(): return M(I())


def main():
    s = S()
    x,y = LI()
    a = [len(_) for _ in s.split('T')]
    l = len(a)
    x -= a[0]
    x = abs(x)
    y = abs(y)

    s = set([0])
    for i in range(2,l,2):
        t = set()
        for c in s:
            t.add(c+a[i])
            t.add(c-a[i])
        s = t
    if x not in s and -x not in s:
        return 'No'
    s = set([0])
    for i in range(1,l,2):
        t = set()
        for c in s:
            t.add(c+a[i])
            t.add(c-a[i])
        s = t
    if y not in s and -y not in s:
        return 'No'


    return 'Yes'



print(main())




Measured memory_bytes: 7868
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	string s,t;
	bool km[200010],lm[200010];
	FOR(i,200010){km[i]=0;lm[i]=0;}
	int k[200010],l[200010];
	cin >> s >> t;
	int n=(int)s.size();
	int v=0,vv=0;

	FOR(i,n){
		if(km[i])continue;
		for(int j=i;j<=n-1;j++){
			if(s[i]==s[j]){
				km[j]=1;
				k[j]=v;
			}
		}
		v++;

	}

	FOR(i,n){
		if(lm[i])continue;
		for(int j=i;j<=n-1;j++){
			if(t[i]==t[j]){
				lm[j]=1;
				l[j]=vv;
			}
		}
		vv++;

	}

	bool ans=1;
	FOR(i,n){
		if(k[i]!=l[i]){
			ans=0;
		}
	}

	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl; 
	}
	
}

Measured memory_bytes: 2696
#include <stdio.h>

int main(void){
  int a, b;
  char op;
  for(;;){
    scanf("%d %c %d", &a, &op, &b);
    if(op == '+')
      printf("%d\n", a + b);
    else if(op == '-')
      printf("%d\n", a - b);
    else if(op == '*')
      printf("%d\n", a * b);
    else if(op == '/')
      printf("%d\n", a / b);
    else
      break;
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;

int main(){

    int n, m;
    cin >> n >> m;
    bool flag=true;
    int arr[n];
    memset(arr,-1,sizeof arr);
    if(m==0){
        if(n==1) cout << 0 << "\n";
        if(n==2) cout << 10 << "\n";
        if(n==3) cout << 100 << "\n";
    }else{
        for(int i=0; i<m; i++){
            int si, ci;
            cin >> si >> ci;
            if((si==1 && ci==0 && n!=1) || (arr[si-1]!=-1 && arr[si-1]!=ci)){
                flag=false;
                break;
            }
            arr[si-1]=ci;
        }
        if(flag){

            if(n==3){
                if(arr[2]==-1) arr[2]=0;
                if(arr[1]==-1) arr[1]=0;
                if(arr[0]==-1) arr[0]=1;
            }else if(n==2){
                if(arr[1]==-1) arr[1]=0;
                if(arr[0]==-1) arr[0]=1;
            }
                        
            int answer=0;
            int y=1;
            for(int i=n-1; i>=0; i--){
                answer+=arr[i]*y;
                y*=10;
            }
            cout << answer << "\n";
        }else{
            cout << -1 << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
input_line = str(input())
s = []

for i in range(len(input_line)):
    if input_line[i] == '9':
        s.append('1')
    elif input_line[i] == '1':
        s.append('9')
    else:
        s.append(input_line[i])

mojiretu = ''

for x in s:
    mojiretu += x

print(int(mojiretu))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long X,Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44

using namespace std;



int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int a, b, c;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> a >> b >> c;
    cout << b + min(c, a + b + 1);
    //cin.close();
    //cout.close();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int x;
  cin >> x;
  int ans = 1;
  while (1) {
	  if (ans * x % 360 == 0) {
		  cout << ans << endl;
		  break;
		}
	  ans++;
	}
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string c;
    cin >> c;
    if(c =="a"){
        cout << "vowel" << endl;
    }
    else if(c=="e"){
         cout << "vowel" << endl;
    }
    else if(c=="i"){
         cout << "vowel" << endl;
    }
    else if(c=="o"){
         cout << "vowel" << endl;
    }
    else if(c=="u"){
         cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a*c <= b)
    cout << c << endl;
  else cout << b/a << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll X[N], L[N];
    pll l[N], r[N];
    rep(i, N){
        cin >> X[i] >> L[i];
        r[i] = pll(X[i]+L[i],i);
    }
    sort(r, r+N);
    int cnt = 0;
    ll pos = -INF;
    rep(i, N){
        int j = r[i].second;
        if(X[j]-L[j] < pos) continue;
        cnt++;
        pos = r[i].first;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    E[u].push_back(v);
    E[v].push_back(u);
  }
  vector<bool> used(N, false);
  int ans = 0;
  for (int i = 0; i < N; i++){
    if (!used[i]){
      used[i] = true;
      ans++;
      queue<int> Q;
      Q.push(i);
      while (!Q.empty()){
        int v = Q.front();
        Q.pop();
        for (int w : E[v]){
          if (!used[w]){
            used[w] = true;
            Q.push(w);
          }
        }
      }
    }
  }
  cout << ans - 1 << endl;
}


Measured memory_bytes: 8416
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main(){
  double x=0,y=0;
  double z=0,w=0,n=0;
  string a="";
  std::cin >> x>>y;
  rep(i,x){
    std::cin >> z>>w;
    w=w/z;
    if(n<w)n=w;
  }
n=n*y;
printf("%0.4lf\n",n);
}





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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main() {
    int k, s;
    cin >> k >> s;
    int count = 0;
    map<int, int> m;
    rep(i, k + 1) {
        rep(j, k + 1) {
            int z = s - i - j;
            if (0 <= z && z <= k) {
                count++;
            }
        }
    }
cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3592
import math
n = int(input())
m = n
l = []
for i in range(2, int(math.sqrt(n))+1):
    while m % i ==0:
        l.append(i)
        m = m // i
        if m == 1:
            break

if m != 1:
    l.append(m)
print("{}: ".format(n),end="")
print(*l)



Measured memory_bytes: 5664
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  string s,t;
  cin >> s >> t;
  int q;
  cin >> q;
  int ss=s.size();
  int tt=t.size();
  int u[ss+1];
  int v[tt+1];
  u[0]=0;
  v[0]=0;
  rep(i,ss){
    if(s[i]=='B')u[i+1]=(u[i]+2)%3;
    else u[i+1]=(u[i]+1)%3;
  }
  rep(i,tt){
    if(t[i]=='B')v[i+1]=(v[i]+2)%3;
    else v[i+1]=(v[i]+1)%3;
  }
  rep(i,q){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((3+u[b]-u[a-1])%3==(3+v[d]-v[c-1])%3)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  //rep(i,ss+1)cout << u[i] << endl;
  //rep(i,tt+1)cout << v[i] << endl;
}


Measured memory_bytes: 4540
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

Vi pairw(1000050,0);
Vi setwi(1000050,0);
Vi prime(void){
    Vi primes;
    repi(i,2,1001){
        bool ok=true;
        repi(j,2,i){
            if(i%j==0){
                ok=false;
                break;
            }
        }
        if(ok) primes.pb(i);
    }
    return primes;
}
void solve(){
    ll n;
    cin >> n;
    Vi a(n);
    rp(i,n){
        cin >> a.at(i);
    }
    bool pairok=true,setok=true;
    Vi pr=prime();
    Vi seen(1000,0);
    ll ic=0;
    for(auto p:pr){
        ll ctr=0;
        bool divide=true;
        for(auto& an:a){
            if(an%p==0) ctr++;
            else divide=false;
            while(an%p==0){
                an/=p;
            }
        }
        if(ctr>=2) {
            pairok=false;
        }
        if(divide) setok=false;
    }
    sort(all(a));
    bool s=true;
    rp(i,n-1){
        if(a[i]!=1&&a[i]==a[i+1]) pairok=false;
        else s=false;
    }
    if(s) setok=true;
    if(pairok) print("pairwise coprime");
    else if(setok) print("setwise coprime");
    else print("not coprime");
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main () {
  int x;
  cin >> x;
  if (x == 0) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int N;
  cin >> N;
  vector<int> a;
  rep(i, N) {
    int ai;
    cin >> ai;
    a.pb(ai);
  }
  sort(a.rbegin(), a.rend());

  int A = 0;
  int B = 0;
  rep(i, N) {
    if (i % 2 == 0) {
      A = A + a[i];
    } else {
      B = B + a[i];
    }
  }

  cout << (A - B) << endl;
}


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

main() {
  string s[3]; rep(i, 3) cin >> s[i];
  int d = 'A' - 'a';
  rep(i, 3) cout << (char)(s[i][0] + d);
  cout << endl;
}

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

def qa(s):
    qa_dict = {}
    WAs=0
    ACs=0
    for qa in s:
        qa_dict[qa[0]] = 0
    for qa in s:
        if qa_dict[qa[0]] <= 0:
            if qa[1] == 'WA':
                qa_dict[qa[0]] -= 1
            elif qa[1] == 'AC':
                if qa_dict[qa[0]] == 0:
                    qa_dict[qa[0]] += 0.001
                else:
                    qa_dict[qa[0]] *= -1
                ACs += 1
    for v in qa_dict.values():
        if v > 0:
            WAs += int(v)
    return ACs, WAs

if m == 0:
    ac, wa = 0, 0
else:
    ac, wa = qa(s)
print('{} {}'.format(ac, wa))

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

MOD = 10 ** 9 + 7

N = int(input())
AN = list(map(int, input().split()))
BN = list(map(int, input().split()))
CN = list(map(int, input().split()))

ans = sum(BN)
for i in range(N - 1):
    if AN[i + 1] == AN[i] + 1:
        ans += CN[AN[i] - 1]

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  sort(all(a));
  vi check(a[n-1]+1);
  rep(i,n){
    for(int j = a[i]; j <= a[n-1]; j += a[i]){
      check[j]++;
    }
  }
  int ans = 0;
  rep(i,n) if(check[a[i]]==1) ans++;
  cout << ans;
}


Measured memory_bytes: 7928
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <queue>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    for(int i = 100; i >= 1; i--){
        if(A % i == 0 && B % i == 0){
            K--;
        }
        if(!K){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
s = str(input())
letter_list = []
for letter in s:
    letter_list.append(letter)
letter_list.sort()
l1 = letter_list[0]
l2 = letter_list[2]
if letter_list.count(l1) == 2 and letter_list.count(l2) == 2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;

//public class Problem0011_DrawingLots {
public class Main {
	public static void main(String[] args) {
		try {
		//	Problem0011_DrawingLots test = new Problem0011_DrawingLots();
			Main test = new Main();
			
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String line = reader.readLine();
			
			int volume = Integer.parseInt(line);
			int swappingCount = Integer.parseInt(reader.readLine());
			int[][] swaps = new int[swappingCount][2];
			
			for(int i = 0; i < swappingCount; i++) {
				line = reader.readLine();
				String[] textArray = line.split(",");
				for(int j = 0; j < 2; j++) {
					swaps[i][j] = Integer.parseInt(textArray[j]);
				}
			}
			test.showAnswer(volume, swaps);
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	void showAnswer(int number, int[][] arrays) {
		int[] numbers = new int[number];
		for(int i = 0; i < numbers.length; i++) {
			numbers[i] = i+1;
		}
		
		for(int[] array : arrays) {
			swap(numbers, array[0]-1, array[1]-1);
		}
		for(int positionNumber : numbers) {
			System.out.println(positionNumber);
		}
	}
	void swap(int[] target, int position1, int position2) {
		int temporary = target[position1];
		target[position1] = target[position2];
		target[position2] = temporary;
	}
}

Measured memory_bytes: 9352
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,i,j,z,x;
	scanf("%d %d %d",&a,&s,&d);
	f=a;
	g=s;
	if(f<g){
		h=f;
		f=g;
		g=h;
	}
	while(1){
		h=f%g;
		if(h==0) break;
		f=g;
		g=h;
	}
	z=a/g;
	x=s/g;
	printf("%d\n",z*x*d);
	return 0;
}

Measured memory_bytes: 2712
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >

#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ll n, m, X, Y; cin >> n >> m >> X >> Y;
	vl x(n), y(m);
	for (int i = 0; i < n; ++i) cin >> x[i];
	for (int i = 0; i < m; ++i) cin >> y[i];
	sort(all(x));
	sort(all(y));
	for (int i = x[n - 1] + 1; i <= y[0]; ++i){
		if (X < i && i <= Y){
			cout << "No War" << endl;
			return 0;
		}
	}cout << "War" << endl;
}

Measured memory_bytes: 256
#include<cstdio>  
#include<cstring>  
#include<algorithm>  
#include<iostream>  
#include<string>  
#include<vector>  
#include<stack>  
#include<bitset>  
#include<cstdlib>  
#include<cmath>  
#include<set>  
#include<list>  
#include<deque>  
#include<map>  
#include<queue>
using namespace std;
typedef long long ll;
const ll inf=1<<29;
const ll Maxn=1e6;

int main(){
	ll n,k;
	ll ans=0;
	scanf("%lld %lld",&n,&k);
	if(k==0){
		ans=n*n;
		printf("%lld",ans);
		return 0;
	}
	for(ll i=k+1;i<=n;i++){
		ans+=(n/i)*(i-k);
		ans+=max(n%i-k+1,0ll);
		}
		printf("%lld\n",ans);
}

Measured memory_bytes: 256
N, K = map(int, input().split())

# if N < K:
#     print(N)
# else:
N = abs(N - (N // K + 1) * K)
if N == 0:
    print(0)
elif abs(N-K) < N:
    print(abs(N-K))
else:
    print(N)

Measured memory_bytes: 3060
#include<functional>
#include<vector>
template<typename T> class SparseTable {
 public:
  explicit SparseTable(const std::vector<T>& v, const std::function<bool(T, T)>& F = std::less<T>()) : V(v), F(F), table_(v.size()) {
    for(auto i = 0; i < v.size(); ++i) table_[0].emplace_back(i);
    for(auto i = 1; pow2(i) <= v.size(); ++i) {
      for(auto j = 0; j + pow2(i) - 1 < v.size(); ++j) {
        auto a = table_[i - 1][j + pow2(i - 1)];
        auto b = table_[i - 1][j];
        table_[i].emplace_back(F(v[a], v[b]) ? a : b);
      }
    }
  }
  T index(int l, int r) const {
    auto d = leftmost(r - l + 1);
    auto a = table_[d][r - pow2(d) + 1];
    auto b = table_[d][l];
    return F(V[a], V[b]) ? a : b;
  }
  T find(int l, int r) const {
    return V[index(l, r)];
  }
 private:
  inline int pow2(int n) const {return 1 << n;}
  inline int leftmost(int n) const {return std::__lg(n);}
  const std::vector<T> V;
  const std::function<bool(T, T)> F;
  std::vector<std::vector<int>> table_;
};

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

const int INF = 1e9;

struct Node {
  pair<int, int> v;
  vector<int> child;
};

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for(auto& p: P) cin >> p;

  vector<int> E(N, INF), O(N, INF);
  for(auto i=0; i<N; i+=2) {
    E[i] = P[i];
    O[i+1] = P[i+1];
  }
  SparseTable<int> even(E), odd(O);

  vector<Node> node;
  function<int(int, int)> dfs = [&](auto l, auto r){
    if(r<=l) return -1;
    int i, j;
    if(l&1) {
      i = odd.index(l, r);
      j = even.index(i+1, r);
    } else {
      i = even.index(l, r);
      j = odd.index(i+1, r);
    }
    Node n;
    n.v = {P[i], P[j]};
    for(auto k: {dfs(l, i-1), dfs(i+1, j-1), dfs(j+1, r)}) n.child.emplace_back(k);
    node.emplace_back(n);
    return int(node.size() - 1);
  };

  auto first = true;
  auto root = dfs(0, N-1);
  priority_queue<int, vector<int>, function<bool(int, int)>> q([&](auto l, auto r) {return node[l].v > node[r].v;});
  q.emplace(root);
  while(!q.empty()) {
    auto i = q.top();
    q.pop();
    cout << (first ? "" : " ") << node[i].v.first << " " << node[i].v.second;
    for(auto j: node[i].child) if(j!=-1) q.emplace(j);
    first = false;
  }
  cout << endl;
}


Measured memory_bytes: 67052
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.System;

class Main {
    public static void main(String[] a) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(r.readLine());
        String[] str = r.readLine().split(" ");

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(str[i]);
        }

        int v, j;
        StringBuilder s;
        show(n, arr);
        for (int i = 1; i < n; i++) {
            v = arr[i];

            j = i - 1;
            while (j >= 0 && arr[j] > v) {
                arr[j+1] = arr[j];
                j--;
            }
            arr[j+1] = v;
            show(n, arr);
        }
    }

    private static void show(int n, int[] arr) {
        StringBuilder s;// ?????? => String
        s = new StringBuilder();
        for (int k = 0; k < n; k++) {
            s.append(arr[k]);
            if (k != n -1) { s.append(" "); }
        }
        System.out.println(s);
    }
}

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

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

    // inputs
    int x;
    cin >> x;

    // output
    cout << (x ? "0\n" : "1\n");
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll N, A, B, C;
  Vl V(3);
  cin >> N >> V[0] >> V[1] >> V[2];
  vector<string> S(N);
  vector<char> Ans;
  REP(i, N)
  cin >> S.at(i);
  REP(j, N) {
    ll L, R;
    L = V.at((int)S.at(j).at(0) - 'A');
    R = V.at((int)S.at(j).at(1) - 'A');
    if (L == 0 && R == 0) {
      cout << "No" << endl;
      return 0;
    } else if (R == 0) {
      L--;
      R++;
      Ans.push_back(S.at(j).at(1));
    } else if (L == 0) {
      L++;
      R--;
      Ans.push_back(S.at(j).at(0));
    } else if (V[0] + V[1] + V[2] == 2 && j != N - 1) {
      if (S.at(j + 1).at(0) == S.at(j).at(0) ||
          S.at(j + 1).at(1) == S.at(j).at(0)) {
        L++;
        R--;
        Ans.push_back(S.at(j).at(0));
      } else {
        if (L >= R) {
          L--;
          R++;
          Ans.push_back(S.at(j).at(1));
        } else {
          L++;
          R--;
          Ans.push_back(S.at(j).at(0));
        }
      }
    } else {
      if (L >= R) {
        L--;
        R++;
        Ans.push_back(S.at(j).at(1));
      } else {
        L++;
        R--;
        Ans.push_back(S.at(j).at(0));
      }
    }
    V.at((int)S.at(j).at(0) - 'A') = L;
    V.at((int)S.at(j).at(1) - 'A') = R;
  }

  cout << "Yes" << endl;
  REP(k, N) cout << Ans.at(k) << endl;
  return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

const i64 mod = 1'000'000'007;

template <class T, T op(T, T)>
class segtree {
public:
    int n, size_;
    vector<T> dat;
    T id_;
    segtree() = default;
    segtree(int size, T id, T initial_value) { init(size, id, initial_value); }
    void init(int size, T id, T initial_value) {
        size_ = size;
        id_ = id;
        n = 1;
        while (n < size) n *= 2;
        dat.assign(2 * n - 1, id);
        for (int i = 0; i < size; ++i) update(i, initial_value);
    }
    int size() const { return size_; }
    void update(int k, T a) {
        k += n - 1;  // leaf
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    T at(int index) { return dat[index + n - 1]; }
    void add(int k, T a) { update(k, at(k) + a); }
    T query(int a, int b) { return query(a, b, 0, 0, n); }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a or b <= l) return id_;
        if (a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return (op(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r)))%mod;
    }
};

i64 sum(i64 a,i64 b){
    return (a+b)%mod;
}

void solve() {
    i64 N;
    string s;
    cin >> N >> s;


    vector<segtree<i64,sum>> dp(N);
    rep(i,0,N){
        dp[i].init(N,0,0);
    }

    for(i64 i=N-1; i>=0; --i) {
        rep(j, 0, N) {
            if (i == N - 1) {
                dp[i].update(j,(j==0)?1:0);
                continue;
            }

            i64 tmp=0;

            if(s[i]=='<'){
                // [j+1, N-i) -> [j,N-i-1)
                tmp+=dp[i+1].query(j,N-i-1);
                tmp%=mod;
            }else{
                // [0, j) -> [0, j)
                tmp+=dp[i+1].query(0,j);
                tmp%=mod;
            }

            dp[i].update(j,tmp);
        }
    }

    cout << dp[0].query(0,N) << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 192512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] ans = new int[n];
			for (int i = 0; i < n; i++) {
				int sum = 0;
				for (int j = 0; j < 5; j++)
					sum += scanner.nextInt();
				ans[i] = sum;
			}
			Arrays.sort(ans);
			System.out.println(ans[n - 1] + " " + ans[0]);
		}
	}
}

Measured memory_bytes: 33672
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if(N==1110||N==1111||N==1112||N==1113||N==1114||N==1115||N==1116||N==1117||N==1118||N==1119||N==2220||N==2221||N==2222||N==2223||N==2224||N==2225||N==2226||N==2227||N==2228||N==2229||N==3330||N==3331||N==3332||N==3333||N==3334||N==3335||N==3336||N==3337||N==3338||N==3339||N==4440||N==4441||N==4442||N==4443||N==4444||N==4445||N==4446||N==4447||N==4448||N==4449||N==5550||N==5551||N==5552||N==5553||N==5554||N==5555||N==5556||N==5557||N==5558||N==5559||N==6660||N==6661||N==6662||N==6663||N==6664||N==6665||N==6666||N==6667||N==6668||N==6669||N==7770||N==7771||N==7772||N==7773||N==7774||N==7775||N==7776||N==7777||N==7778||N==7779||N==8880||N==8881||N==8882||N==8883||N==8884||N==8885||N==8886||N==8887||N==8888||N==8889||N==9990||N==9991||N==9992||N==9993||N==9994||N==9995||N==9996||N==9997||N==9998||N==9999||N==2111||N==3111||N==4111||N==5111||N==6111||N==7111||N==8111||N==9111||N==1222||N==3222||N==4222||N==5222||N==6222||N==7222||N==8222||N==9222||N==1333||N==2333||N==4333||N==5333||N==6333||N==7333||N==8333||N==9333||N==1444||N==2444||N==3444||N==5444||N==6444||N==7444||N==8444||N==9444||N==1555||N==2555||N==3555||N==4555||N==6555||N==7555||N==8555||N==9555||N==1666||N==2666||N==3666||N==4666||N==5666||N==7666||N==8666||N==9666||N==1777||N==2777||N==3777||N==4777||N==5777||N==6777||N==8777||N==9777||N==1888||N==2888||N==3888||N==4888||N==5888||N==6888||N==7888||N==9888||N==1999||N==2999||N==3999||N==4999||N==5999||N==6999||N==7999||N==8999||N==1000||N==2000||N==3000||N==4000||N==5000||N==6000||N==7000||N==8000||N==9000)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  ll n; cin>>n;
  ll i=5;
  ll c=0;
  if(n%2==0){
    while(i<=n){
      c+=(n/i)/2;
      if(n%2!=0&&(n/i)%2!=0)
      c++;
      i*=5;
    }
  }else
  c=0;
  cout<<c<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
 
int main(){

double r;

cin >> r;

cout << setprecision(15) << r*M_PI*r << " " << 2*r*M_PI << endl;


return 0;
}

Measured memory_bytes: 1288
n,m = map(int,input().split())
ans = [int(0) for i in range(m+1)]
for i in range(n):
    k = list(map(int,input().split()))
    for j in range(1,k[0]+1):
        ans[k[j]] += 1
#print(ans)
cnt = 0
for i in range(1,len(ans)):
    if ans[i]==n:
        cnt += 1
print(cnt)

Measured memory_bytes: 9196
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
ll a,b,n;cin>>a>>b>>n;
ll q=min(b-1,n);
int ans=0;
ans=(a*q)/b-(q/b);
cout<<ans<<endl;
}

Measured memory_bytes: 3640
def dist(h,xi, yi, cx, cy):
    return h + abs(xi - cx) + abs(yi - cy)

N = int(input())
P = []
for i in range(N):
    xi, yi, h= map(int, input().split())
    P.append([h, xi, yi])
P.sort(reverse = True)

for i in range(101):
    for j in range(101):
        H = dist(P[0][0], P[0][1], P[0][2],i, j)
        for p in P[1:]:
            if max(H - abs(p[1]-i)-abs(p[2]-j), 0) != p[0]:
                break
        else:
            print(i, j, H)
            break

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll L{0};
	ll R{0};
	ll d{0};
	cin>>L>>R>>d;

	ll count{0};
	for(ll i=L;i<=R;i++){
		if(i%d==0)
			count++;
	}
	cout<<count<<endl;
	
	return 0;
}



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

using namespace std;

int main() {
    int K, X;
    cin >> K >> X;
    int min_X = max({X - K + 1, -1000000});
    int max_X = min({X + K - 1, +1000000});
    for (int i = min_X; i <= max_X; i++) {
        printf("%d", i);
        if (i == max_X) {
            printf("\n");
        } else {
            printf(" ");
        }
    }

    return 0;
}


Measured memory_bytes: 256