akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int arr[n+1];
    for(int i = 1; i <= n; i++)cin >> arr[i];
    vector<int> v;
    int apple[n+1]{0};
    for(int i = n; i > 0; i--){
        int s = 0;
        for(int j = 2; j*i <= n; j++){
            s += apple[i*j];
        }
        // cout << s << " " << arr[i] << "\n";
        if(s%2 != arr[i]%2){
            apple[i] = 1;
            v.push_back(i);
        }
    }
    for(int i = 1; i <= n; i++){
        int s = 0;
        for(int j = 1; j*i <= n; j++){
            s += apple[i*j];
        }
        // cout << s << " " << arr[i] << "\n";
        if(s%2 != arr[i]%2){
            cout << -1;
            return 0;
        }
    }
    cout << v.size() << "\n";
    for(int val : v){
        cout << val << " ";
    }
}


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

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

	ll s = sqrt(n);

	for(ll i=0;;i++){
		if((n%(s-i)) == 0){
			ll t = n/(s-i);
			cout<<t-1+s-i-1; break;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b && b < c)puts("Yes");
	else puts("No");
	ggr
}



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

int main(){
	int N, M;
	cin >> N >> M;
	int X[M];
	rep(i,M) cin >> X[i];

	if (N >= M) {
		cout << 0 << endl;
		return 0;
	}

	sort(X,X+M);
	int Y[M-1];
	rep(i,M-1) Y[i] = X[i+1] - X[i];
	sort(Y,Y+M-1);
	int ans = 0;
	rep(i,M-N) ans += Y[i];

	cout << ans << endl;

return 0;
}


Measured memory_bytes: 4272
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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 dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n, a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    if (b - a < 0) cout << 0 << endl; 
    else if (n == 1) {
        if (a != b) cout << 0 << endl;
        else cout << 1 << endl;
    } else {
        cout << (b - a) * (n - 2) + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect
N, *A = map(int, open(0).read().split())
D = [1]*(N+1)
D[0] = -10**10

for a in A:
    idx = bisect(D, -a)
    D[idx] = min(D[idx], -a)
print(bisect(D, 0)-1)

Measured memory_bytes: 14092
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll a,b,c,d ;
	string s ; cin >> s ;
	a = s.at(0)-'0' ;
	b = s.at(1)-'0' ;
	c = s.at(2)-'0' ;
	d = s.at(3)-'0' ;
	if(a+b+c+d==7){ cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl ; return 0 ;}
	if(a+b+c-d==7){ cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl ; return 0 ;}
	if(a+b-c+d==7){ cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl ; return 0 ;}
	if(a+b-c-d==7){ cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl ; return 0 ;}
	if(a-b+c+d==7){ cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl ; return 0 ;}
	if(a-b+c-d==7){ cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl ; return 0 ;}
	if(a-b-c+d==7){ cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl ; return 0 ;}
	if(a-b-c-d==7){ cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl ; return 0 ;}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int mina = 0;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    if (a.at(mina) > a.at(i)) {
      mina = i;
    }
  }
 
  int num0 = 0;
  while (num0 < n-1) {
    for (int i = 0; i < n; i++) {
      if (i != mina) {
	a.at(i) = a.at(i) % a.at(mina);
	if (a.at(i) == 0) num0++;
	else {
	  mina = i;
	}
      }
    }
  }

  cout << a.at(mina) << endl;
}

Measured memory_bytes: 640
import math
import fractions
import collections
import itertools
import pprint
from collections import deque
N,K=map(int,input().split())
A=list(map(int,input().split()))
plist=[]
mlist=[]
ans=1
p=10**9+7
for i in range(N):
    if A[i]>=0:
        plist.append(A[i])
    else:
        mlist.append(A[i])
if len(plist)==0:
    if K%2==1:
        A.sort(reverse=True)
    else:
        A.sort()
    for i in range(K):
        ans=(ans*A[i])%p
    print(ans%p)
