akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

vector<int> e[100000];
int color[100000];

int main(void) {
    int i, n;
    scanf("%d",&n);
    REP (i,n-1) {
        int a, b;
        scanf("%d%d",&a,&b);
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    queue<pair<int,int>> q;
    q.push({0,1});
    q.push({n-1,2});
    color[0] = 1;
    color[n-1] = 2;
    while (!q.empty()) {
        int u, c;
        tie(u,c) = q.front(); q.pop();
        for (auto v: e[u]) if (color[v] == 0) {
            color[v] = c;
            q.push({v,c});
        }
    }
    int cnt = 0;
    REP (i,n) cnt += color[i] == 1;
    if (2 * cnt > n) {
        puts("Fennec");
    }
    else {
        puts("Snuke");
    }
    return 0;
}

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

#define MAX 10000
#define INF (1<<29)

struct Edge{
  int c, to;
};

struct state{
  int node, c;
  bool operator <(const state &b)const{
    return c > b.c;
  }
};

int n;
int d[MAX+1];
vector<Edge> G[MAX+1];
priority_queue<state> q;

void dijkstra(){

  fill(d,d+MAX+1,INF);
  q.push((state){0,0});
  d[0] = 0;

  while(!q.empty()){

    state info;
    info = q.top();
    q.pop();

    for(int i = 0; i < G[info.node].size(); i++){
      if(d[G[info.node][i].to] > G[info.node][i].c + d[info.node]){
        d[G[info.node][i].to] = G[info.node][i].c + d[info.node];
        q.push((state){G[info.node][i].to,d[info.node]});
      }
    }
  }

  for(int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }



}

int main(){

  cin >> n;
  for(int i = 0; i < n; i++){
    int k, v, cc, u;
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      cin >> v >> cc;
      G[u].push_back((Edge){cc,v});
    }
  }

  dijkstra();

}

Measured memory_bytes: 6380
#include <iostream>

using namespace std;

