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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v),v.end()))
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const ll MOD=1000*1000*1000+7;

const int N=2e5+6;
int ans[N];
int main(){
    //fastio;
    srng;
    #ifdef ALEXPC
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    string s;
    cin>>s;
    int n=s.length();
    FOR(i,n){
        int qan1=0,qan2=0,ind,sk=i;
        while(s[i]=='R'){
            i++;
            qan1++;
        }
        ind=i;
        while(s[i]=='L'){
            i++;
            qan2++;
        }
        ans[ind]=(qan1+qan2)/2;
        ans[ind-1]=(qan1+qan2)-ans[ind];
        if ((ind-sk)%2==0){
            swap(ans[ind],ans[ind-1]);
        }
        i--;
    }
    FOR(i,n)cout<<ans[i]<<" ";
    return 0;
}

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

int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    double area;
    int num = 0;
 
    area = (w*h)/2;
    cout << setprecision(6) << area;
    if ( x == (w/2) && y == (h/2) ) {
        num = 1;
        cout << " " << num << endl;
    } else {
        cout << " " << num << endl;
    }
    return 0;
}

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

int main() {

    long long int n, k;
    cin >> n >> k;

    long long int ans = 0;

    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        if ( in >= k ) ans++;
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        string subs = s.substr(i, n - i);
        string subt = t.substr(0, n - i);
        if (subs == subt)
            cnt = max(cnt,n - i);
    }
    cout << 2 * n - cnt << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