else:
    ans=1
    plist.sort(reverse=True)
    mlist.sort()
    pmap=deque()
    mmap=deque()
    if K%2==1:
        ans=plist[0]%p
        plist.pop(0)
        K=K-1
    #print(plist,mlist)
    for i in range(0,len(plist)-1,2):
        pmap.append(plist[i]*plist[i+1])
    for i in range(0,len(mlist)-1,2):
        mmap.append(mlist[i]*mlist[i+1])
    if len(plist)>0:
        pres=plist[len(plist)-1]
    if len(mlist)>0:
        mres=mlist[len(mlist)-1]
    #print(K)
    mapnum=K//2
    #print(mapnum)
    #print(pmap,mmap,ans)
    for i in range(mapnum):
        if (len(pmap)>0)and(len(mmap)>0):
            pl=pmap.popleft()
            mi=mmap.popleft()
            if pl>mi:
                ans=(ans*pl)%p
                mmap.appendleft(mi)
            else:
                ans=(ans*mi)%p
                pmap.appendleft(pl)
        elif (len(pmap)==0)and(len(mmap)>0):
            mi=mmap.popleft()
            ans = (ans *mi) % p
        elif (len(mmap)==0)and(len(pmap)>0):
            pl=pmap.popleft()
            ans = (ans *pl) % p
        else:
            ans=(ans*pres*mres)%p
    print(ans)



Measured memory_bytes: 112832
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vector<string> s(N);
    vec t(N);
    REP(i, N) cin >> s[i] >> t[i];
    string X; cin >> X;
    REP(i, N) if(s[i] == X){
        int ans = 0;
        FOR(j, i + 1, N) ans += t[j];
        Out(ans);
        break;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  
  // int A=max({N/100,N%100/10,N%100%10});
  //ありうる答え　999 888 777 666 555 444 333 222 111
for(int i =0 ;i <10 ; i++)
  if(111*i>=N &&111*(i-1)<N)
   cout<<i*111;
    
}


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

int main()
{
    int X,b,p,c,Max=0;
    cin >>X;
    
    for(b=1;b<=1000;b++)
    {
        for( p=2;p<=10;p++)
        {
            c=pow(b,p);
            if(c>X)
            {
                break;
            }
            if(c>=Max)
            {
                Max=c;
            }
        }
    }
    cout <<Max<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
#include<set>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)
#define loopj(x,y) for(int j = x;j<(y);j++)


#define nl cout<<"\n";
#define ll long long int
using namespace std;
#define mod  1000000007


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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	ll sum = 0;
	ll count[100001] = {0};
	int a;
	loopi(0, n)
	{
		cin >> a;
		sum += a;
		count[a]++;
	}
	int q;
	cin >> q;

	while (q--)
	{
		ll b, c;
		cin >> b >> c;
		sum -= count[b] * b;
		sum += count[b] * c;


		count[c] += count[b];
		count[b] = 0;

		cout << sum;
		nl;
	}

	return 0;
}

