akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int n,m;
int G[50][50];
bool seen[50];

void dfs(int v){
  seen[v] = true;
  rep(nv, n){
    if(seen[nv] || !G[v][nv]) continue;
    dfs(nv);
  }
}

int main(){
  cin >> n >> m;
  vi a(m),b(m);
  rep(i, m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    G[a[i]][b[i]]++;
    G[b[i]][a[i]]++;
  }
  int ans = 0;
  rep(i, m){
    G[a[i]][b[i]]--; G[b[i]][a[i]]--;
    memset(seen,false,sizeof(seen));

    dfs(0);

    bool bridge = false;
    rep(v, n) if(!seen[v]) bridge = true;

    if(bridge) ans++;
    G[a[i]][b[i]]++; G[b[i]][a[i]]++;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
const int INF = 1e9;
typedef long long ll;
using namespace std;
int main() {
    ll n;
    cin >> n;
    ll a[n];
    ll zero;
    ll sum = 0;
    bool flag = false;
    ll nega_min = INF;
    REP(i, n) {
        cin >> a[i];
        if(a[i] < 0) zero++;
        if(a[i] == 0) flag = true;
        a[i] = abs(a[i]);
    }
    REP(i, n) {
        nega_min = min(nega_min, a[i]);
        sum += a[i];
    }
    if(!flag && zero % 2 != 0) {
        sum -= (nega_min * 2); 
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int x, y;
    cin >> x >> y;
    if (x == abs(y)) {
        cout << 1 << endl;
    } else {
        int count = 0;
        if (abs(x) > abs(y)) {
            if (x > 0) {
                x = x * -1;
                count += 1;
            }

            while (abs(x) != abs(y)) {
                x += 1;
                count += 1;
            }

            if (x != y) {
                count += 1;
            }
            cout << count << endl;
        } else {
            int count = 0;
            if (0 > x) {
                x = x * -1;
                count += 1;
            }

            while (abs(x) != abs(y)) {
                x += 1;
                count += 1;
            }

            if (x != y) {
                count += 1;
            }
            cout << count << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    a[0] = -1;
    for(int i = n; i >= 1; i--) {
        if(a[i] == i) {
            ans++;
            swap(a[i], a[i - 1]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
s = input()
count = 0
for i in range(0,len(s)):
    if i%2 == 0:
        if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
            count += 1
    else:
        if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
            count += 1

if count == len(s):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
from itertools import groupby

n,k = map(int,input().split())
s = input()

grouped = groupby(s)

res = []

if s[0] == '0':
	res.append(0)

for l,v in grouped:
	res.append( (len(list(v))) )

if s[len(s)-1] == '0':
	res.append(0)

now = 0
ans = 0
for i in range(min(len(res),2*k+1)):
	now += res[i]

ans = max(ans,now)

for i in range(2*k+1,len(res),2):
	now -= res[i-2*k-1]
	now -= res[i-2*k]

	now += res[i]
	now += res[i+1]

	ans = max(ans,now)

print(ans)



Measured memory_bytes: 9836
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] l = new long[n];
		int count = 0;
		for(int i = 0; i < n; i++) {
			l[i] = sc.nextLong();
		}
		for(int i = 0; i < n-2; i++) {
			long temp1 = l[i];
			for(int j = i+1; j< n-1; j++) {
				long temp2 = l[j];
				for(int k = j+1; k < n; k++) {
					long temp3 = l[k];
					if(temp1+temp2 > temp3&&
							temp1+temp3>temp2&&
							temp2+temp3>temp1) {
						if(temp1 != temp2 &&temp1 != temp3  &&
								temp2 != temp3) {
							count++;
						}
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 36784
#include<cstdio>
using namespace std;
char s[10010];
int main()
{
	int n;
	double x,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lf",&x);
		ans+=1.0/x;
	}
	printf("%.8lf\n",1.0/ans);
}

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

enum SegtreeType{
	CUSTOM,
	RAQ_RMQ,
	RAQ_RSQ,
	RUQ_RMQ,
	RUQ_RSQ,
	RMQ_RMQ
};
template<SegtreeType ty,class T>
class LazySegtree{
	int n;
	vector<T>dat,lazy;
	T INIT;
	T E0,E1;
	function<T(T,T,int)>F0;
	function<T(T,T)>F1,F2;
public:
	LazySegtree(int n_,T INIT,T E0,T E1
	,function<T(T,T,int)>F0,function<T(T,T)>F1,function<T(T,T)>F2):
		INIT(INIT),E0(E0),E1(E1),F0(F0),F1(F1),F2(F2){
		n=1;while(n<n_)n<<=1;
		dat=lazy=vector<T>(2*n);
		for(int i=0;i<2*n-1;i++){
			dat[i]=INIT;
			lazy[i]=E1;
		}
	}
	LazySegtree(int n_){
		switch(ty){
		case RAQ_RMQ:
			INIT=0;
			E0=numeric_limits<T>::max();
			E1=0;
			F0=[](T a,T b,int s){return a+b;};
			F1=[](T a,T b){return a+b;};
			F2=[](T a,T b){return min(a,b);};
			break;
		case RAQ_RSQ:
			INIT=0;
			E0=0;
			E1=0;
			F0=[](T a,T b,int s){return a+b*s;};
			F1=[](T a,T b){return a+b;};
			F2=[](T a,T b){return a+b;};
			break;
		case RUQ_RMQ:
			INIT=numeric_limits<T>::max();
			E0=numeric_limits<T>::max();
			E1=numeric_limits<T>::min();
			F0=[](T a,T b,int s){return b;};
			F1=[](T a,T b){return b;};
			F2=[](T a,T b){return min(a,b);};
			break;
		case RUQ_RSQ:
			INIT=0;
			E0=0;
			E1=numeric_limits<T>::min();
			F0=[](T a,T b,int s){return b*s;};
			F1=[](T a,T b){return b;};
			F2=[](T a,T b){return a+b;};
			break;
		case RMQ_RMQ:
			INIT=numeric_limits<T>::max();
			E0=numeric_limits<T>::max();
			E1=numeric_limits<T>::max();
			F0=[](T a,T b,int s){return min(a,b);};
			F1=[](T a,T b){return min(a,b);};
			F2=[](T a,T b){return min(a,b);};
			break;
		}
		n=1;while(n<n_)n<<=1;
		dat=lazy=vector<T>(2*n);
		for(int i=0;i<2*n-1;i++){
			dat[i]=INIT;
			lazy[i]=E1;
		}
	}
	inline void push(int k,int s){
		if(lazy[k]==E1)return;
		dat[k]=F0(dat[k],lazy[k],s);
		if(k<n-1){
			lazy[k*2+1]=F1(lazy[k*2+1],lazy[k]);
			lazy[k*2+2]=F1(lazy[k*2+2],lazy[k]);
		}
		lazy[k]=E1;
	}
	inline void upnode(int k){
		dat[k]=F2(dat[k*2+1],dat[k*2+2]);
	}
	inline void update(int a,int b,T x,int k,int l,int r){
		push(k,r-l);
		if(r<=a||b<=l)return;
		if(a<=l&&r<=b){
			lazy[k]=F1(lazy[k],x);
			push(k,r-l);
			return;
		}
		update(a,b,x,k*2+1,l,(l+r)/2);
		update(a,b,x,k*2+2,(l+r)/2,r);
		upnode(k);
	}
	inline T query(int a,int b,int k,int l,int r){
		push(k,r-l);
		if(b<=l||r<=a)return E0;
		if(a<=l&&r<=b)return dat[k];
		T lb=query(a,b,k*2+1,l,(l+r)/2);
		T rb=query(a,b,k*2+2,(l+r)/2,r);
		upnode(k);
		return F2(lb,rb);
	}
	inline void update(int a,int b,T x){
		update(a,b,x,0,0,n);
	}
	inline void update(int a,T x){
		update(a,a+1,x);
	}
	inline T query(int a,int b){
		return query(a,b,0,0,n);
	}
	inline T query(int a){
		return query(a,a+1);
	}
};

int main(){
	int n,q;cin>>n>>q;
	LazySegtree<RUQ_RSQ,int>seg(n);
	rep(i,q){
		int ty;scanf("%d",&ty);
		if(ty==0){
			int l,r,x;scanf("%d%d%d",&l,&r,&x);r++;
			seg.update(l,r,x);
		}
		else{
			int l,r;scanf("%d%d",&l,&r);r++;
			printf("%d\n",seg.query(l,r));
		}
	}
}


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

int main() {
  string s;
  cin >> s;
  ll now=0;
  rep(i,s.length()){
      int x=s[i]-'0';
      now+=x;
  }
  if(now%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int n,t,m[1000],l[1000],k[1000];

bool check(int x){
  int c[1001]={},used[1000]={},cnt=n;
  for(int i=0;i<t;i++){
    x+=c[i];
    for(int j=0;j<n&&x;j++){
      if(used[j])continue;
      if(i+m[j]>t)return 0;
      if(i%(l[j]+k[j])<=l[j])c[i+m[j]]++,cnt--,used[j]=1,x--;
    }
  }
  return !cnt;
}

int main(){
  while(scanf("%d%d",&n,&t),n){
    for(int i=0;i<n;i++)scanf("%d%d%d",&m[i],&l[i],&k[i]);
    int ans=0;
    for(int i=1;i<=n&&!ans;i++)if(check(i))ans=i;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
int n, k; 
	scanf("%d %d", &n, &k );
	vector<int> arr(n), dp(n, INT_MAX);
	for(int i=0; i<n; ++i) scanf("%d", &arr[i]);
	
	dp[0]=0;
	
	for(int i=1; i<n; ++i){
		for(int j= max(0,i-k ); j<i; ++j ){
			dp[i] = min(dp[i], dp[j] + abs(arr[j]- arr[i]));
			
		}
	}
	printf("%d\n", dp[n-1]);

	return 0;
}


Measured memory_bytes: 4008
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int w,h;
    int x,y;
    cin>>w>>h>>x>>y;
    double ww=w,hh=h;
    cout<<(ww*hh/2)<<sp<<(x*2==w&&y*2==h)<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const ll mod = 998244353;

int main() {
    ll n; cin >> n;
    Vl d(n);
    rep(i, 0, n) cin >> d[i];
    if(d[0] != 0){
        cout << 0 << endl;
        return 0;
    }

    map<ll, ll> cnt;
    rep(i, 0, n) cnt[d[i]]++;

    ll si = sz(cnt);
    rep(i, 0, si) if(cnt[i] == 0) {co(0); return 0;}
    if(cnt[0] != 1) {co(0); return 0;}
    if(d[0] != 0) {co(0); return 0;}

    ll ans = 1;
    rep(i, 0, si){
        // ans *= RepeatSquaring(cnt[i], cnt[i+1], mod);
        ans *= modpow(cnt[i], cnt[i+1], mod);
        ans %= mod;
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<atcoder/fenwicktree>
using namespace std;
using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n,q; cin >> n >> q;
    fenwick_tree<ll> fw(n);
    rep(i,n){
        int a; cin >> a;
        fw.add(i,a);
    }
    rep(i,q){
        int t; cin >> t;
        if(t == 0){
            int p,x; cin >> p >> x;
            fw.add(p,x);
        }
        else{
            int l,r; cin >> l >> r;
            cout << fw.sum(l,r) << endl;
        }
    }
}



Measured memory_bytes: 8220
// Written By NewbieChd
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

const int maxN = 1000003;
char s[maxN], t[maxN];
queue<int> que;

int main() {
    int n, up, dn, ans = 0;
    scanf("%d%s%s", &n, s, t);
    if (!strcmp(s, t)) {
        printf("0\n");
        return 0;
    }
    
    up = dn = n - 1;
    while (~dn) {
        while (dn && t[dn - 1] == t[dn])
            --dn;
        while (~up && (up > dn || s[up] != t[dn]))
            --up;
        if (up < 0) {
            printf("-1\n");
            return 0;
        }
        while (!que.empty() && (int)(que.front() - que.size()) >= dn)
            que.pop();
        if (up != dn)
            que.push(up);
        ans = max(ans, (int)que.size());
        --dn;
    }
    
    printf("%d\n", ans + 1);
    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,P>;

int inf = 1000000000;
int h,w;

int dijkstra(vector<vector<string>> field, P s, P g) {
  priority_queue<PP, vector<PP>, greater<PP>> q;
  q.push(PP(0,s));
  vector<vector<int>> dist(h,vector<int>(w,inf));
  dist[s.fi][s.se] = 0;

  while(!q.empty()) {
    PP p = q.top(); q.pop();
    P v = p.se;
    if (dist[v.fi][v.se] < p.fi) continue;
    rep(nh,v.fi-2,v.fi+3) rep(nw,v.se-2,v.se+3) {
      if (nh < 0 || nh >= h || nw < 0 || nw >= w) continue;
      if (v.fi == nh && v.se == nw) continue;
      if (field[nh][nw] == "#") continue;
      if ((v.fi == nh && abs(v.se-nw) == 1) || (v.se == nw && abs(v.fi-nh) == 1)) {
        if (dist[nh][nw] > dist[v.fi][v.se]) {
          dist[nh][nw] = dist[v.fi][v.se];
          q.push(PP(dist[nh][nw],P(nh,nw)));
        }
      } else {
        if (dist[nh][nw] > dist[v.fi][v.se] + 1) {
          dist[nh][nw] = dist[v.fi][v.se] + 1;
          q.push(PP(dist[nh][nw],P(nh,nw)));
        }
      }
    }
  }
  return dist[g.fi][g.se];
}

int main() {
  int ch,cw,dh,dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--; cw--; dh--; dw--;
  vector<vector<string>> field(h,vector<string>(w));
  rep(i,0,h) {
    string s;
    cin >> s;
    rep(j,0,w) field[i][j] = s.substr(j,1);
  }
  int ans = dijkstra(field, P(ch,cw), P(dh,dw));
  if (ans == inf) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 69984
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    if (n % 1000 == 0) {
        cout << 0 << newl;
    } else {
        cout << 1000 - (n % 1000) << newl;
    }
}

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

const long long MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    int dp[n + 1][m + 1], s[n], t[m];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    for (int i = 0; i <= m; i++) {
        dp[0][i] = 1;
    }
    for (int i = 1; i <= n; i++) {
        dp[i][0] = 1;
        for (int j = 1; j <= m; j++) {
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            if (s[i - 1] != t[j - 1]) {
                dp[i][j] = (dp[i][j] - dp[i - 1][j - 1]) % MOD;
            }
        }
    }
    cout << (dp[n][m] + MOD) % MOD;
    return 0;
}


Measured memory_bytes: 15872
# inp.readline()
# int(inp.readline())
# out.write()
# raw_input()
# map(int,raw_input().split())
# map(int,inp.readline().split())
# for _ in xrange(input()):
# print "Case #"+str(_+1)+": "+ 
if __name__ == "__main__":
    from sys import stdin as inp, stdout as out,setrecursionlimit as srl
    from collections import Counter,defaultdict,deque
    from heapq import *
    def upd(idx,v):
      while idx<len(b):
        b[idx]=(b[idx]+v)%mod
        idx+=(idx&-idx)
    def acc(idx):
        s=0
        while idx>0:
            s=(s+b[idx])%mod
            idx-=(idx&-idx)
        return s
    for _ in xrange(1):
        n,k=map(int,inp.readline().split())
        a=[map(int,inp.readline().split()) for i in xrange(k)]
        b=[0]*(n+1)
        mod=998244353
        upd(1,1)
        for i in xrange(2,n+1):
          for l,r in a:
            upd(i,acc(max(0,i-l))-acc(max(0,i-r-1))%mod)
        print (acc(n)-acc(n-1))%mod

Measured memory_bytes: 80604
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	if (a <= c && c <= b)
	{
		println("Yes");
	}
	else
	{
		println("No");
	}
}


Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>











ll x,y,res;



void solve()
{
	cin>>x>>y;
	res=0;
	for(;;)
	{
		if(x>y)break;
		res++;
		x*=2;
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()ss		
#define debug system("pause")				//デバッグ用



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

	int k, s;
	cin >> k >> s;

	int c = 0;

	for (int i = 0; i <= k; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			if (i + j > s)
			{
				break;
			}
			if (s - i - j <= k)
			{
				c++;
			}
		}
	}

	cout << c << endl;

}

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

int main() {
  int n, m, x, b = 0, c = 0;
  cin >> n >> m >> x;
  vector<int> a(m);
  rep(i, m) cin >> a[i];
  rep(i, m){
    if(a[i] > x) ++b;
    else ++c;
  }
  cout << min(b, c) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);


		char chA ='a';
		char chA1 ='A';
		char[] arrayAlpha = new char[26];
		char[] arrayAlpha1 = new char[26];


		int[] arrayCount = new int[26];

		for(int i = 0; i <= ('z'-'a'); i++) {
			//System.out.println(chA++);
			arrayAlpha[i] = chA;
			arrayAlpha1[i] = chA1;

			chA1++;
			chA++;
		//	System.out.println("arrayAlpha[i]"+arrayAlpha[i]);
		}

		String strKarioki ="";
		char chKarioki1 =' ';

		while(sc.hasNext()) {

			String strInput = sc.nextLine();

			for(int i = 0; i < strInput.length(); i++) {

				//??\?????????????????????????§£????????????
				strKarioki = strInput.substring(i,i+1);
				//String??????char??????????????????
				chKarioki1 = strKarioki.charAt(0);

				for(int j = 0; j <= ('z'-'a'); j++) {
					if(chKarioki1 == arrayAlpha[j] || chKarioki1 == arrayAlpha1[j]) {
						arrayCount[j] += 1;
					}
				}
			}
		}
		for(int j = 0; j <= ('z'-'a'); j++) {
			System.out.println(arrayAlpha[j] +" : "+arrayCount[j]);
		}
	}
}

Measured memory_bytes: 26124
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int[] ss = new int[28];
        int[] tt = new int[28];
        boolean f = false;
        for(int i = 0;i < 28;i++){
            ss[i] = -1; tt[i] = -1;
        }
        for(int i = 0;i < s.length();i++){
            char c = s.charAt(i);
            char cc = t.charAt(i);
            if(ss[c-'a'] < 0){
                ss[c-'a'] = cc-'a';
            }else if(ss[c-'a'] != cc-'a'){
                f = true;
                break;
            }
            if(tt[cc-'a'] < 0){
                tt[cc-'a'] = c-'a';
            }else if(tt[cc-'a'] != c-'a'){
                f = true;
                break;
            }
        }
        if(f)   System.out.println("No");
        else    System.out.println("Yes");
    }
}

Measured memory_bytes: 28060
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var v = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var c = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            ans = Math.Max(ans, ans + v[i] - c[i]);
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> 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;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
  int N,h,count=0;
 
  cin >> N;
  int A[N];
 
  for(int i=1;i<=N;i++)
    {
      cin >> A[i];
    }
 
  for(int i=1;i<=N;i++)
    {
      for(int j=N;j>=i+1;j--)
    {
      if(A[j] < A[j-1])
        {
          h = A[j];
          A[j] = A[j-1];
          A[j-1] = h;
          count++;
        }
    }
    }
 
  for(int i=1;i<=N;i++)
    {
      cout << A[i];    
      if(i != N)cout << " ";
    }
  cout << endl << count << endl;
 
 
  return 0;
}

Measured memory_bytes: 3092
from collections import defaultdict
n = int(input())
book = defaultdict(lambda : defaultdict(int))
for i in range(n):
    s, p = input().split()
    p = int(p)
    book[s][p] = i

for _, v in sorted(book.items()):
    for _, vv in sorted(v.items(), reverse=True):
        print(vv+1)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a) (a).begin(),(a).end()
ll n,ans=0;
void Main(){
    cin>>n;
    For(i,1,n/2+1){
        if(n-i!=i) ans++;
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


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

#define f first
#define s second

using namespace std;

typedef long long lint;
const lint N = 3300, INF = N*1e9+7;
lint n, a[N], dp[N][N][2];

lint solve(lint i, lint j, lint k){
	if (dp[i][j][k] != INF){
		return dp[i][j][k];
	}

	if (i == j){
		if (k==0) return dp[i][j][k] = a[i];
		else 	  return dp[i][j][k] = -a[i];
	}

	if (k == 0){ //maximize
		return dp[i][j][k] = max(solve(i + 1, j, 1) + a[i], solve(i, j - 1, 1) + a[j]);
	} else {
		return dp[i][j][k] = min(solve(i + 1, j, 0) - a[i], solve(i, j - 1, 0) - a[j]);
	}

}

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%lld", &n);

	for (lint i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}

	for (lint i = 0; i < N; i++)
		for (lint j = 0; j < N; j++)
			dp[i][j][0] = dp[i][j][1] = INF;

	printf("%lld\n", solve(0, n-1, 0));

	return 0; 
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        TreeMap<Long, Integer> map = new TreeMap<>();
        int n = in.ni();
        for (int i = 0; i < n; i++) {
            long a = -in.nl();
            if(!map.containsKey(a)) map.put(a, 1);
            else map.replace(a, map.get(a)+1);
        }
        long edge1 = 0;
        long edge2 = 0;
        for(Long l: map.keySet()){
            if(edge1==0){
                if(map.get(l)>=2){
                    edge1 = l;
                    map.replace(l, map.get(l)-2);
                }
            }
            if(edge2==0){
                if(map.get(l)>=2){
                    edge2 = l;
                    map.replace(l, map.get(l)-2);
                }
            }
            if(edge1>0&&edge2>0) break;
        }
        out.println(edge1*edge2);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 47468
#include<iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int A,B;
    cin >> A >> B;
    int N;

    if(A - B > 0){
      N = A;
    }else{
      N = B;
    }

    for(int i = 0; i <= N; i++){
      if(abs(A - i) ==abs(B - i)){
        cout << i << endl;
        break;
      }
      if(i == N) cout <<  "IMPOSSIBLE" << endl;
    }
}


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

vector<vector<int>> to;
vector<int> ans;
void dfs(int v,int p=-1){
    for(int u:to.at(v)){
        if(u==p){continue;}
        ans.at(u)+=ans.at(v);
        dfs(u,v);
    }
    return;
}

int main() {
    int N,Q;
    cin>>N>>Q;
    to.resize(N,vector<int>(0));
    ans.resize(N);
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        --a;--b;
        to.at(a).push_back(b);
        to.at(b).push_back(a);
    }
    rep(i,Q){
        int p,x;
        cin>>p>>x;
        --p;
        ans.at(p)+=x;
    }
    dfs(0);
    rep(i,N){
        cout<<ans.at(i)<<endl;
    }
}


Measured memory_bytes: 26624
#include <stdio.h>
int main(void)
{
	int a,b,c,d,e,f,g,h,i,j,gokei;
	j=0 ;
	scanf("%d %d %d %d %d %d %d %d %d %d",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
	gokei=a+b+c+d+e+f+g+h+i+j ;
	printf("%d\n",gokei);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int main() {
	int n;
	while ( ~scanf( "%d", &n ) && n ) {
		int s = 0, e = n - 1, f;
		int ans = 0;
		int num;
		VI a( n );
		for ( int i = 0; i < n; i++ ) {
			scanf( "%d", &a[ i ] );
		}
		sort( a.begin(), a.end() );

		scanf( "%d", &num );
		while ( e - s >= 0 ) {
			ans++;
			f = ( s + e ) / 2;
			if ( a[ f ] == num ) {
				break;
			}
			else if ( a[ f ] < num ) {
				s = f + 1;
			}
			else if ( a[ f ] > num ) {
				e = f - 1;
			}
		}
		printf( "%d\n", ans );
	}
	return 0;
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  
  for (int a = 0; a <= A; a++)
  {
    for (int b = 0; b <= B; b++)
    {
      for (int c = 0; c <= C; c++)
      {
        int sum = 500 * a + 100 * b + 50 * c;
        if (sum == X)
        {
          ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
int n;
string s[100010];
int ans;
map<string, int> vis;
signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		char a[20];
		for (int j = 0; j < s[i].size(); j++)
			a[j] = s[i][j];
		sort(a, a + s[i].size());
		for (int j = 0; j < s[i].size(); j++)
			s[i][j] = a[j];
		if (vis[s[i]] > 0) ans += vis[s[i]];
		vis[s[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18176
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

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

    vector<long long> prime(N+1);
    for (int i = 1; i <= N; i++) {
        int n = i;
        for (int a = 2; a*a <= n; a++) {
            if (n % a != 0) continue;
            int ex = 0;
            while (n % a == 0) {
                prime[a]++;
                n /= a;
            }
        }
        if (n != 1) prime[n]++;
    }

    // for (int i = 0; i <= N; i++) {
    //     print(i, prime[i]);
    // }

    int ans = 0;

    // 5 * 5 * 3
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N-1; j++) {
            for (int k = j+1; k <= N; k++) {
                if (i == j || i == k) continue;
                if (prime[i] >= 2 && prime[j] >= 4 && prime[k] >= 4) ans++;
            }
        }
    }

    // 5 * 15, 3 * 25
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (i == j) continue;
            if (prime[i] >= 4 && prime[j] >= 14) ans++;
            if (prime[i] >= 2 && prime[j] >= 24) ans++;
        }
    }
    
    // 75
    for (int i = 1; i <= N; i++) {
        if (prime[i] >= 74) ans++;
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}    

Measured memory_bytes: 3604
import scala.io.Source.stdin

object Main extends App {
  def f(x:Double) = if(x == -0.0) 0.0 else x

  val results = stdin.getLines.map { s=>
    val n = s.split(",").map(_.toDouble)
    val d = Math.pow(n(2)-n(0),2) + Math.pow(n(3)-n(1),2)
    val inner = (n(2)-n(0))*(n(4)-n(0)) + (n(3)-n(1))*(n(5)-n(1))
    val (x,y) = (2*inner*(n(2)-n(0))/d + 2*n(0)-n(4), 2*inner*(n(3)-n(1))/d + 2*n(1)-n(5))
    "%.6f %.6f".format(f(x),f(y))
  }
  println(results.mkString("\n"))
}

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

const int MAX = 200001;
const int64_t MOD = 1e9+7;
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

const int64_t FACT_MAX = MAX;
int64_t famod[FACT_MAX+1];
int64_t simod[FACT_MAX+1];
int64_t fimod[FACT_MAX+1];

void create_fact_mod(int num){
    famod[0] = 1;
    famod[1] = 1;
    for(int i=2; i<=num; i++){
        famod[i] = famod[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    simod[0] = 1;
    simod[1] = 1;
    for(int i=2; i<=num; i++){
        simod[i] = (MOD - MOD/i) * simod[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fimod[0] = 1;
    fimod[1] = 1;
    for(int i=2; i<=num; i++){
        fimod[i] = fimod[i-1] * simod[i] % MOD;
    }
}

void create_mod_tables(int num){
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return famod[n] * fimod[n-k] % MOD * fimod[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return famod[n] * fimod[n-k] % MOD;
}

int main(){
    int i, j, k;
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> cw[MAX];
    for(i=0; i<N; i++){
        int c, w;
        cin >> c >> w;
        cw[c-1].push_back(w);
    }

    vector<int> mins;
    for(i=0; i<N; i++){
        if(cw[i].size()){
            sort(cw[i].begin(), cw[i].end());
            mins.push_back(cw[i][0]);
        }
    }
    sort(mins.begin(), mins.end());
    mins.push_back(1e9); //sentinel

    vector<int> swappable;
    for(i=0; i<N; i++){
        if(cw[i].size()){
            int other_min = (mins[0] == cw[i][0] ? mins[1] : mins[0]);
            int numY = upper_bound(cw[i].begin(), cw[i].end(), Y-other_min) - cw[i].begin();
            if(numY == 0) continue;

            int numX = upper_bound(cw[i].begin(), cw[i].end(), X-cw[i][0]) - cw[i].begin();

            swappable.push_back(max(numX, numY));
        }
    }

    int sum = accumulate(swappable.begin(), swappable.end(), 0);
    create_mod_tables(sum);
    int64_t ans = 1;
    for(auto n : swappable){
        mul(ans, comb_mod(sum, n));
        sum -= n;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14964
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let a: i32 = sc.next();
    let b: i32 = sc.next();
    println!("{}", if a < 10 && b < 10 { a * b } else { -1 });
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}


Measured memory_bytes: 4352
import math

a, b, h, m = map(int, input().split())

degs = 6 * m
degl = 30 * h + 0.5 * m

degsa = abs(degs - degl)
nasukaku = min(degsa, 360 - degsa)

ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(nasukaku)))

print(ans)

Measured memory_bytes: 9500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
ll ans[55],c[55],d[55],f[55][10005];
struct E{ll to,a,b;};
struct P{ll t,pos,s;};
bool operator <(const P &a,const P &b){return a.t>b.t;}
vector<E> edge[55];
priority_queue<P> q;
int main(){
    ll n,m,k,sum=0;
    cin>>n>>m>>k;
    for(ll i=1;i<=m;i++){
        ll u,v,x,y;
        cin>>u>>v>>x>>y;
        edge[u].push_back({v,x,y});
        edge[v].push_back({u,x,y});
    }
    for(ll i=1;i<=n;i++){
        cin>>c[i]>>d[i];
        c[i]=min(c[i],(ll)5000);
    }
    k=min(k,(ll)5000);
    q.push({1,1,k});
    while(!q.empty()&&sum<n){
        ll x=q.top().t,p=q.top().pos,num=q.top().s;q.pop();
        if(f[p][num]) continue;
        f[p][num]=x;
        if(!ans[p]) ans[p]=x,sum++;
        for(E i:edge[p]){
            if(i.a<=num&&!f[i.to][num-i.a]) q.push({x+i.b,i.to,num-i.a});
            if(num+c[p]<=5000) q.push({x+d[p],p,num+c[p]});
        }
    }
    for(int i=2;i<=n;i++){
        cout<<ans[i]-1<<endl;
    }
}

Measured memory_bytes: 29740
import sys
from fractions import gcd
input = sys.stdin.readline

def lcm(x, y):
    return (x * y) // gcd(x, y)
def main():
    n = int(sys.stdin.readline())
    a = list(map(int,input().split()))
    
    l = a[0]
    for i in range(n):
        l = lcm(l, a[i])
    sum = 0
    for i in range(n):
        sum += l // a[i]
    print(sum % 1000000007)
main()

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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define debug(x) cerr<<#x<<"="<<x<<'\n'

int n;
int a[120];

int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%d",&a[i]);
	int ans=1e9;
	for (int i=1;i<=100;i++) {
		int res=0;
		for (int j=0;j<n;j++) res+=(a[j]-i)*(a[j]-i);
		ans=min(ans,res);
	}
	printf("%d",ans);
	return 0;
}


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

template <class T>
T pow(T x, T n, T mod) {
    T ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <class T>
T inverse(T x, T p) { return pow(x, p - 2, p); }

int main() {
    long long n;
    const auto mod = 1000000007ll;
    std::cin >> n;
    std::vector<long long> a(n + 1);
    std::vector<long long> fact(n + 1), inv(n + 1);
    fact[0] = 1;
    for (auto i = 1ll; i <= n; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = inverse(i, mod);
    }
    for (auto i = 1; i <= n; i++) inv[i] = (inv[i] + inv[i - 1]) % mod;

    for (int i = 1; i <= n; i++) std::cin >> a[i];

    std::vector<long long> s(n + 1);
    // s[1] = inv[n];
    // s[n] = inv[n];
    for (int i = 1; i <= n; i++) s[i] = (inv[i] + inv[n - i + 1] + mod - 1) % mod;
    auto ret = 0ll;
    for (int i = 1; i <= n; i++) {
        ret = (ret + s[i] * a[i] % mod * fact[n] % mod) % mod;
    }

    std::cout << ret << std::endl;

    return 0;
}

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b,a%b);
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    
    ll divide = 0;
    
    if (A % C == 0) {
        divide += B/C - A/C + 1;
    } else {
        divide += B/C - A/C;
    }
    
    if (A % D == 0) {
        divide += B/D - A/D + 1;
    } else {
        divide += B/D - A/D;
    }
    
    //あとはダブって引いてるとこ考える
    ll GCD = gcd(C, D);
    ll LCM = C / GCD * D;
    
    if (A % LCM == 0) {
        divide -= B/LCM - A/LCM + 1;
    } else {
        divide -= B/LCM - A/LCM;
    }
    
    ll ans;
    
    ans = B - A + 1 - divide;
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <deque>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
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 dp[100010];

int main() {

    string s;

    cin >> s;
    
    int a, b, c, d;

    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';

    if (a == b || b == c || c == d) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
    

    return 0;

}

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

using namespace std;
int main(void){
  int N;
  vector<int> v;
  cin >> N;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(),v.end());

  int ans = 0;
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      //cout << i << j << endl;
      //二分探索
      int a = v[i];
      int b = v[j];
      int l = j+1;
      int r = N-1;
      // v[N-1]は領域？
      if(v[N-1] < a+b){
	//cout << "all" << endl;
	//あまったもの全部はいる
	ans = ans + (N-1) - j;
      }else{
	 
	//j+1は領域にはいっているしN-1は領域外
	//j+1が領域にはいっているか調べる　なかったらおわり
	if(a+b > v[j+1]){
	  while(r-l>1){
	    int cent = (r+l)/2;
	    if(v[cent] >= a+b){
	      // centは求める領域ではない
	      r = cent;
	    }else{
	      // cent は欲しい領域に入っている
	      l = cent;
	    }
	  }
	  //cout << "(i,j)=(" << i << "," << j << "),l=" <<l << ",r=" << r << endl;
	  // この結果 lは領域 rは領域外
	  ans = ans + l - j;
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>

int main(){

    int a,b,c;
    int cnt=0;
    scanf("%d %d %d", &a, &b, &c);
    for(int i=a; i<=b; i++){
        if(c%i == 0) cnt++;
    }
    printf("%d\n", cnt);
    
    return 0;
}


Measured memory_bytes: 2696