typedef struct{
  int parent;
  int left;
  int right;
} Tree;
Tree tree[1000000];
#define NIL -1
int main()
{
  int i,id,j,n,k,c[100000],depth=0,num;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    tree[i].parent=NIL;
    tree[i].left=NIL;
    tree[i].right=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c[j]);
      if(j==0){
	tree[c[0]].parent=id;
        tree[id].left=c[0];
      }
      else{
        tree[c[j]].parent=id;
        tree[c[j-1]].right=c[j];
      }
    }
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,tree[i].parent);
    num=i;
    while(tree[num].parent!=NIL){
      depth++;
      num=tree[num].parent;
    }
    printf("depth = %d,",depth);
    depth=0;
    if(tree[i].parent==NIL && tree[i].left==NIL){
       printf(" root, []\n");
    }
    else if(tree[i].parent==NIL && tree[i].left!=NIL){
      printf(" root, [%d",tree[i].left);
      for(j=tree[tree[i].left].right;j!=NIL;j=tree[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    else if(tree[i].left!=NIL){
      printf(" internal node, [%d",tree[i].left);
      for(j=tree[tree[i].left].right;j!=NIL;j=tree[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }

    else{
      printf(" leaf, []\n");
    }

  }
  return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define MP make_pair
#define PB push_back

const int MAX = 3e5+10;
const int MOD = 1e9+10;

int N, K;
bool edges[111][111];

int main() {
    cin >> N >> K;
    if (K > (N-1)*(N-2)/2) {
        cout << -1 << endl;
        return 0;
    }

    REP (i, N) REP (j, N) edges[i][j] = true;
    REP (a, N-1) FOR (b, a+1, N-1) {
        if (K) {
            K--;
            edges[a][b] = false;
        }
    }
    int count = 0;
    REP (a, N) FOR (b, a+1, N) {
        if (edges[a][b]) count++;
    }
    cout << count << endl;
    REP (a, N) FOR (b, a+1, N) {
        if (edges[a][b]) cout << a+1 << " " << b+1 << "\n";
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())

a = []
for i in range(N):
    line = list(map(int, input().split()))
    a.append(line)

# dp[i + 1][j]: i日目までの活動履歴のうち、最終日であるi日目にjを選んだ場合の幸福度の最大値

inf = float("inf")
n_pattern = 3
dp = [[-inf for _ in range(n_pattern)] for i in range(N + 1)]

for i in range(n_pattern):
    dp[0][i] = 0

for i in range(N):
    for j in range(n_pattern):
        for k in range(n_pattern):
            if k != j:
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][j])

print(max(dp[N]))


Measured memory_bytes: 86488
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int n, x;
    cin >> n >> x;
    int m = 2*n -1;

    if (x == 1 || x == m){
        cout << "No" << endl;
        return 0;
    }

    VI ans(m);
    if (x == n){
        REP(i,m) ans[i] = i+1;
    }else if (x < n){
        int p = n-x;
        REP(i,m) ans[(i+p) % m] = i+1;
    }else{
        int p = x-n;
        REP(i,m) ans[(i-p+m) % m] = i+1;
    }

    cout << "Yes" << endl;
    REP(i,m) cout << ans[i] << endl;


    return 0;
}

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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < (EPS))

#define COUNTER_CLOCKWISE (1)
#define CLOCKWISE (-1)
#define ONLINE_BACK (2)
#define ONLINE_FRONT (-2)
#define ON_SEGMENT (0)

struct Point 
{
  double x, y;
  
  Point() {}
  
  Point(double x, double y) : x(x), y(y) {}
  
  void input() { scanf("%lf %lf", &x, &y); }
  void output() { printf("%.10f %.10f\n", x, y); }
  double abs() { return (sqrt(norm())); }
  double norm() { return (x * x + y * y); }
  
  Point operator + (Point d) { return (Point(x + d.x, y + d.y)); }
  Point operator - (Point d) { return (Point(x - d.x, y - d.y)); }
  Point operator - () { return (Point(-x, -y)); }
  Point operator * (double a) { return (Point(x * a, y * a)); }
  Point operator / (double a) { return (Point(x / a, y / a)); }
  
};

struct Segment
{
  Point p1, p2;
  
  Segment() {}
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {}

  void input() { p1.input(); p2.input(); }
  
};

typedef Point Vector;
typedef vector < Point > Polygon;
typedef Segment Line;

double dot(Vector a, Vector b)
{
  return (a.x * b.x + a.y * b.y);
}

double cross(Vector a, Vector b)
{
  return (a.x * b.y - a.y * b.x);
}

Point project(Line l, Point p)
{
  Vector base = l.p2 - l.p1;
  return (l.p1 + base * (dot(p - l.p1, base) / base.norm()));
}

Point reflect(Line l, Point p)
{
  return (-p + project(l, p) * 2.0);
}

double getDistanceLP(Line l, Point p)
{
  return (abs(cross(l.p2 - l.p1, p - l.p1) / (l.p2 - l.p1).abs()));
}

double getDistanceSP(Segment s, Point p)
{
  if(dot(s.p2 - s.p1, p - s.p1) < 0.0) return ((p - s.p1).abs());
  if(dot(s.p1 - s.p2, p - s.p2) < 0.0) return ((p - s.p2).abs());
  return (getDistanceLP(s, p));
}

double getDistance(Segment s1, Segment s2)
{
  return (0.0);
}

int ccw(Point p0, Point p1, Point p2)
{
  Vector a = p1 - p0, b = p2 - p0;
  
  if(cross(a, b) > EPS) return (COUNTER_CLOCKWISE);
  if(cross(a, b) < -EPS) return (CLOCKWISE);
  if(dot(a, b) < -EPS) return (ONLINE_BACK);
  if(a.norm() < b.norm()) 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 intersect(Segment s1, Segment s2)
{
  return (intersect(s1.p1, s1.p2, s2.p1, s2.p2));
}

main()
{
  int n;

  cin >> n;
  for(int i = 0; i < n; i++) {
    Segment s1, s2;
    s1.input(); s2.input();
    cout << intersect(s1, s2) << endl;
  }

  return (0);
}

Measured memory_bytes: 3224
#include<stdio.h>

int main(){
	int N, A[1000], i, j, v, k;
	
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d", &A[i]);
	}
	
	for(k=0; k<N-1; k++){
			printf("%d ", A[k]);
		}
                printf("%d", A[N-1]);
		printf("\n");

	for(i=1; i<N; i++){
		v=A[i];
		j=i-1;
			while(j>=0 && A[j]>v){
			A[j+1] = A[j];
			j--;
			}
		A[j+1]=v;

		for(k=0; k<N-1; k++){
			printf("%d ", A[k]);
		}
		printf("%d", A[N-1]);
		printf("\n");
	}

return 0;

}


	
	

Measured memory_bytes: 604
#include"bits/stdc++.h"
using namespace std;

int main(){
  int n, m, flag=0;
  long long i, j, ans=0, k=0;
  vector<pair<long long, long long>> p;
  cin >> n >> m;
  vector<long long> a(n), b(m), c(m);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<m; i++) {
    cin >> b[i] >> c[i];
    p.push_back(make_pair(c[i], b[i]));
  }
  sort(a.begin(), a.end());
  sort(p.begin(), p.end(), greater<pair<long long, long long>>());

  for(j=0; j<m; j++){
    for(i=0; i<p[j].second; i++){
      if(a[k]<p[j].first){
        a[k] = p[j].first;
        k++;
      }else{
        flag=1;
        break;
      }
    }
    if(flag) break;
  }

  for(i=0; i<n; i++){
    ans += a[i];
  }

  cout << ans << endl;

return 0;
}


Measured memory_bytes: 4724
#include <iostream>

using namespace std;