Measured memory_bytes: 4396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
int a,b;
bool c[4];
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

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

    cin>>a>>b;
    for(int i=1;i<=3;i++){
        if(i!=a && i!=b) cout<<i<<newl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100010
#define mod 1000000007
ll a[N], A, B;
int tree[N * 4], f[N];
int t, n, m, ans;
void change(int p, int l, int r, int a, int b) {
    if (l == r) {
        (tree[p] += b) %= mod;
        return;
    }
    int mid = (l + r) / 2;
    if (a <= mid)
        change(p * 2, l, mid, a, b);
    else
        change(p * 2 + 1, mid + 1, r, a, b);
    tree[p] = (tree[p * 2] + tree[p * 2 + 1]) % mod;
}
int query(int p, int l, int r, int a, int b) {
    if (a > b) return 0;
    if (l == a && r == b) return tree[p];
    int mid = (l + r) / 2;
    if (b <= mid)
        return query(p * 2, l, mid, a, b);
    if (a > mid)
        return query(p * 2 + 1, mid + 1, r, a, b);
    return (query(p * 2, l, mid, a, mid) + query(p * 2 + 1, mid + 1, r, mid + 1, b)) % mod;
}
int main() {
    scanf("%d%lld%lld", &n, &A, &B);
    if (A < B) swap(A, B);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    sort(a + 1, a + n + 1);
    a[0] = -A, a[n + 1] = a[n] + A, f[0] = 1;
    change(1, 0, n, 0, f[0]);
    int l = 0, r = 0;
    for (int i = 1; i <= n + 1; i++) {
        while (a[i] - a[r + 1] >= A) r++;
        if (i >= 2 && a[i - 1] - a[i - 2] < B) l = i - 2;
        if (a[i] - a[i - 1] >= A) f[i] = f[i - 1];
        (f[i] += query(1, 0, n, l, min(i - 2, r))) %= mod;
        if (i <= n && a[i + 1] - a[i - 1] >= B) change(1, 0, n, i, f[i]);
    }
    ll ans = (f[n + 1] + mod) % mod;
    printf("%lld\n", ans);
}

Measured memory_bytes: 2432
n = int(input())
b = list(map(int,input().split()))

# In[]
a = []
for i in range(n):
    if i == 0:
        a.append(b[i])
        
    elif i == n-1:
        a.append(b[-1])
    
    else:
        a.append(min(b[i-1],b[i]))
    
print(sum(a))

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

#define mod 1000000007

int dp[3003][3003];

int solve(string &s, int n) {

	dp[n][0] = (s[n-2] == '<' ? 0 : 1);
	dp[n][1] = (s[n-2] == '<' ? 1 : 0);

	for (int len = n-1; len >= 2; len--) {
		
		int total = n - len + 1;
		
		for (int g = 0; g <= total; g++) {

			if (g == 0) {	
				
				dp[len][g] = 0;
				if (s[len - 2] == '<') {
					continue;
				}
				for (int j = 1; j <= total; j++) {
					dp[len][g] += dp[len + 1][total - j];
					dp[len][g] %= mod;
				}

				continue;
			}

			if (s[len - 2] == '<') {
				dp[len][g] = dp[len][g - 1] + dp[len + 1][g - 1];
			}
			else {
				dp[len][g] = mod + dp[len][g - 1] - dp[len + 1][g - 1];
			}

			dp[len][g] %= mod;
			
		}
	}

	int ans = 0;
	for (int g = 0; g < n; g++) {
		ans = (ans + dp[2][g]) % mod;
	}

	return ans;

}
void c_p_c()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
   string s; int n;
   cin >> n >> s;
   cout << solve(s, n);   
}
 
int32_t main()
{
    c_p_c();
    return 0;
}

Measured memory_bytes: 31052
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    string S;
    cin >> S;

    vector<int> num(S.size());
    for (int i = 0; i < S.size(); i++) {
        num[i] = 0;
    }
    // 
    //コンテスト後 
    // 

    bool RL = true;
    int cnt = 0;

    for (int i = 0; i < S.size(); i++) {
        if(RL){
            if(S[i] == 'L'){

                num[i-1] += (cnt+1) / 2;
                num[i] += cnt/2;
                RL = !RL;
                cnt = 1;
            }else {
                cnt ++;
            }
        }
        else{
            if(S[i] == 'R'){

                num[i-cnt] += (cnt+1) / 2;
                num[i-1-cnt] += cnt/2;
                RL = !RL;
                cnt = 1;
            }else {
                cnt ++;
            }
        }

        if(i == S.size()-1) {            
            num[i-cnt] += cnt / 2;
            num[i-(cnt-1)] += (cnt+1) / 2;
        }
    }

    REP(i, S.size())
        cout << num[i] << " ";


    return 0;
    


    ///////コンテスト中
    // int flag = 0;

    // int tmp = 0, sa = 0;

    // for (int i = 1; i < S.size(); i++) {

    //     if(flag == 0) {
    //         if(S[i] == 'L'){
    //             sa = i - tmp;
    //             num[i-1] += 1 + (sa-1)/2;
    //             if(sa != 1 && sa % 2 == 1)
    //                 num[i-1] += 1;
    //             num[i] += sa/2;
    //             tmp = i;

    //             flag = 1;   
    //         }
    //     }

    //     if(flag == 1 || i == S.size()-1) {
    //         if(S[i] == 'R' || i == S.size()-1){
    //             sa = i - tmp - 1;
    //             num[tmp] += 1 + (sa-1)/2;
    //             if(sa != 1 && sa % 2 == 1)
    //                 num[tmp] += 1;
    //             num[tmp-1] += (sa+1)/2;
    //             tmp = i;

    //             flag = 0;
    //         }
    //     }

    // }

    REP(i, S.size())
        cout << num[i] << " ";
    

}

Measured memory_bytes: 1024
n,a,b = (int(x) for x in input().split())
c = b - a