int main()
{
    int S;
    cin >> S;
    int h = S / 60 / 60;
    int m = S / 60 % 60;
    int s = S % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        String a = sc.next();
        String b = new StringBuilder(sc.next()).reverse().toString();
        System.out.println(a.equals(b) ? "YES" : "NO");
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int r; cin >> r;
  double ans = 2*r*M_PI;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 3780
/*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define pb push_back
#define f first
#define s second
#define inf INT_MAX
#define size_1d 10000000
#define size_2d 1000
#define rep(i,v,n) for(ll i = v; i < n; i++)
//Snippets: delta, sieve, fastexp, dfs, bfs, dijkstra, floodfill

using namespace std;

ll n, w;

void Input() {
	cin >> n >> w;
}

void Solve() {
	vll a(n), b(n);
	for (ll i = 0; i < n; i++) cin >> a[i] >> b[i];
	vll c(w + 1, -1);
	c[0] = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = w; j >= 0; j--) {
			if (c[j] != -1 and j + a[i] <= w) c[j + a[i]] = max(c[j + a[i]], c[j] + b[i]);
		}
	}
	ll ans = 0;
	for (ll i = 0; i <= w; i++)ans = max(ans, c[i]);
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll T = 1;
	//cin >> T;
	//ll t = 1;
	while (T--) {
		Input();
		//cout << "Case " << t << ": ";
		Solve();
		//t++;
	}
	return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

int main() {
    ll a, b;
    cin >> a >> b;
    ll l;
    l = lcm(a, b);
    cout << l << endl;

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < int(Y);++(X))
#define rrep(X,Y) for (int (X) = int(Y-1);(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll Int;
ll INF=1ll<<45;
Int extgcd(Int a, Int b, Int &x, Int &y) {
  Int g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

int main(){
  int i,j,k;
  ll n,m,d;
  cin>>n>>m>>d;
  vector<ll> a(m),r(m),lcma(m+1);
  vector<vector<ll > > subs(m);
  rep(i,m)
    cin>>a[i];
  lcma[0]=1;
  rep(i,m)
    lcma[i+1]=lcma[i]*a[i]/__gcd(lcma[i],a[i]);
//  rep(i,m)
//    gcda[i]=__gcd(lcma[i],a[i]);
  rep(i,m){
    subs[i].resize(a[i],INF);
    rep(j,a[i]){
      ll &tmp=subs[i][j*lcma[i]%a[i]];
      tmp=min(tmp,j*lcma[i]);
    }
//rep(j,a[i])cout<<subs[i][j]<<",";cout<<endl;
  }
  ll dd;
  rep(i,d){
    ll nnn=n,lcms=1,subst;
    rep(j,m)
      cin>>r[j];
    rep(j,m){
      if(r[j]<0)continue;
      ll nn=(n+a[j]-r[j])%a[j];
      subst=INF;
      rep(k,a[j])
        if(k*lcms%a[j]==nn){
          subst=k*lcms;
          break;
        }
      if(subst==INF){
        cout<<-1<<endl;
        return 0;
      }
      n-=subst;
      lcms*=a[j]/__gcd(a[j],lcms);
      n+=(nnn-n)/lcms*lcms;
      if(n<0){
        cout<<-1<<endl;
        return 0;
      }
 //     cout<<"->"<<n<<":"<<r[j]<<"mod"<<a[j]<<endl;
    }
  }
  cout<<(n<0?-1:n)<<endl;
  return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
/*迷路移動*/const int dx[4]={1,0,-1,0};const int dy[4]={0,1,0,-1};
llfor;//ll ans=0;////////////////////////////////////////////////////////////
ll n,ans;
void search(ll x){
 x*=10;
 if(x>n)return;
 ll k;
 rep(k,0,3){
  ll tmp=x+3+2*k;
  bool ok=false;
  bool cnt[10]={false};
  while(tmp>0){
   cnt[tmp%10]=true;
   tmp/=10;
  }
  search(x+3+2*k);
  if(!cnt[3]||!cnt[5]||!cnt[7])continue;
  if(x+3+2*k<=n){
   ans++;
  // cout<<x+3+2*k<<" "<<ans<<" "<<cnt[3]<<" "<<cnt[5]<<" "<<cnt[7]<<endl;
  }
 }
 return;
}

int main(){
 cin>>n;
 ans=0;
 search(35);
 search(33);
 search(37);
  
 search(53);
 search(55);
 search(57);
  
 search(73);
 search(75);
 search(77);
 pr(ans);
 return 0;}

Measured memory_bytes: 3604
#include<iostream>
#include<bits/stdc++.h>
#include <stdio.h>
#include<unordered_map>
#define Amr_Abdelazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vvll vector<vector<ll> >
#define vpll vector<pair<ll,ll> >
#define P complex<ld>
#define X real()
#define Y imag()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rep(i,n)   for(int i=0;i<n;i++)
#define repp(i,s,n)   for(int i=s;i<=n;i++)
#define print(v) {for(auto i:v)cout<<i<<" ";cout<<"\n";}
#define mkp make_pair
#define clr(ar,v) memset(ar,v,sizeof(ar));
#define TC ll amr_abdelazim;cin>>amr_abdelazim;while(amr_abdelazim--)
#define popcnt(x) __builtin_popcount(x)
#define EPS 1e-9
#define INF 1000000000000000009
using namespace std;
//freopen("output.txt", "w", stdout);
//freopen("input.txt", "r", stdin);
const int mod = 1000000007;
const int N = 2 * 100000 + 9;
const double pi = acos(-1);
class cmp{
public:
	bool operator() (ll &A, ll &B){
		return A > B;
	}
};
bool by_sec(const pll &a, const pll &b){
	if ((abs(a.first) == abs(b.first)))
		return (abs(a.second) < abs(b.second));
	return (abs(a.first) < abs(b.first));
}
bool byth(const tuple<ll, ll, ld>& a, const tuple<ll, ll, ld>& b){
	return (get<2>(a) < get<2>(b));
}
ld dist(P a, P b){
	return (ld)abs(a - b);
}
ll fact[1000009], inv[1000009];
ll fp(ll a, ll b){
	if (b == 0)
		return 1;
	ll ans = fp(a, b / 2);
	ans = (ans * ans) % mod;
	if (b % 2 != 0)
		ans = (ans * (a % mod)) % mod;
	return ans;
}
void FacInv(ll n){
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = ((i%mod) * fact[i - 1] % mod) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}
ll ncr(ll n, ll r){
	return (((fact[n] * inv[r]) % mod) * inv[n - r]) % mod;
}
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a%b);
}
ll max(ll a, ll b){
	if (a >= b)return a;
	else return b;
}
ll min(ll a, ll b){
	if (a <= b)return a;
	else return b;
}
ld dp[3009][3009];
ll n;
vector<ld>v;
int main()
{
	Amr_Abdelazim	
	cin >> n;
	v = vector<ld>(n);
	rep(i, n)cin >> v[i];
	ld ans = 0;
	dp[0][0] = 1;
	repp(i,1, n)
		rep(j, n + 1){
			if (j == 0)dp[i][j] = (1-v[i - 1]) * dp[i - 1][j];
			else dp[i][j] = v[i - 1] * dp[i - 1][j - 1] + (1 - v[i - 1])*dp[i - 1][j];
		}
	rep(i, n + 1)if (i > n - i)ans += dp[n][i];
	cout << fixed << setprecision(9) << ans << "\n";
	return 0;
}

Measured memory_bytes: 144792
// 2014/07/28 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int a1, b1;
	cin >> a1 >> b1;
	cout << a1-b1 << '\n';

	int a2, b2;
	cin >> a2 >> b2;
	cout << a2-b2 << '\n';

	int a3, b3;
	cin >> a3 >> b3;
	cout << a3-b3 << '\n';

	int a4, b4;
	cin >> a4 >> b4;
	cout << a4-b4 << '\n';

	int a5, b5;
	cin >> a5 >> b5;
	cout << a5-b5 << '\n';

	int a6, b6;
	cin >> a6 >> b6;
	cout << a6-b6 << '\n';

	int a7, b7;
	cin >> a7 >> b7;
	cout << a7-b7 << '\n';

	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef tuple<ll,int,int> T;
const ll INF = 1000000000;
const ll MOD = 1000000007;

ll ans = 1e18;

vector<ll> l;
ll n,a,b,c;
void solve(ll num,ll A,ll B,ll C,ll L1,ll L2,ll L3){
	if(num == n && A >= 1 && B >= 1 && C >= 1){
		ll cost = (A + B + C - 3) * 10 + abs(L1-a) + abs(L2-b) + abs(L3-c);
		ans = min(ans,cost);
		return;
	}
	else if(num == n)return;
	solve(num+1,A+1,B,C,L1+l[num],L2,L3);
	solve(num+1,A,B+1,C,L1,L2+l[num],L3);
	solve(num+1,A,B,C+1,L1,L2,L3+l[num]);
	solve(num+1,A,B,C,L1,L2,L3);
}