int main() {
	int d, n;

	cin >> d >> n;

	if (d == 0) {
		if (n == 100) {
			cout << n + 1 << endl;
		}
		else {
			cout << n << endl;
		}
	}
	else if (d == 1) {
		if (n == 100) {
			cout << n * 100 + 100 << endl;
		}
		else {
			cout << n * 100 << endl;
		}
	}
	else if (d == 2) {
		if (n == 100) {
			cout << n * 10000 + 10000 << endl;
		}
		else {
			cout << n * 10000 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read


def main():
    N, D, A, *XH = map(int, read().split())
    monster = [0] * N
    for i, (x, h) in enumerate(zip(*[iter(XH)] * 2)):
        monster[i] = (x, (h + A - 1) // A)

    monster.sort()

    pos = []
    damage = []
    idx = 0
    cur_damage = 0

    for x, h in monster:
        while idx < len(pos) and pos[idx] < x:
            cur_damage -= damage[idx]
            idx += 1

        if h > cur_damage:
            pos.append(x + 2 * D)
            damage.append(h - cur_damage)
            cur_damage += h - cur_damage

    print(sum(damage))
    return


if __name__ == '__main__':
    main()


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

using namespace std;

const int MAX_N = 2000;
const int MOD = 1000000000 + 7;

int64_t nCr[MAX_N + 1][MAX_N + 1];

int main()
{
	for (int i = 0; i <= MAX_N; ++i) {
		nCr[i][0] = 1;
		nCr[i][i] = 1;
	}
	for (int i = 1; i <= MAX_N; ++i) {
		for (int j = 1; j < i; ++j) {
			nCr[i][j] = (nCr[i - 1][j - 1] % MOD + nCr[i - 1][j] % MOD) % MOD;
		}
	}
	int n, k; cin >> n >> k;
	for (int i = 0; i < k; ++i) {
		if (n - k >= i) {
			cout << (nCr[n - k + 1][i + 1] * nCr[k - 1][i]) % MOD << endl;
		} else {
			cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 30080
def main():
	# n,m = map(int,input().split())
	n = int(input())
	a = list(map(int,input().split()))
	
	ans = 0
	for i in range(n-2):
		# print(a[i], a[i+1], a[i+2])
		if a[i] < a[i+1] and a[i+1] < a[i+2]:
			ans +=1
		elif a[i] > a[i+1] and a[i+1] > a[i+2]:
			ans +=1
	print(ans)
	

	
 
if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
using System;
using System.Linq;

namespace Aiging
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();
            var As = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            
            
            var result = 0;
            for(var i = 1; i <= int.Parse(n); i++)
            {
                if(i % 2 == 1 && As[i - 1] % 2 == 1)
                    result++;
            }
            Console.WriteLine(result.ToString());
        }
    }
}


Measured memory_bytes: 28260
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

#define INF 1000000000

int main() {
  int a, b, c, x, y, i, ans = INF;
  cin >> a >> b >> c >> x >> y;
  for (i = 0; i <= max(x, y); i++) {
    ans = min(ans, 2 * c * i + a * max(0, x - i) + b * max(0, y - i));
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=233;
const ll mod=1e9+7;
const int inf=(1<<30);
ll q,h,s,d,n;
ll h1,s1,d1;
int main(){
    cin>>q>>h>>s>>d>>n;
    h1=min(q*2,h);
    s1=min(s,h1*2);
    d1=min(d,s1*2);
    cout<<(n/2)*d1+(n%2)*s1<<endl;
}


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

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int A, B;
    cin >> A >> B;
    rep(i, 0, 10000) {
        if(i * 8 / 100 == A && i * 10 / 100 == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define INFINITY 100000
int cost[20][20];

int dijkstra(int n, int s, int g){
  set<int> S;
  S.insert(s);
  int distance[n];
  REP(i,n)
    distance[i] = cost[s][i];
  while(S.find(g) == S.end()){
    int sol,mindis=INFINITY;
    REP(i,n)
      if(S.find(i) == S.end()&&distance[i]<mindis){
        mindis = distance[i];
        sol = i;
      }
    S.insert(sol);
    REP(i,n)
      distance[i] = min(distance[i],distance[sol] + cost[sol][i]);
  }
  return distance[g];
}

int main(void){
  int n,m,x1,x2,y1,y2;
  REP(i,20)
    REP(j,20)
      cost[i][j] = (i!=j)?INFINITY:0;
  cin>>n>>m;
  while(m--){
    int a,b,c,d;
    cin>>a; getchar(); cin>>b; getchar(); cin>>c; getchar(); cin>>d;
    cost[a-1][b-1] = c;
    cost[b-1][a-1] = d;
  }
  cin>>x1; getchar(); cin>>x2; getchar(); cin>>y1; getchar(); cin>>y2;
  cout << y1 - y2 - dijkstra(n,x1-1,x2-1) - dijkstra(n,x2-1,x1-1) << endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  unordered_set<int> a;
  for(int i=0;i<m;i++)
  {
    int p;
    cin>>p;
    for(int j=0;j<p;j++)
    {
      int q;
      cin>>q;
      a.insert(q);
    }
  }
  int cnt=0;
  for(int i=1;i<=n;i++)
  {
    if(!a.count(i))
      cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
    double x1, x2, x3;
    double y1, y2, y3;
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    cin >> x3 >> y3;
    double a = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    double b = sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
    double c = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
    double S = abs((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1));
    double R = S/(a+b+c);
    double M = max(max(a, b), c);
    double ans = M*R/(2*R+M);
    
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define INF (ll)1000000007
// chmax chmin
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 main(void){

    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    ll a[N], b[N], c[N];
    ll amax = 0, bmax = 0;
    REP(i,N){
        cin >> a[i] >> b[i] >> c[i];
        amax += a[i];
        bmax += b[i];
    }

    ll dp[N+1][amax+1][bmax+1];
    REP(i,N+1)REP(j,amax+1)REP(k,bmax+1){
        dp[i][j][k] = INF;
    }
    REP(i,N+1) dp[i][0][0] = 0;

    FOR(i,1,N+1)FOR(j,1,amax+1)FOR(k,1,bmax+1){
        if(j-a[i-1] >= 0 && k-b[i-1] >= 0) chmin(dp[i][j][k], dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1]);
        chmin(dp[i][j][k], dp[i-1][j][k]);
    }

    ll ans = INF;
    int ma = Ma, mb = Mb;
    while(ma <= amax && mb <= bmax){
        chmin(ans, dp[N][ma][mb]);
        ma += Ma; mb += Mb;
    }

    if(ans == INF) ans = -1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 18560
#include <cstdlib>
#include <iostream>
#include <vector>

void dfs(int i, std::vector<std::vector<int>>& graph, std::vector<int>& in, std::vector<long>& dp, std::vector<bool>& visited) {
    visited[i] = true;
    for(auto n : graph[i]) {
        dp[n] = std::max(dp[n], dp[i] + 1);
        --in[n];
        if(in[n] == 0) {
            dfs(n, graph, in, dp, visited);
        }
    }
}


int main() {
    int N, M;
    std::cin >> N >> M;
    std::vector<std::vector<int>> graph(N, std::vector<int>{});
    std::vector<int> in(N, 0);
    for(int i = 0; i < M; ++i) {
        int x,y;
        std::cin >> x >> y;
        graph[x-1].push_back(y-1);
        ++in[y-1];
    }
    std::vector<bool> visited(N, false);
    std::vector<long> dp(N, 0);
    for(int i = 0; i < N; ++i) {
        if(!visited[i] && in[i] == 0) {
            dfs(i, graph, in, dp, visited);
        }
    }
    long max = 0;
    for(int i = 0; i < N; ++i){
        max = std::max(max, dp[i]);
    }
    std::cout << max << "\n";
}

Measured memory_bytes: 17576
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define repB(i, z, n) for(int i = n - 1; i >= z; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*
import java.lang.Math.*


fun main() {
    val N = rd.readInt()
    val NMAX = 10000
    val f = IntArray(NMAX+1){0}

    for (x in 1 .. 100) {
        for (y in 1 .. 100) {
            for (z in 1 .. 100) {
                val n = x*x + y*y + z*z + x*y + y*z + z*x
                if (n in 1 .. NMAX) {
                    f[n] += 1
                }
            }
        }
    }

    for (i in 1 .. N) {
        println(f[i])
    }
}


//val rd = debug.Reader("abc", "168", "c", "sample-1")
val rd = Reader()
fun main(args: Array<String>) {
    Thread(null, MainThread(), "mainThread", 128 * 1024 * 1024).start()
}


const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
class MainThread : Runnable {
    override fun run() { main() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 37832
sx,sy,tx,ty=map(int,input().split())
s="U"*(ty-sy)
s+="R"*(tx-sx)
s+="D"*(ty-sy)
s+="L"*(tx-sx)
s+="L"+"U"*(ty-sy+1)
s+="R"*(tx-sx+1)+"D"
s+="R"+"D"*(ty-sy+1)
s+="L"*(tx-sx+1)+"U"
print(s)


Measured memory_bytes: 38384
n = int(input())
v = [0] * 100010
a = list(map(int, input().split()))
for i in range(n):
    v[a[i]] += 1
ans = 0
for i in range(100010):
    ans += i * v[i]
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    ans -= b * v[b]
    ans += c * v[b]
    print(ans)
    v[c] += v[b]
    v[b] = 0

Measured memory_bytes: 21536
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005

int n,m,tot,pps,pp;
int now[maxn],pre[maxn*2],son[maxn*2],deg[maxn],f[maxn];

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

inline void print(int x){
	if (x<0){putchar('-'); x=-x;}
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}

void add(int a,int b){son[++tot]=b,pre[tot]=now[a],now[a]=tot;}
void link(int a,int b){add(a,b),add(b,a),++deg[a],++deg[b];}

int top;
int stack[maxn];
bool can;

bool check1(int x){
	for (int i=1,j=top;i<j;i++,j--){
		if (i==x) ++i; if (j==x) --j; if (i>=j) break;
		if (stack[i]+stack[j]>pps) return 0;
	}
	return 1;
}

void tree_dp(int x,int fa){
	if (!can) return;
	for (int p=now[x];p;p=pre[p])
		if (son[p]!=fa) tree_dp(son[p],x);
	top=0;
	for (int p=now[x];p;p=pre[p])
		if (son[p]!=fa) stack[++top]=f[son[p]];
	if (~top&1) stack[++top]=0;
	sort(stack+1,stack+top+1);
	int l=1,r=top,res=-1;
	while (l<=r){
		int mid=(l+r)>>1;
		if (check1(mid)) res=mid,r=mid-1;
		else l=mid+1;
	}
	if (res==-1){can=0; return;}
	f[x]=stack[res]+1;
}

bool check(int x){
	memset(f,0,sizeof(f));
	pps=x,can=1; tree_dp(pp,0);
	//	for (int i=1;i<=n;i++) printf("%d %d\n",i,f[i]);
	return can&&f[pp]<=x+1;
}

int main(){
	n=read();
	for (int i=1,x,y;i<n;i++) x=read(),y=read(),link(x,y);
	int ans=0;
	for (int i=1;i<=n;i++) ans+=deg[i]&1; cout<<(ans>>1)<<' ';
	for (int i=1;i<=n;i++) if (deg[i]==1){pp=i; break;}
	int l=1,r=n,res=n+1;
	while (l<=r){
		int mid=(l+r)>>1;
		if (check(mid)) r=mid-1,res=mid;
		else l=mid+1;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 7680
NUMS = {n for n in range(1, 14)}
P = ['S', 'H', 'C', 'D']
CARDS = {'S': set(), 'H': set(), 'C': set(), 'D': set()}

N = int(input())
for i in range(N):
    m, n = input().split()
    CARDS[m].add(int(n))
for p in P:
    ans = sorted(list(NUMS - CARDS[p]))
    for n in ans:
        print(p, n)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K % 2 == 0){
        cout << A-B << endl;
    }else{
        cout << B-A << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  string S, ans;
  cin >> N >> S >> K;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == S.at(K - 1)) {
      ans += S.at(K - 1);
    }
    else {
      ans += '*';
    }
  }
  cout << ans << endl;
  return 0;
}


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

long long GCD(long long n, long long m)
{
  return m ? GCD(m, n % m) : n;
}

int main()
{
  long long n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;

  long long g = GCD(n, m);
  long long res = n / g * m;
  n /= g, m /= g;
  bool ok = true;
  for (long long i = 0; i < g; i++)
  {
    if (s[i * n] != t[i * m])
      ok = false;
  }
  if (ok)
    cout << res << endl;
  else
    cout << -1 << endl;
}

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

int main() {
  string num;
  int B[4], flag = 0;

  cin >> num;
  for (string::size_type index = 0; index != num.size(); ++index) {
    B[index] = (int)(num[index]) - 48;
  }

  if (B[0] == B[1])
    flag = 1;
  else if (B[1] == B[2])
    flag = 1;
  else if (B[2] == B[3])
    flag = 1;

  if (flag)
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
       
        public static long gcd(long x,long y)
        {
            if (x < y) gcd(y, x);
            
            while (y > 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }

        public static long lcm(long x,long y)
        {
            return x * y / gcd(x, y);
        }



        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);


            var s = ReadLine();
           
            var a = new long[s.Length+1];
            var b = new long[s.Length + 1];

            long ans = 0;
            var count = 1;
            a[0] = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '<')
                {
                    a[i+1] = count;
                    count++;
                }
                else count = 1;
            }
            count = 1;
            b[s.Length] = 0;
            for (int i = s.Length-1; i >=0; i--)
            {
                if (s[i] == '>')
                {
                    b[i] = count;
                    count++;
                }
                else count = 1;
            }

            for (int i = 0; i <=s.Length; i++)
            {
                ans += Math.Max(a[i], b[i]);
            }
            WriteLine(ans);
          
            Out.Flush();
        }
    }
}




Measured memory_bytes: 26332
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long N){
  int n = 0;
  while(n < N){
    n += 1000;
  }
  cout << n-N << endl;
}

int main(){
    long long N;
				scanf("%lld",&N);
    solve(N);
    return 0;
}


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

#define rep(i, N) for (ll i = 0; i < N; i++)

using ll = long long;
using namespace std;


int main() {
    int N, M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    
    bool flag = false;
    rep(lux, N-M+1) {
        rep(luy, N-M+1) {
            if(A[lux][luy] == B[0][0]) {
                bool chflag = true;
                rep(dx, M) {
                    rep(dy, M) {
                        int cx = lux + dx;
                        int cy = luy + dy;
                        if(A[cx][cy] != B[dx][dy]) {
                            chflag = false;
                            break;
                        }
                    }
                    if(!chflag) break;
                }
                if(chflag) flag = true;
            }
            if(flag) break;
        }
        if(flag) break;
    }
    
    
    string ans = ( flag ? "Yes" : "No" );
    cout << ans << "\n";
    return 0;
}


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

int main() {
  int N, L;
  cin >> N >> L;
  
  vector<string> words(N);
    
  for (int i = 0; i < N; i++) cin >> words.at(i);
  
  sort(words.begin(), words.end());
  
  string answer;
  
  for (int i = 0; i < N; i++) answer += words.at(i);
  
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int row, col;
char grid[1005][1005];
int dist[1005][1005];

int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
const int inf=1e10;

bool isSafe(int x,int y){
    if(x<=0 || y<=0 || x>row || y>col || grid[x][y]=='#' )return false;
    return true;
}

int32_t main() {

    fast

    cin >> row >> col;
    int sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;


    for(int i=1;i<=row;i++){
        for(int j=1;j<=col;j++){
            cin>>grid[i][j];
            dist[i][j]=inf;
        }
    }

    deque<int>xs,ys;
    dist[sx][sy]=0;
    xs.push_back(sx);
    ys.push_back(sy);
    int newX,newY;
    while(!xs.empty()){
        int curX=xs.front();xs.pop_front();
        int curY=ys.front();ys.pop_front();

        for(int i=0;i<4;i++){
            newX=curX+dx[i];
            newY=curY+dy[i];
            if(!isSafe(newX,newY))continue;

            if(dist[newX][newY]>dist[curX][curY]){
                dist[newX][newY]=dist[curX][curY];
                xs.push_front(newX);
                ys.push_front(newY);
            }
        }

        for(int x=curX-2;x<=curX+2;x++){
            for(int y=curY-2;y<=curY+2;y++){
                if(!isSafe(x,y))continue;

                if(dist[x][y]>dist[curX][curY]+1){
                    dist[x][y]=dist[curX][curY]+1;
                    xs.push_back(x);
                    ys.push_back(y);
                }
            }
        }
    }
    if(dist[ex][ey]>=inf){
        cout<<-1<<endl;
    }
    else{
        cout<<dist[ex][ey]<<endl;
    }


    return 0;
}



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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100050

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

ll DIGIT[MAX][13];

//
int main(){
	string S;
	cin >> S;
	int N = S.size();

	V M(N+1);
	M[1] = 1;
	REPS(i,2,N+1){
		M[i] = (M[i-1]*10)%13;
	}

	if(S[N-1]=='?')REP(i,10)DIGIT[1][i]=1;
	else DIGIT[1][S[N-1]-'0'] = 1;

	REPS(i,1,N){
		REP(j,13){
			if(S[N-i-1]=='?'){
				REP(k,10){
				//	cout << " " << ((j+M[i+1]*k)%13);
					DIGIT[i+1][(j+M[i+1]*k)%13] += DIGIT[i][j];
					DIGIT[i+1][(j+M[i+1]*k)%13] %= MOD;
				}
				//cout << endl;
			}else{
				//printf("%d [%d:%d]\n",((j+M[i+1]*(S[N-i-1]-'0'))%13) ,j, DIGIT[i][j] );
				DIGIT[i+1][(j+M[i+1]*(S[N-i-1]-'0'))%13] += DIGIT[i][j];
				DIGIT[i+1][(j+M[i+1]*(S[N-i-1]-'0'))%13] %= MOD;
			}
		}
	}

	cout << DIGIT[N][5]  << endl;

	return 0;
}




Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const ll INF = 1001001001;
const ll MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  pair<int, pair<int, int>> p[100];
  rep(i, n){
    int x, y, h;
    cin >> x >> y >> h;
    p[i] = make_pair(h, P(x, y));
  }
  sort(p, p+n);
  reverse(p, p+n);
  for(int i = 0; i < 101; i++){
    for(int j = 0; j < 101; j++){
      int H = p[0].first + abs(p[0].second.first - i) + abs(p[0].second.second - j);
      bool flag = true;
      for(int k = 1; k < n; k++){
        if(max(H - abs(p[k].second.first - i) - abs(p[k].second.second - j), 0) != p[k].first){
          flag = false;
          break;
        }
      }
      if(flag){
        printf("%d %d %d\n", i, j, H);
      }
    }
  }
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    cout << "AB"[abs(x - a) > abs(x - b)] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define MOD 1000000007
int n;
vector<int> adj[100100];
long long dp1[100100], dp2[100100];
void dfs (int x, int p) {
	dp1[x] = dp2[x] = 1;
	for (auto i: adj[x]) {
		if (i == p) continue;
		dfs(i, x);
		dp1[x] = (dp1[x]*dp2[i])%MOD;
		dp2[x] = (dp2[x]*(dp1[i]+dp2[i])%MOD)%MOD;
	}
}
int main () {
	cin >> n;
	int ai, bi;
	for (int i=0; i<n-1; i++) {
		cin >> ai >> bi;
		ai--; bi--;
		adj[ai].push_back(bi);
		adj[bi].push_back(ai);
	}
	dfs(0, 0);
	cout << (dp1[0]+dp2[0])%MOD << endl;
}

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

# 文字列の入力
s = str(input())

# 配列に一文字ずつ格納
colors = list(s)

prev = int(colors[0])
changeCnt = 0

for i in range(1,len(colors)):

    if prev == int(colors[i]):
        colors[i] = abs(int(colors[i])-1)
        changeCnt += 1
    
    prev = int(colors[i])

# 出力
print(str(changeCnt))


Measured memory_bytes: 3956
import math

a, b, x = map(int, input().split())

if x/(a*a*b) <= 0.5: #水が水筒の半分以下の場合
    area = x/a
    tan = area*2/(b*b)
    d = 90 - math.degrees(math.atan(tan))
else:
    rest = (a*a*b - x)/a
    tan = rest*2/(a*a) #空の部分の面積は、a*atanθ/2 = a*a*b - x
    d = math.degrees(math.atan(tan))

print(d)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define rep(i,n) for(int i=0;i<n;i++)

typedef vector<int> vi;
typedef vector<vi> vvi;

const int INFTY=1<<29;

pair<vi,int> solve(int v,vvi& dist,map<pair<vvi,int>,pair<vi,int> >& memo)
{
	map<pair<vvi,int>,pair<vi,int> >::iterator it=memo.find(make_pair(dist,v));
	if(it!=memo.end())
		return it->second;
	
	int n=dist.size();
	pair<vi,int> res;
	rep(i,n){
		if(dist[v][i]==INFTY)
			continue;
		int d=dist[v][i];
		dist[v][i]=dist[i][v]=INFTY;
		pair<vi,int> temp=solve(i,dist,memo); temp.second+=d;
		if(temp.second>res.second || temp.second==res.second && temp.first<res.first)
			res=temp;
		dist[v][i]=dist[i][v]=d;
	}
	res.first.insert(res.first.begin(),v);
	return memo[make_pair(dist,v)]=res;
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vvi dist(n,vi(n,INFTY));
		rep(i,m){
			int s,d,w; cin>>s>>d>>w;
			dist[s-1][d-1]=dist[d-1][s-1]=w;
		}
		map<pair<vvi,int>,pair<vi,int> > memo;
		pair<vi,int> res;
		rep(i,n){
			pair<vi,int> temp=solve(i,dist,memo);
			if(temp.second>res.second || temp.second==res.second && temp.first<res.first)
				res=temp;
		}
		cout<<res.second<<endl;
		rep(i,res.first.size())
			cout<<(res.first[i]+1)<<(i==res.first.size()-1?'\n':' ');
	}
	
	return 0;
}

Measured memory_bytes: 1836
//洛谷P1919
#include<bits/stdc++.h>
#include<complex>
using namespace std;

const int N=3e6+10;
const long double PI=acos(-1);
typedef complex<long double> Complex;
struct FastFourierTransform  {
    Complex omega [N], omegaInverse [N] ;
    void init ( int n )  {
        for ( int i = 0 ; i < n ; ++ i )  {
            omega [i] = Complex ( cos ( 2 * PI / n * i), sin ( 2 * PI / n * i ) ) ;
            omegaInverse [i] = conj(omega [i]);
        }
    }
    void transform ( Complex *a, int n, const Complex* omega ) {
        for ( int i = 0, j = 0 ; i < n ; ++ i )  {
            if ( i > j )  swap ( a [i], a [j] ) ;
                for( int l = n >> 1 ; ( j ^= l ) < l ; l >>= 1 ) ;
	    }
        for ( int l = 2 ; l <= n ; l <<= 1 )  {
            int m = l >> 1;
            for ( Complex *p = a ; p != a + n ; p += l )
                for ( int i = 0 ; i < m ; ++ i )  {
                    Complex t = omega [n / l * i] * p [m + i] ;
                    p [m + i] = p [i] - t ;
                    p [i] += t ;
                }
        }
    }
    void dft ( Complex *a, int n )  {
        transform ( a, n, omega ) ;
    }
    void idft ( Complex *a, int n )  {//逆变换
        transform ( a, n, omegaInverse ) ;
        for ( int i = 0 ; i < n ; ++ i ) a [i] /= n ;
    }
} fft ;
Complex a[N];

typedef long long ll;
ll P=200003;
ll c[N];
int idx[200003];
int Pow[200003];

int main(){
    ll tmp=1;
    for(int i=0;i<=P-2;++i){
        idx[tmp]=i;
        Pow[i]=tmp;
        tmp=tmp*2%P;
    }
    int n;
    scanf("%d",&n);
    ll ans=0;
    for(int i=0;i<n;++i){
        scanf("%lld",c+i);
        if(c[i]==0)continue;
        a[idx[c[i]]]+=Complex(1,0),ans-=c[i]*c[i]%P;
    }
    
    tmp=1;
    n=2*P;
    while(tmp<n)tmp<<=1;
    n=tmp;
    fft.init(n);
    fft.dft(a,n);
    for(int i=0;i<n;++i)a[i]*=a[i];
    fft.idft(a,n);
    
    for(int i=0;i<n;++i){
        ans+=(ll)(a[i].real()+0.5)*Pow[i%(P-1)];
    }
        
    ans/=2;
    printf("%lld",ans);
    return 0;
}
/*
3
2019 2020 200002
*/

Measured memory_bytes: 56376
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		double a=sc.nextInt();
		double b=sc.nextInt();
		double h=sc.nextInt();
		double m=sc.nextInt();
		
		double t=h*60+m;
		
		
		//double hx = Math.sin(Math.toRadians(t*0.5))*3;
		//double hy = Math.cos(Math.toRadians(t*0.5))*3;
		double hx = Math.cos(Math.toRadians(t*0.5-90))*a;
		double hy = Math.sin(Math.toRadians(t*0.5-90))*a;
		//System.out.println(hx);
		//System.out.println(hy);
		
		//double mx = Math.sin(Math.toRadians(t/6))*4;
		//double my = Math.cos(Math.toRadians(t/6))*4;
		double mx = Math.cos(Math.toRadians(t*6-90))*b;
		double my = Math.sin(Math.toRadians(t*6-90))*b;
		//System.out.println(mx);
		//System.out.println(my);
		
		double d = Math.sqrt((hy-my)*(hy-my)+(hx-mx)*(hx-mx));
		System.out.println(d);
		
	}

}


Measured memory_bytes: 35980
a, b = map(int, input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

agcd = gcd(a,b)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            return False

    return True

x = make_divisors(agcd)
ans = 1
for _x in x:
    ans += is_prime(_x)

print(ans)


Measured memory_bytes: 41324
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int a = sc.nextInt();
    
    if ((n % 500) <= a || n <= a) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
// const int MOD = 1e9 + 7;
const int MOD = 10007;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, ans;
int fc[N];
std::vector< Pair > edges;
std::vector<int> g[N];
std::map< Pair, int > col;

void dfs(int x, int fa, int fc) {
    int now = 0;
    for (auto to : g[x]) {
        if (to == fa) continue;
        now++;
        if (now == fc) now++;
        col[mp(x, to)] = col[mp(to, x)] = now;
        dfs(to, x, now);
    }
}

int main() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
        edges.push_back(mp(u, v));
    }
    for (int i = 1; i <= n; i++) ans = std::max(ans, (int)g[i].size());
    dfs(1, -1, -1);
    printf("%d\n", ans);
    for (auto e : edges) {
        printf("%d\n", col[e]);
    }
    return 0;
}

Measured memory_bytes: 21368
import math

a,b,x=list(map(int, input().split()))

if x/(a**2)/b < 1/2:
    print(180*math.atan((a*b**2)/(2*x))/math.pi)

else:
    print(180*math.atan(2*(a*b-x/a)/(a**2))/math.pi)
    


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

ll k, q, d[5010], n, x, m;

signed main() {
	cin >> k >> q;
	for (int i = 0; i < k; i++)cin >> d[i];
	for (int i = 0; i < q; i++) {
		cin >> n >> x >> m;
		ll cnt = x % m, ans = 0;
		for (int j = 0; j < k; j++) {
			ll p = 0;
			ll s = d[j] % m;
			if (s == 0)s = m;
			if (j < (n - 1) % k)p = (n - 1) / k + 1;
			else p = (n - 1) / k;
			cnt += s * p;
		}
		ans += cnt / m;
		cout << n - 1 - ans << endl;
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int x, a, b;
   cin >> x >> a >> b;
   int ans = 0;
   x -= a;

   while(x >= 0){
      x -= b;
   }
   cout << x + b << endl;

   return 0;
}

Measured memory_bytes: 256