if c%2==0:
    print(c//2)
else:
    d = a + (b-a-1)//2
    e = n - b + 1 + (b-a-1)//2
    print(min(b-1,n-a,d,e))


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

long int A, B;

long int gcd(long int a, long int b)
{
    while (b)
    {
        long int m = a % b;
        a = b;
        b = m;
    }
    return a;
}

bool IsPrime(long int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (long int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main()
{

    cin >> A >> B;

    // vector<long int> C;

    // long int head = 1, tail = target;

    long int target = gcd(A, B);
    long int count = 1;
    for (long int i = 2; i < sqrt(target); i++)
    {
        if (target % i == 0)
        {
            while (target % i == 0)
                target /= i;
            count++;
        }
    }

    if (target != 1)
        count++;

    // while (head < tail)
    // {

    //     if (target % head == 0)
    //     {
    //         if (IsPrime(head))
    //         {
    //             C.push_back(head);
    //         }
    //         tail = target / head;
    //         if (head != tail && IsPrime(tail))
    //         {
    //             C.push_back(tail);
    //         }
    //     }
    //     head++;
    // }

    cout
        << count << endl;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string S;
    cin>>S;
    int K;cin>>K;
    rep(i,S.size()){
         int t=('z'+1-S[i])%26;
         if(t>K)continue;
         S[i]='a';
         K-=t;
    }
    int tmp=S[S.size()-1]-'a';
    S[S.size()-1]=(tmp+K)%26+'a';
    cout<<S<<endl;
    return 0;
}


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

int main() {
	int n, a[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	vector<int> v;
	v.push_back(0);
	v.push_back(0);
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			v.push_back(a[i]);
			i++;
		}
	}
	cout << (long long)v[v.size() - 2] * v[v.size() - 1] << endl;
	return 0;
}


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

int gcd(int a,int b){return b==0 ? a : gcd(b,a%b);}

bool dfs(int v,vector<vector<int>> &g,
    vector<int> &match,vector<bool> &used){

    used[v] = true;
    for(int u : g[v]){
        int w = match[u];
        if(w<0 || (!used[w] && dfs(w,g,match,used))){
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}
 
int bipartite_matching(vector<vector<int>> &g){
    int res = 0;
    int V = g.size();
    vector<int> match(V, -INF);
    rep(v,V){
        if(match[v] < 0){
            vector<bool> used(V, false);
            if(dfs(v,g,match,used)){
                res++;
            }
        }
    }
    return res;
}

int main(void){
    int m,n;
    while(cin>>m>>n, n|m){
        vector<int> b(m),r(n);
        rep(i,m) cin>>b[i];
        rep(i,n) cin>>r[i];

        vector<vector<int>> g(m+n);
        rep(i,m)rep(j,n){
            if(gcd(b[i],r[j]) > 1){
                g[i].push_back(m+j);
                g[m+j].push_back(i);
            }
        }
        cout<<bipartite_matching(g)<<endl;
    }
    return 0;
}



Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


ll a[1100],b[1100];
vector<ll> dp(11000,INF);
main(){
  ll h,n,ans=0;
  cin>>h>>n;
  rep(i,0,n)cin>>a[i]>>b[i];
  dp[h]=0;
  rep(i,0,n){
    irep(j,h,0){
      dp[max(j-a[i],(ll)0)]=min(dp[max(j-a[i],(ll)0)],dp[j]+b[i]);
    }
  }
  cout<<dp[0];
}


Measured memory_bytes: 384
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)


p,q,r = inm()
a = [p+q,q+r,r+p]
print(min(a))


Measured memory_bytes: 38384
n = int(input())
papers = list(map(int, input().split()))

evens = list()
for paper in papers:
    if paper % 2 == 0:
        evens.append(paper)

approveds = list()
for even in evens:
    if even % 3 == 0:
        approveds.append(even)
    elif even % 5 == 0:
        approveds.append(even)

if set(evens) == set(approveds):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e5;
int A[N+7], dp[N+7], n;
const int inf=1e9;

int solve(int i) {
	if(i==n) return 0;
	if(i>n) return inf;
	if(dp[i]!=-1) return dp[i];
	int a = solve(i+1) + abs(A[i]-A[i+1]);
	int b = solve(i+2) + abs(A[i]-A[i+2]);
	return dp[i] = min(a, b);
}
int main(){
	ios_base::sync_with_stdio(0);
	int a,b,T,cas=0;
	cin>>n;
	for(int i=1;i<=n;++i) cin>>A[i];
	fill(dp, dp+n+1, -1);
	int res = solve(1);
	cout<<res<<endl;
	return 0;
}

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

void find_node(int node,vector<int> &seen,vector<set<int>> &l){
  if(!seen.at(node)){//未探索ノードならば
    seen.at(node) = 1;
    for(auto next_node : l.at(node)){
      find_node(next_node,seen,l);
    }
  } 
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<set<int>> l(n+1);//隣接リスト
  vector<int> A(m),B(m);
  for(int i = 0; i < m; i++){
    int a,b;
    cin >> a >> b;
    A.at(i) = a;
    B.at(i) = b;
    l.at(a).insert(b);
    l.at(b).insert(a);
  }
  int ans = 0;
  for(int i = 0; i < m; i++){
    //i本目の橋を抜く。
    int ea=A.at(i),eb=B.at(i);
    l.at(ea).erase(eb);
    l.at(eb).erase(ea);
    
    vector<int> seen(n+1,0);//辿りつけたら1
    find_node(1,seen,l);

    //seenが全て1だったらans++;
    int flag = 0;
    for(int i = 1; i <= n; i++){
      if(seen.at(i)==0){
        flag = 1;
        break;
      }
    }
      
    l.at(ea).insert(eb);
    l.at(eb).insert(ea);

    if(!flag)continue;
    else ans++;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#define int long long
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

void solve() {
   int n;
   cin>>n;
   int arr[n];
   for(int i=0;i<n;++i) 
   {
       cin>>arr[i];
       //temp[i]=arr[i];
   }
   int maxx=INT_MIN;
//    for(int i=0;i<n-1;++i)
//    {
//        if(arr[i]>arr[i+1])
//        {
//            arr[i]--;
//        }
       
//    }
   for(int i=0;i<n;++i)
   {
      if(arr[i]>=maxx)
      {
          maxx=arr[i];
      }
      else
      {
          if(maxx-arr[i]!=1)
          {
              cout<<"No";
              return;
          }
          
      }
      //cout<<maxx<<" ";
      
   }
   cout<<"Yes"<<"\n";
    
}

int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //cout<<"Hello World"<<"\n";
    //int t;cin>>t;while(t--)
    solve();
   
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    int p[n];
    for (auto &x: p) {
        cin >> x;
    }
    sort(p, p + n);
    int res = 0;
    for (int i = 0; i < k; i ++) {
        res += p[i];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;


int main()
{
    int H, W;
    std::cin >> H >> W;
    std::vector<std::string> tiles(H);
    for (auto i=0; i<H; ++i)
        std::cin >> tiles[i];

    auto ToNodeId = [](int x, int y, int width) { return y * width + x; };
    std::vector<std::vector<int>> connections(H * W);

    int wallCount = 0;
    for (auto i=0; i<H; ++i)
    {
        for (auto j=0; j<W; ++j)
        {
            if (tiles[i][j] == '#')
            {
                wallCount++;
                continue;
            }

            auto from = ToNodeId(j, i, W);
            if (0 < i && tiles[i - 1][j] == '.')
                connections[from].emplace_back(ToNodeId(j, i - 1, W));
            if (i < H - 1 && tiles[i + 1][j] == '.')
                connections[from].emplace_back(ToNodeId(j, i + 1, W));

            if (0 < j && tiles[i][j - 1] == '.')
                connections[from].emplace_back(ToNodeId(j - 1, i, W));
            if (j < W - 1 && tiles[i][j + 1] == '.')
                connections[from].emplace_back(ToNodeId(j + 1, i , W));
        }
    }

    std::vector<int> distanceTable(H * W, -1);
    std::queue<int> queue;
    queue.push(0);
    distanceTable[0] = 0;
    while (!queue.empty())
    {
        auto top = queue.front();
        queue.pop();

        for (auto& c : connections[top])
        {
            if (distanceTable[c] != -1)
                continue;

            distanceTable[c] = distanceTable[top] + 1;
            queue.push(c);
        }
    }

    auto goal = H * W - 1;
    if (distanceTable[goal] == -1)
        std::cout << "-1" << std::endl;
    else
    {
        auto result = H * W - wallCount - (distanceTable[goal] + 1);
        std::cout << result << std::endl;
    }
}


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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N + 1), B(N);
  for (int i = 0; i < N + 1; i++) cin >> A.at(i);
  for (int i = 0; i < N ; i++) cin >> B.at(i);

  long long ans = 0;

  for (int i = 0; i < N; i++) {
    ans += min(A.at(i), B.at(i));
    B.at(i) = max(0, B.at(i) - A.at(i));
    ans += min(A.at(i + 1), B.at(i));
    A.at(i + 1) = max(0, A.at(i + 1) - B.at(i));
  }

  cout << ans << "\n";
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = acos(-1.0); //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

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

ll parallelogram(ll a, ll b) { //縦、横
    if (a < b) swap(a, b);
    ll times = a / b;
    if (a % b == 0) return 2 * b * times - b;
    ll ra = a - b * times;
    return parallelogram(b, ra) + 2 * b * times;
}

int main() {
    ll n, x;
    cin >> n >> x;
    cout << n + parallelogram(n - x, x) << endl;

    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;

int isvisted=0;
int allvisted;
int ans=0;
int N,M;
bool graph[10][10];

int cnt=0;
void dfs(int v){
    if(isvisted == allvisted){
        ans++;
        return;
    }
    repeat(i, N){
        if((isvisted>>i)&1 || !graph[v][i])
            continue;
        isvisted |= 1<<i;
        dfs(i);
        isvisted -= 1<<i;
    }
    return;
}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    cin >> N >> M;
    allvisted = (1<<N) - 1;
    repeat(i,N){
        repeat(j,N){
            graph[i][j] = false;
        }
    }
    
    repeat(i, M){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        graph[a][b] = true;
        graph[b][a] = true;
    }
    isvisted = 1;
    ans = 0;
    dfs(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;

  ll ans=0;
  if(A+B<2*C){
    ans=X*A+Y*B;
  }
  else{
    if(X<Y){
      if(B<2*C) ans=2*X*C+(Y-X)*B;
      else ans=2*Y*C;
    }
    else{
      if(A<2*C) ans=2*Y*C+(X-Y)*A;
      else ans=2*X*C;
    }
  }

  cout << ans << endl;
  
  return 0;
}


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

int		main(void)
{
	int N;
	int num;

	cin >> N;
	num = N % 10;
	if (num == 2 || num == 4 || num == 5 || num == 7 || num == 9)
	{
		cout << "hon" << endl;
	}
	else if (num == 0 || num == 1 || num == 6 || num == 8)
	{
		cout << "pon" << endl;
	}
	else
	{
		cout << "bon" << endl;
	}

	return (0);
}

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

void prev_make(vector<vector<int>> &v, vector<int> &prev, int now = 0, int par = -1){
	for(int i:v[now]) if(i != par){
		prev[i] = now;
		prev_make(v, prev, i, now);
	}
}

void paint(vector<vector<int>> &v, vector<int> &board, int now, int par, int color){
	if(board[now] != -1) return;
	board[now] = color;
	for(int i:v[now]) paint(v, board, i, now, color);
}

int main(){
	int n;
	cin >> n;
	vector<vector<int>> v(n);
	for(int i = 0; i < n - 1; i++){
		int from, to;
		cin >> from >> to;
		from--; to--;
		v[from].emplace_back(to);
		v[to].emplace_back(from);
	}
	vector<int> prev(n);
	prev_make(v, prev);
	vector<int> w;
	for(int i = prev[n - 1]; i; i = prev[i]) w.emplace_back(i);
	reverse(w.begin(), w.end());
	vector<int> board(n, -1);
	board[0] = 0;
	board[n - 1] = 1;
	for(int i = 0; i < (w.size() + 1) / 2; i++) board[w[i]] = 0;
	for(int i = (w.size() + 1) / 2; i < w.size(); i++) board[w[i]] = 1;
	for(int i = 0; i < n; i++) if(board[i] != -1) for(int j:v[i]) paint(v, board, j, i, board[i]);
	int p1 = count(board.begin(), board.end(), 0), p2 = n - p1;
	cout << (p1 <= p2 ? "Snuke" : "Fennec") << endl;
}

Measured memory_bytes: 13304
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int X = Cin();
        int A = Cin();
        int B = Cin();
        Console.WriteLine((X - A) % B);
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 13140
def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(m)]
    res = [0] * n
    for i in ab:
        res[i[0] - 1] += 1
        res[i[1] - 1] += 1
    for i in res:
        print(i)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;



void Main(){
    ll N, R;
    sll(N);
    sll(R);
    if(N>=10){
        cout << R <<endl;
    }else{
        cout << R + 100 * (10 - N) <<endl;
    }
}

int main(){
    Main();
    // string S = "ksdfjl";
    // char v = S[3];
    // S[3] = 'a';
    // cout << S <<endl;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,pair<int,int>> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
int main(){
    int n,k;cin>>n>>k;
    if(n%k){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int r;
    cin>>r;
    if(r<1200)cout<<"ABC"<<endl;
    else if(r>=2800)cout<<"AGC"<<endl;
    else cout<<"ARC"<<endl;
}

   


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int n,m;
char mp[1010][1010];
int dp[1010][1010];
int fl[2][2]={{-1,0},{0,-1}};
bool book[101][101];
void dfs(int x,int y,int a,int b)
{
    if(book[x][y]||mp[x][y]!='#')return;
    book[x][y]=1;
    dp[a][b]=min(dp[a][b],dp[x-1][y]+1);
    dp[a][b]=min(dp[a][b],dp[x][y-1]+1);
    dfs(x+fl[0][0],y+fl[0][1],a,b);
    dfs(x+fl[1][0],y+fl[1][1],a,b);
}
void solve(int x,int y)
{
    memset(book,0,sizeof(book));
    dfs(x,y,x,y);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)scanf("%s",mp[i]+1);
    memset(dp,0x3f,sizeof(dp));dp[0][1]=dp[1][0]=0;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
        {
            if(mp[i][j]=='.')
            {
                dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
//                cout<<"i: "<<i<<" j: "<<j<<" dp: "<<dp[i][j]<<endl;
                continue;
            }
            solve(i,j);
//                cout<<"i: "<<i<<" j: "<<j<<" dp: "<<dp[i][j]<<endl;
        }
    printf("%d\n",dp[n][m]);
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll a, b, c;
	cin >> a >> b >> c;
	
	vector<ll> v;
	v.push_back(c);
	
	for(int i = 0; i < 10; i++){
		v.push_back(v.back() * a - b);
		cout << v.back() << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1010;
const ll mod=1e9+7;


const int MAX = 500000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<long long, int> prime_factor(long long n){
  map<long long,int> ret;
  for(ll i=2; i*i<=n; i++){ while(n%i==0){ ret[i]++; n /= i; } }
  if(n!=1){ ret[n]=1; }
  return ret;
}

int main(){
  int n,m; cin >> n >> m;
  map<ll,int> ret = prime_factor(m);	//soinsu-bunkai
  
  
  COMinit();							//	combination ready
  ll ans=1;
  for(auto x : ret){					//x.first:sosuu  x.second:ruizyo
      ans *= COM(x.S+n-1,n-1);
      ans %= mod;
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11904
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>
#include<math.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nBuf,int N){
    char *buf,*ptr;

    buf=(char*)malloc(nBuf*sizeof(char));
    my_gets(buf,nBuf,stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}


#define MIN(a,b)  ( ((a)<(b))?(a):(b) )

typedef struct{
    int64_t A,B;
} TaskPair_t;

TaskPair_t Task[200000];

int CompareTask(const void* pTask1, const void *pTask2){
    TaskPair_t Task1=*((TaskPair_t*)pTask1),Task2=*((TaskPair_t*)pTask2);

    if(Task1.B > Task2.B)
        return 1;
    else if(Task1.B == Task2.B)
        return 0;
    else
        return -1;
}

int main(){
    int N;
    int64_t StTime,EdTime;

    scanf("%d%*c",&N);
    for(int i=0;i<N;i++){
        scanf("%ld %ld%*c", &(Task[i].A), &(Task[i].B));
    }
    qsort(Task, N, sizeof(TaskPair_t), CompareTask);
    
    EdTime=Task[N-1].B;                      //ギリギリに終わる時間設定
    for(int i=N-1;i>=0;i--){
        StTime = EdTime - Task[i].A;         //間に合う一番遅い時間
        //printf("%lld - %lld\n",StTime,EdTime);
        if(i>0){
            EdTime = MIN(StTime,Task[i-1].B);
        }
    }
    if(StTime >= 0){
        puts("Yes");
    }
    else
    {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 6396