int main(){
	cin >> n >> a >> b >> c;
	l.resize(n);
	for(ll i = 0;i < n;i++)cin >> l[i];
	solve(0,0,0,0,0,0,0);

	cout << ans << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
#define EPS (1e-10)

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

struct Point { double x, y; };//点
struct Segment { Point p1, p2; };//線
double dot(Point a, Point b) {//内積
    return a.x * b.x + a.y * b.y;
}
double cross(Point a, Point b) {//外積
    return a.x * b.y - a.y * b.x;
}
double norm(Point a) {
    return a.x * a.x + a.y * a.y;
}
double absv(Point a) {
    return sqrt(norm(a));
}
Point project(Segment s, Point p) {
    Point base, q;
    Point ans;
    base.x = s.p2.x - s.p1.x;
    base.y = s.p2.y - s.p1.y;
    q.x = p.x - s.p1.x;
    q.y = p.y - s.p1.y;
    double r = dot(q, base) / norm(base);
    ans.x = s.p1.x + base.x * r;
    ans.y = s.p1.y + base.y * r;
    return ans;
}
Point reflect(Segment s, Point p) {
    Point ans;
    ans.x = p.x + (project(s, p).x - p.x) * 2.0;
    ans.y = p.y + (project(s, p).y - p.y) * 2.0;
    return ans;
}
/*double getPointDistance(Point a, Point b) {
    Point ans;
    ans.x = a.x - b.x;
    ans.y = a.y - b.y;
    absv(ans);
}
double getDistanceLP(Segment l, Point p) {
    Point tmp, tmp2, ans;
    tmp.x = l.p2.x - l.p1.x;
    tmp.y = l.p2.y - l.p1.y;
    tmp2.x = p.x - l.p1.x;
    tmp2.y = p.y - l.p1.y;
    return absv(cross(tmp, tmp2) / absv(tmp));
}
double getDistanceSP(Segment s, Point p) {
    Point t1, t2, t3, t4;
    t1.x = s.p2.x - s.p1.x;
    t1.y = s.p2.y - s.p1.y;
    t2.x = p.x - s.p1.x;
    t2.y = p.y - s.p1.y;
    t3.x = s.p1.x - s.p2.x;
    t3.y = s.p1.y - s.p2.y;
    t4.x = p.x - s.p2.x;
    t4.y = p.y - s.p2.y;
    if (dot(t1, t2) < 0.0)return absv(t2);
    if (dot(t3, t4) < 0.0)return absv(t4);
    return getDistanceLP(s, p);
}*/
int ccw(Point p0,Point p1,Point p2){
    Point a,b;
    a.x=p1.x-p0.x;
    a.y=p1.y-p0.y;
    b.x=p2.x-p0.x;
    b.y=p2.y-p0.y;
    if(cross(a,b)>EPS)return COUNTER_CLOCKWISE;
    if(cross(a,b)<(-EPS))return CLOCKWISE;
    if(dot(a,b)<(-EPS))return ONLINE_BACK;
    if(norm(a)<norm(b))return ONLINE_FRONT;
    
    return ON_SEGMENT;
}
bool intersect(Point p1,Point p2,Point p3,Point p4){
    return(ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}
bool intersectS(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}
/*double getDistance(Segment s1,Segment s2){
    if(intersectS(s1,s2))return 0.0;
    return min(min(getDistanceSP(s1,s2.p1)),getDistanceSP(s1,s2.p2)),min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}*/

int main(void) {
    Segment a,b;
    int n;cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a.p1.x >> a.p1.y >> a.p2.x >> a.p2.y;
        cin >> b.p1.x >> b.p1.y >> b.p2.x >> b.p2.y;
        cout<<intersectS(a,b)<<endl;
        //cout << fixed << setprecision(10) <<  << " " << ans.y << endl;
    }
    return 0;
}



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

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a = ceil((double)n / 1.08);
    int b = floor((double)n / 1.08);
    int x = floor((double)a * 1.08);
    int y = floor((double)a * 1.08);
    if (x == n) {
        cout << a << '\n';
    } else if (y == n) {
        cout << b << '\n';
    } else {
        puts(":(");
    }
    return 0;
}


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

int Q;
int A, B;
long long res;

long long sqrtll(long long x)
{
	long long l=1, r=2000000000;
	long long m;
	while(l<r){
		m = (l+r)/2;
		if(m*m >= x)
			r = m;
		else
			l = m+1;
	}
	if (l*l>x)
		l --;
	return l;
}

void solve()
{
	res = 0;
	if(A>B)
		swap(A, B);
	res += (A-1)*2;
	long long sq = sqrtll(1ll*A*B);
	if(sq*(sq+1)<1ll*A*B)
		res ++;
	if(sq*sq<1ll*A*B)
		res ++;
	if(sq-A>=0)
		res += (sq-A)*2;
	if(A!=B)
		res --;
	printf("%lld\n", res);
}

int res2;
int vis[1000000];
void solve2()
{
	int i;
	for(i=0; i<1000000; i++)
		vis[i] = 0;
	res2 = 0;
	for(i=1; i<A; i++){
		int tmp = A*B/i;
		if(tmp*i<A*B){
			if(vis[tmp]==0){
				vis[tmp] = 1;
				res2 ++;
			}
		}
	}
	for(i=0; i<1000000; i++)
		vis[i] = 0;
	for(i=1; i<B; i++){
		if(vis[i]==1)
			continue;
		int tmp = (A*B)/i;
		if(tmp*i < A*B && vis[tmp]==0){
			if(tmp > A){
				res2 ++;
			}
		}
		else{
			tmp --;
			while(vis[tmp]==1){
				tmp --;
				if(tmp == 0)
					break;
			}
			if(tmp>A)
				res2 ++;
		}
	}
	printf("%d\n", res2);
}

void test1()
{
	A = rand()%5+1;
	B = rand()%5+1;
	solve();
	solve2();
	if(res != res2){
		printf("Wrong\n");
		solve();
	}
}

void test()
{
	int i;
	for(i=0; i<100; i++)
		test1();
}

int main()
{
	//test();
	int i;
	scanf("%d", &Q);
	for(i=0; i<Q; i++){
		scanf("%d%d", &A, &B);
		solve();
		//solve2();
	}
	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
order_dict = {}
ans = [0]*N

for i in range(N):
    if i != 0:
        a, b = map(int, input().split())
        if not a in order_dict:
            order_dict[a] = set()
        order_dict[a].add(b)
    

for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

for a in range(N+1):
    if a in order_dict:
        for b in order_dict[a]:
            ans[b-1] += ans[a-1]


print(' '.join(map(str, ans)))

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

int main(){
    ll k;
    cin >> k;
    ll x = 7;
    ll ans = 1;
    while(x % k && ans < k+1){
        x = (10*x + 7) % k;
        ans++;
    }
    cout << (ans >= k+1 ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int H,M;
    while(1){
        cin >> H >> M;
        if(H==0&&M==0) break;
        REP(i,H){
            if(i%2==0){
                REP(j,M){
                    if(j%2==0) cout << '#';
                    else cout << '.';
                }
            }
            else{
                REP(j,M){
                    if(j%2!=0) cout << '#';
                    else cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
import java.io.*;

/**
 * Created by Ayushi on 04/08/2019.
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int a = Integer.parseInt(temp[0]);
        int b = Integer.parseInt(temp[1]);
        int c = Integer.parseInt(temp[2]);
        r.close();
        System.out.println(Math.max(((b+c)-a), 0));
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define Maxn 307
#define modp 1000000007
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m;
bool vis[Maxn][Maxn][Maxn];
int f[Maxn][Maxn][Maxn];
multiset<pair<int,int> >s[Maxn];
int dfs(int a,int b,int c)
{
	if (vis[a][b][c]) return f[a][b][c];
	vis[a][b][c]=true;
	int now=max(a,max(b,c));
	for (multiset<pair<int,int> >::iterator it=s[now].begin();it!=s[now].end();it++)
	{
		int r=0;
		r=(a>=(*it).first)+(b>=(*it).first)+(c>=(*it).first);
		if (r!=(*it).second)
		{
			f[a][b][c]=0;
			return 0;
		}
	}
	if (now>=n)
	{
		f[a][b][c]=1;
		return 1;
	}
	f[a][b][c]=(f[a][b][c]+dfs(now+1,b,c))%modp;
	f[a][b][c]=(f[a][b][c]+dfs(a,now+1,c))%modp;
	f[a][b][c]=(f[a][b][c]+dfs(a,b,now+1))%modp;
	return f[a][b][c];
}
int main()
{
	n=read(),m=read();
	for (int i=1;i<=m;i++)
	{
		int l=read(),r=read(),x=read();
		s[r].insert(make_pair(l,x));
	}
	printf("%d\n",dfs(0,0,0));
	return 0;
}


Measured memory_bytes: 141056
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
int main(void){

    int n;
    cin >> n;
    
    vector<int> d(n);
    for(int i=0; i<n; i++) cin >> d[i];

    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());

    int result = 0;
    for(int i=0; i<n; i++) {
        if(i!=0 && d[i-1] == d[i]) continue;
        else result++;
    }
    
    cout << result << endl;

    return 0;
    
}


Measured memory_bytes: 256
#include <cassert>
#include <iostream>
using ll = long long;
using namespace std;

constexpr int mod = 1e9+7;
int main() {
    int n; cin >> n;
    string s0, s1; cin >> s0 >> s1;
    ll result = (s0[0] == s1[0] ? 3 : 2);
    bool prv = false;
    for (int i = 0; i < n; ) {
        if (s0[i] == s1[i]) {
            result *= (prv ? 2 : 1);
            result %= mod;
            prv = true;
            i += 1;
        } else {
            assert (i + 1 < n and s0[i] == s0[i + 1] and s1[i] == s1[i + 1]);
            result *= (prv ? 2 : 3);
            result %= mod;
            prv = false;
            i += 2;
        }
    }
    printf("%lld\n", result);
    return 0;
}


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

int main(){
  ll a,b,c,d,e,f,g;
  cin>>a>>b>>c>>d>>e>>f>>g;
  ll ans=a/2*2+b+d/2*2+e/2*2;
  if(a>0&&d>0&&e>0){
    ans=max(ans,(a-1)/2*2+(d-1)/2*2+(e-1)/2*2+3+b);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n;
    cin >> n;
    ll a[n];
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll x[n];
    vector<ll> ans;
    for (ll i=n;i>0;i--){
        ll c=0;
        for (ll j=i*2;j<=n;j+=i){
            c+=x[j-1];
        }
        if (c%2!=a[i-1]){
            x[i-1]=1;
            ans.push_back(i);
        }else{
            x[i-1]=0;
        }
    }
    cout << ans .size() << endl;
    for (ll i=0;i<ans.size();i++){
        cout << ans[i] << " ";
    }
    if (ans.size())cout << endl;
    return 0;
}


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

int main(){
    while(1){
      int x,y,s;
      cin>>x>>y>>s;

      if(x==0&&y==0&&s==0){
        break;
      }

      int max=-1;

      for(int i=1;i<s-1;i++){
        int ax=i*(100+x)/100;
        int ay=i*(100+y)/100;
        for(int j=1;j<=s-1;j++){
          int bx=j*(100+x)/100;
          int by=j*(100+y)/100;

          if(ax+bx==s&&max<ay+by){
            max=ay+by;
          }else if(ax+bx>s){
            break;
          }
        }
      }
      cout<<max<<endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include	<stdio.h>
int main(void){
 
  	int a; //一回分の値段
  	int b; //所持金
  	int c; //必要な回数
  	int sum; //回答
  
  scanf("%d %d %d",&a,&b,&c);
  
 if(b/a>=c)
   	printf("%d",c);
 else
   printf("%d",b/a);
  
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[1010],cnt;
//map<ll,ll>f[18][18][280010];
ll solve(ll l,ll r,ll tl,ll tr){
	if(l+1==r)return 0;
	if(l+2==r)return (tl+tr)*a[l+1];
	cnt++;
//	if(f[l][r][tl][tr])return f[l][r][tl][tr];
	ll i,sej=1e18;
	for(i=l+1;i<r;i++)sej=min(sej,solve(l,i,tl,tl+tr)+solve(i,r,tl+tr,tr)+(tl+tr)*a[i]);
	return sej;
}
int main(){
	ll i;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	//printf("%lld\n",cnt);
	printf("%lld\n",solve(1,n,1,1)+a[1]+a[n]);
	//printf("%lld",cnt);
}
/*
18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
*/

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int N, M;
pair<int,int> p[10005];

int main() {
  while(1){
    cin>>N>>M;
    if(N==0&&M==0) break;
    long long sum = 0;
    REP(i,0,N){
      int a, b;
      cin>>a>>b;
      p[i] = make_pair(b,a);
      sum += a*b;
    }
    sort(p,p+N);

    long long diff = 0;
    for(int i = N-1; 0<=i; i--){
      if(M == 0) break;
      int tmp = min(M, p[i].second);
      diff += p[i].first*tmp;
      M -= tmp;
    }
    cout<<sum - diff<<endl;
  }
  return 0;
}

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

void marge(int *, int, int ,int);
void margeSort(int *, int, int);

long long cnt = 0;

int main() {
    
    int a[200000];
    
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];

    margeSort(a, 0, n);
    
    cout<<cnt<<endl;
    
    return 0;
}

void marge(int *A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1], R[n2+1];
    int i, j;
    for(i = 0; i < n1; i++) L[i] = A[left + i];
    for(j = 0; j < n2; j++) R[j] = A[mid+j];
    
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;
    
    i = 0;
    j = 0;
    
    for(int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
            cnt += n1 - i;
        }
    }
}

void margeSort(int *a, int left, int right) {
    if(left+1 < right) {
        int mid = (left + right) /2;
        margeSort(a, left, mid);
        margeSort(a, mid, right);
        marge(a, left, mid, right);
    }
}



Measured memory_bytes: 4636
<?php

$N = trim(fgets(STDIN));

$col = trim(fgets(STDIN));

$arr_col = str_split($col);

$count = count($arr_col);

for ($i = 0; $i < $count; $i++) {

               if ($arr_col[$i] == $arr_col[$i+1]) {
                              $N --;
      }

}

echo $N;

?>

Measured memory_bytes: 10872
import math as m

n = list(map(int, input().split()))


def comb(n, r):
    if n <= 1:
        return 0
    else:
        return m.factorial(n) / (m.factorial(n - r) * m.factorial(r))


print(int((comb(n[0], 2)+comb(n[1], 2))))

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		int a = Integer.parseInt(tmpArray[0]);
		int b = Integer.parseInt(tmpArray[1]);
		int c = Integer.parseInt(tmpArray[2]);
		int[] array = new int[3];
		array[0] = a; array[1] = b; array[2] = c;
		
		Arrays.sort(array);
		System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
		/*
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}*/
	}

}

Measured memory_bytes: 24612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  
  if(A+B>C+D) {
    cout<<"Left"<<endl;
  }else if(A+B==C+D) {
    cout<<"Balanced"<<endl;
  }else if (A+B<C+D) {
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
#include <numeric>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; c[i] = a[i] + b[i]; }
    long long ans = 0;
    sort(c, c+n);
    for (int i = n-1; i >= 0; i -= 2) ans += c[i];
    cout << ans - accumulate(b, b+n, 0LL) << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a,b,c,d;
int main(void){
    cin>>n>>a>>b>>c>>d;
    ll G=b-a;
    for(int i=0;i<n;i++){
        ll A=c*i;
        ll B=d*i;
        ll C=c*(n-1-i)-G;
        ll D=d*(n-1-i)-G;
        if(A>D||C>B){
            
        }else{
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    
}


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

vector<int> C(26, 0); // C[i]
vector<vector<int> > S(365, vector<int>(26, 0)); // S[d][i]
int D;
int N;

int score(vector<int> V) {
	vector<int> c = C;
	int s = 0;
	for (int d = 0; d < D; d++) {
		c[V[d]] = 0;
		s += S[d][V[d]];
		s -= accumulate(c.begin(), c.end(), 0);
		for (int i = 0; i < N; i++) {
			c[i] += C[i];
		}
	}
	return s;
}

int ls1(int d, int i, int ci, int Ci) {
	return S[d][i] + 5 * ci;
}

int ls(int a, int b, int x, int d, int i, int ci, int Ci) {
	return S[d][i] - x * (S[min(D - 1, d + 1)][i] + S[min(D - 1, d + 2)][i]) / 100 + a * ci - b * Ci;
}

vector<int> findmin(int a, int b, int x) {
	vector<int> V(D, 0);
	vector<int> c = C;
	int s = 0;
	for (int d = 0; d < D; d++) {
		int mi = 0;
		for (int i = 0; i < N; i++) {
			if (ls(a, b, x, d,mi,c[mi],C[mi]) < ls(a, b, x, d, i, c[i], C[i])) mi = i;
		}
		V[d] = mi;
		c[V[d]] = 0;
		s += S[d][V[d]];
		s -= accumulate(c.begin(), c.end(), 0);
		for (int i = 0; i < N; i++) {
			c[i] += C[i];
		}
	}
	return V;
}

int main() {
	cin >> D;
	N = 26;
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	for (int d = 0; d < D; d++) {
		for (int i = 0; i < N; i++) {
			cin >> S[d][i];
		}
	}
	vector<int> V(D, 0);
	for (int d = 0; d < D; d++) {
//		cin >> V[d];
//		V[d]--;
		int i = 0;
		for (int j = 1; j < N; j++) {
			if (S[d][i] < S[d][j]) i = j;
		}
		V[d] = i;
	}

	vector<int> sV = findmin(5,30,0);
	if (score(V) < score(sV)) V = sV;

	random_device seed_gen;
	mt19937 engine(seed_gen());
	normal_distribution<> dist(0.0, 2.0);

	int a = 5;
	int b = 30;
	int x = 0;
	for (int j = 0; j < 10000; j++) {
		int ba = (int)(dist(engine) + 100.0) - 100;
		int bb = (int)(dist(engine) + 100.0) - 100;
		int bx = (int)(dist(engine) + 100.0) - 100;
		sV = findmin(a + ba, b + bb, x + bx);
		if (score(V) < score(sV)) {
			V = sV;
			a += ba;
			b += bb;
			x += bx;
//			cerr << "a = " << a << ", b = " << b << ", x = " << x << ", s = " << score(V) << endl;
		}
	}

	/*
	random_device seed_gen;
	mt19937 engine(seed_gen());
	uniform_real_distribution<> dist1(0.0, 1.0);
	vector<int> newV = V;
	int ms = score(V);
	for (int j = 0; j < 100000; j++) {
		newV = V;
		for (int k = 0; k < 1; k++) {
			int d1 = int(dist1(engine) * D);
			int d2 = min(D-1, d1 + int(dist1(engine) * 3));
			newV[d1] = V[d2];
			newV[d2] = V[d1];
		}
		int ns = score(newV);
		if (ms < ns) V = newV;
	}
	*/

	for (int d = 0; d < D; d++) {
		cout << V[d] + 1 << endl;
	}
	cerr << score(V) << endl;
  	return(0);
}


Measured memory_bytes: 4056
/*
I_Love_Trueno 
Author- darklight13
Smoke_Weed_Everyday
*/
#define _CRT_SECURE_NO_DEPRECATE
#define V__0_0__V
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double   ld;
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define view(x)     cout << (#x) << " is " << (x) << endl
#define view2(x,y)     cout << (#x) <<" "<<(#y)<< " are " << (x) <<" "<<(y)<< endl
#define  pb push_back
#define  F  first
#define  S  second
#define  mp make_pair
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
#define all(v) (v).begin(),(v).end()
#define sz(a) (ll)((a).size())
#define sq(x) ((x)*(x))
#define pii pair<ll,ll>
#define endl '\n'
#define pow (ll)pow
ll max_smile(ll a[],int j)
{
    ll maxx = 0;
    for(int i=0;i<3;i++)
    {
        if(i==j)
            continue;
        else
            maxx = max(maxx,a[i]);
    } 
    return maxx;
}
int32_t main()
{
  // FRE
    SYNC
    int n;cin>>n;
    ll a[n+1][3],dp[n+1][3];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    for(int i=0;i<3;i++)    dp[1][i]=a[1][i];
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            dp[i][j]= a[i][j]+max_smile(dp[i-1],j);
        }
    }
    ll ans = max(dp[n][0],max(dp[n][1],dp[n][2]));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b;
  co(b+b-a);
  
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

ans = {str(i): [0, 0] for i in range(1, n + 1)}
for i in range(m):
    # p, s = p_list[i], s_list[i]
    p, s = input().split()
    if s == 'WA' and ans[p][0] == 0:
        ans[p][1] += 1
    elif s == 'WA' and ans[p][0] == 1:
        pass
    elif s == 'AC' and ans[p][0] == 0:
        ans[p][0] = 1
    elif s == 'AC' and ans[p][0] == 1:
        pass

sum_ac = 0
sum_wa = 0
for x, y in ans.values():
    sum_ac += x
    if x == 1:
        sum_wa += y

print(sum_ac, sum_wa)


Measured memory_bytes: 25380
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include<cmath>
using namespace std;
bool fun(int num)
{
    for(int i=1; num>0; i+=2)
    {
        num -= i;
    }
    if(num==0)
    {
        return true;
    }
    else
    {
        return false;
    }
}
int main()
{
    long long n;
    while(~scanf("%lld",&n))
    {
        for(long long i=n; i>=0; i--)
            if(fun(i))
            {
                printf("%lld\n",i);
                break;
            }

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int main(){
    const double PI=3.14159265358979323846;
    int r;
    cin>>r;
    double ans = 0;
    ans = PI*(double)r*2.0;
    printf("%.14f\n",ans);
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 403, M = N << 1, mod = 1000000007;

int n, c;
int a[N], b[N];
LL sum[N][N], dp[N][N];

inline LL qpow(LL x, LL y)
{
	LL res = 1;
	while (y)
	{
		if (y & 1) res = res * x % mod;
		x = x * x % mod, y >>= 1;
	}
	return res;
}

int main()
{
	//File("");
	n = gi <int> (), c = gi <int> ();
	for (int i = 1; i <= n; i+=1) a[i] = gi <int> ();
	for (int i = 1; i <= n; i+=1) b[i] = gi <int> ();
	for (int i = 1; i <= 400; i+=1)
		for (int j = 0; j <= 400; j+=1)
			sum[i][j] = (sum[i - 1][j] + qpow(i, j)) % mod;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i+=1)
		for (int j = 0; j <= c; j+=1)
			for (int k = 0; k <= j; k+=1)
				dp[i][j] = (dp[i][j] + dp[i - 1][k] * ((sum[b[i]][j - k] - sum[a[i] - 1][j - k]) % mod + mod) % mod) % mod;
	printf("%lld\n", dp[n][c]);
	return 0;
}


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

int main() {
    int a,b;
    cin>>a>>b;
    cout<< (b-a)*(b-a+1)/2 -b<<endl;
    return 0;
    
   
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
#include <array>
using namespace std;
typedef long long ll;
int dist[200][200];
int color[200];
bool saiki(int v,int c)
{
	bool ret=true;
	color[v]=c;
	for(int i=0;i<200;i++)
	{
		if(dist[v][i]==1 && color[i]==c)
			return false;
		else if(dist[v][i]==1 && color[i]==0)
			ret&=saiki(i,-c);
	}
	return ret;
}
int main()
{
	int n;
	string s;
	cin>>n;
	fill(dist[0],dist[200],1e8-1);
	for(int i=0;i<n;i++)
	{
		cin>>s;
		dist[i][i]=0;
		for(int j=0;j<n;j++)
		{
			if(s[j]=='1')
				dist[i][j]=1;
		}
	}
	//二部グラフ判定
	fill(color,color+200,0);
	if(!saiki(0,1))
	{
		cout<<-1<<endl;
		return 0;
	}
	//ワーシャルフロイド
	for(int k=0;k<n;k++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(dist[i][j]>dist[i][k]+dist[k][j])
					dist[i][j]=dist[i][k]+dist[k][j];
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(dist[i][j]!=1e8-1)
				ans=max(ans,dist[i][j]);
		}
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)

int main( void ){
	std::string str, exp;
	std::cin >> str;
	std::cin >> exp;
	int array[ 26 ] = {};
	int rra[ 26 ] = {};
	rep( i, 0, 26 ){
		array[ i ] = -1;
		rra[ i ] = -1;
	}
	int length = str.length();
	rep( i, 0, length ){
		int a = (( int )exp[ i ] ) - ( int )'a';
		int b = (( int )str[ i ] ) - ( int )'a';
		if (array[ a ] != -1 && array[ a ] != b){
			printf("No\n");
			return 0;
		}
		if (exp[ i ] != str[ i ]){
			if (array[ a ] != -1 && array[ a ] != b || rra[ b ] != -1 && array[ a ] != b){
				printf( "No\n" );
				return 0;
			}
			array[ a ] = b;
			rra[ b ] = a;
		}
	}
	printf( "Yes\n" );
	return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<'\n'

int main(){
    int r;
    cin >> r;
    COUT(2*r*M_PI);
    return 0;
}


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

ll solve(string s,string t){
    int len=s.size();
    s='@'+s;
    vector < int > sum[26];
    for(char x=0;x<26;++x){
        sum[x].resize(len+1);
        sum[x][0]=0;
    }
    for(int j=1;j<=len;++j){
        for(char x=0;x<26;++x)
            sum[x][j]=sum[x][j-1];
        sum[s[j]-'a'][j]+=1;
    }
    
    ll i=0,dup=0;
    for(int j=0;j<t.size();++j){
        char x=t[j]-'a';
        //printf("t[%d] %c\n",j,x+'a');
        if(sum[x][len]-sum[x][i] == 0){
            i=0;
            dup+=1;
        }
        if(sum[x][len]-sum[x][i] == 0){
            return -1;
        }
        i=upper_bound(sum[x].begin()+i+1,sum[x].end(),sum[x][i])-sum[x].begin();
        //printf("then dup=%lld i=%lld\n",dup,i);
    }
    return dup*len+i;
}
int main(){
    string s,t;cin>>s>>t;
    cout<<solve(s,t)<<endl;
    return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
  
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
  
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  
typedef long long int ll;
  
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll MAXN=1000001;
const ll MAX_LOG=30;
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
}

int main()
{
    
  IOS
  ll n,m;
  cin>>n>>m;
  ll a[n][m],b[n][m];
  for(ll i=0;i<n;i++)
  {
    for(ll j=0;j<m;j++) cin>>a[i][j];
  }
  for(ll i=0;i<n;i++)
  for(ll j=0;j<m;j++)
  cin>>b[i][j];

  bool dp[n][m][(((n+1)+(m+1))*80)];
  ll M=(((n+1)+(m+1))*80);
  memset(dp,0,sizeof(dp));
  dp[0][0][abs(a[0][0]-b[0][0])]=1;
  for(ll i=0;i<n;i++)
  {
    for(ll j=0;j<m;j++)
      {
        if(i+1<n)
          for(ll x=0;x<M;x++) if(dp[i][j][x])
            dp[i+1][j][x+abs(a[i+1][j]-b[i+1][j])]=1,dp[i+1][j][abs(x-abs(a[i+1][j]-b[i+1][j]))]=1;
        if(j+1<m)
          for(ll x=0;x<M;x++) if(dp[i][j][x])
            dp[i][j+1][x+abs(a[i][j+1]-b[i][j+1])]=1,dp[i][j+1][abs(x-abs(a[i][j+1]-b[i][j+1]))]=1;
      }
  }
  for(ll i=0;i<M;i++)
  {
    if(dp[n-1][m-1][i]==1)
      {
        cout<<i<<endl;
        return 0;
      }
  }
  

    
  
  
} 
    


  
	

 

Measured memory_bytes: 81408
#include <iostream>
using namespace std;
int main()
{
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int res = 0;
	for (int a = 0; a <= A; ++a)
	{
		for (int b = 0; b <= B; b++)
		{
			for (int c = 0; c <= C; c++)
			{
				int total = 500 * a + 100 * b + 50 * c;
				if (total == X) ++res;
			}
		}
	}
	cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>

double a,b,x;

double l,r,mid;

bool ok(double alpha){
    double sita=(alpha/360.0)*2*3.1415926535;
    //if(alpha<=45.0){
     //   return a*a*b-(a*a*a*tan(sita)/2)>=x;
   // }
    //double sita=(alpha/360.0)*2*3.1415926535;
    double jote=a-b/tan(sita);
    double s=(jote+a)*b/2;
    //cout<<alpha<<" "<<jote<<endl;
    if(jote<0){
        return a*a*b-a*a*a*tan(sita)/2 >=x;
    }
    //cout<<alpha<<" "<<s<<endl;
    //r=a/sin(sita);
    //double h=r*cos(sita);
    //cout<<"]"<<h*a*a*1/2<<endl;
    //cout<<a*a*b-(a*tan(sita)*a*a*1/2)<<" "<<(a*tan(sita)*a*a*1/2)<<endl;
    return a*a*b-s*a >= x;
}
int main(){
    cin>>a>>b>>x;

    r=90.0,l=0.0;
    mid=(r+l)/2.0;

    for(int i=0;i<100;i++){
         //cout<<mid<<endl;
        bool ret=ok(mid);

        if(ret){
            l=mid;
        }
        else{
            r=mid;
        }
        mid=(r+l)/2;
    }

    printf("%.10lf\n",mid);
    return 0;
}


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

int main(){

    ll n;
    string s;
    cin >> n >> s;

    string AL="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string al="abcdefghijklmnopqrstuvwxyz";

    vector<ll> cnt(26,0);

    rep(i,n){
        rep(j,26){
            if(s[i]==al[j]){
                cnt[j]++;
            }
        }
    }

    ll ans=1;
    ll mo=1e+9+7;

    rep(i,26){
        if(cnt[i]>=1){
            ans*=cnt[i]+1;
            ans%=mo;
        }
    }

    cout << ans-1 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef unsigned long long ll;
int N, n, M, K;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;

vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; 
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; 
        dfs(G, next_v); 
    }
}

int main(){
    cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int from, to, weight;
        cin >> from >> to >> weight;
        G[from-1].push_back(to-1);
     	G[to-1].push_back(from-1);
    }
    int count = 0;
    seen.assign(N, false);
    for(int v = 0; v < N; ++v){
        if(seen[v]) continue;
        dfs(G, v);
      	++count;
    }
    cout << count<<"\n";
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
long long n,k,maxx;
string s;
int main()
{
	cin>>n>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='I') k++;
		else k--;
		maxx=max(maxx,k);
	}
	cout<<maxx<<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);
        int n = sc.nextInt();
        int tmp;
        int[] a = new int[n];
        for(int i = 0; i < a.length; i++){
            a[i] = sc.nextInt();
        }
        for(int j = 0; j < a.length/2; j++){
            tmp = a[j];
            a[j] = a[a.length - 1- j];
            a[a.length -1 - j] = tmp;
        }
        for(int k = 0; k < a.length; k++){
            System.out.printf("%d", a[k]);
            if(k < a.length - 1){
                System.out.printf(" ");
            }else{
                System.out.printf("\n");
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26804