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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, a, b) for(int i = a; i <= b; i++) 
#define ford(i, a, b) for(int i = a; i >= b; i--) 
#define endl "\n"
#define scv(a, b, c) #a#b#c
#define com(a,b) a ## b

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 3e3 + 1;
const ll MOD = 998244353;
const ll oo = 1e18 + 7;
const int BASE = 10000;

vector<vi> g;
vi check, res;

void dfs(int u) {
    check[u] = 1;
    for (int v : g[u]) {
        if (!check[v]) {
            res[v] += res[u];
            dfs(v);
        }
    }
}

void solve() {
    int n, q;
    cin >> n >> q;
    g = vector<vi>(n + 1);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    check = res = vi(n + 1);
    while (q--) {
        int p, x;
        cin >> p >> x;
        res[p] += x;
    }
    dfs(1);
    for (int i = 1; i <= n; i++) {
        cout << res[i] << " ";
    }
}

int main() {
    #ifdef DEBUG
        com(fre, open) (scv(solve, ., inp), "r", stdin);
        com(fre, open) (scv(solve, ., out), "w", stdout);
    #endif
    ios_base::sync_with_stdio(1);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 21120
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author indy256
 */

#include <bits/stdc++.h>

using namespace std;

void solve(istream &in, ostream &out) {
    int n;
    in >> n;

    vector<int> x(n), y(n);
    for (int i = 0; i < n; ++i) {
        in >> x[i] >> y[i];
    }

    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    double res = 0;
    do {
        for (int i = 0; i + 1 < n; ++i) {
            int dx = x[p[i]] - x[p[i + 1]];
            int dy = y[p[i]] - y[p[i + 1]];
            res += sqrt((double) dx * dx + dy * dy);
        }
    } while (next_permutation(p.begin(), p.end()));

    for (int i = 0; i < n; ++i) {
        res /= i + 1;
    }
    out << setprecision(10) << res << '\n';
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, l;
    cin >> n >> l;
    vector<int> a(n,l);
    for(int i=0;i<n;++i) {
        a[i] += i;
    }

    int b = (1<< 30);
    for(int i=0;i<n;++i) {
        if(abs(a[i]) < abs(b)) b = a[i];
    }
    

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

    cout << ans << endl;
}


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

using ll = long long;

int main() {
    ll N, MOD = 1e9 + 7, ans = 1;
    string S;
    cin >> N >> S;
    vector<int> A(26, 1);
    rep(i, N) {
        A[S[i] - 'a']++;
    }
    rep(i, 26) {
        ans = (ans * A[i]) % MOD;
    }
    cout << ans - 1 << "\n";
}

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

int main()
{
  int a, b;
  
  cin >> a >> b;
  switch (a * b % 2)
  {
    case 0:
      cout << "Even";
      break;
    case 1:
      cout << "Odd";
      break;
    default:
      break;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
char a[110];
int main(){
    int s=0;
    scanf("%s",a);
    for(int i=0;a[i]!='\0';i++){
        if(s==0 && a[i]=='C')s=1;
        if(s==1 && a[i]=='F')s=2;
    }
    if(s==2) printf("Yes\n");
    else printf("No\n");
    
}

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

int dis[1005][1005];
int h, w;
int mx[] = {-1, 0, 1, 0};
int my[] = {0, -1, 0, 1};
queue<P> que;

void bfs() {
  while (!que.empty()) {
    P tmp = que.front(); que.pop();
    int x, y;
    x = tmp.first; y = tmp.second;
    rep(i, 4) {
      int tx, ty;
      tx = x + mx[i]; ty = y + my[i];
      if (dis[tx][ty] < 0) {
        dis[tx][ty] = dis[x][y] + 1;
        que.push(P (tx,ty));
      }
    }
  }
}

int main() {
  cin >> h >> w;
  rep(i, h) {
    rep(j, w) {
      char c;
      cin >> c;
      if (c == '#') que.push(P (i+1, j+1));
      else dis[i+1][j+1] = -1;
    }
  }
  bfs();
  int ans = 0;
  rep(i, h)rep(j, w) ans = max(ans, dis[i+1][j+1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


ll LargestRectangle(vector<ll> h){
    ll n=(ll)h.size();
    stack<pair<ll,ll>> st;//高さ，index
    st.push(make_pair(-LINF,-1));//ばんぺいくん
    ll ret=0;
    rep(i,n){
        while(h[i]<st.top().first){
            auto p=st.top();st.pop();
            chmax(ret,(i-st.top().second-1)*p.first);
        }
        st.push(make_pair(h[i],i));
    }
    while(!st.empty()){
        auto p=st.top();st.pop();
        if(p.first==-LINF) continue;
        chmax(ret,(n-st.top().second-1)*p.first);
    }
    return ret;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    vector<ll> h(n);
    rep(i,n){
        cin>>h[i];
    }
    cout<<LargestRectangle(h)<<endl;
    return 0;
}



Measured memory_bytes: 6208
import bisect

N = int(input())
A = sorted(list(map(int, input(). split())))
B = list(map(int, input(). split()))
C = sorted(list(map(int, input(). split())))

ans = 0

for b in B:
   ans += (bisect.bisect_left(A,b)) *(N - bisect.bisect_right(C,b))

print(ans)

Measured memory_bytes: 23348
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long 
#define mod 1000000007
bool bo=0,b[100000000];
int main()
{
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		ll q,w;
		cin>>q>>w;
		if(q==1 && b[w]==1) bo=1;
		if(w==n && b[q]==1) bo=1;
		if(q==1 && w==n)
		{
			bo=1;
		}
		if(q==1)
		{
			b[w]=1;
		}
		if(w==n)
		{
			b[q]=1;
		}

	}
	if(bo==1)
	{
		cout<<"POSSIBLE"<<endl;
	}
	else
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
int main() {
        int N; cin >> N;
        int H[N], dp[N];
        for (int i=0; i<N; i++) {
                cin >> H[i];
                if (i==0) dp[i] = 0;
                else if (i==1) dp[i] = abs(H[1]-H[0]);
                else {
                        dp[i] = min(
                                abs(H[i]-H[i-1]) + dp[i-1],
                                abs(H[i]-H[i-2]) + dp[i-2]);
                }
        }
        cout << dp[N-1] << "\n";
        return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    int n,m;
    cin >> n >> m;
    int s,t;
    VVI es(n);
    REP(i,0,m) {
        cin >> s >> t;
        --s; --t;
        es[s].push_back(t);
    }

    double ans = n;
    REP(i,0,n) {
        vector<double> d(n);
        RREP(j,0,n-1) {
            double maxe = 0;
            double sum = 0;
            for (int &dst: es[j]) {
                sum += d[dst];
                maxe = max(maxe, d[dst]);
            }
            if (j == i && es[j].size() > 1) {
                sum -= maxe;
                d[j] = 1 + sum / (es[j].size() - 1);
            } else {
                d[j] = 1 + sum / es[j].size();
            }
        }
        ans = min(ans, d[0]);
    }
    printf("%.7lf\n", ans);
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
void dfs(ll u,bool visited[],vector<ll> vect[],ll &c){
	visited[u] = true;
	c++;
	for(ll i=0;i<vect[u].size();i++){
		if(visited[vect[u][i]]==false){
			dfs(vect[u][i],visited,vect,c);
		}
	}
}
int main(){
     ll n,m,u,v;
     cin>>n>>m;
     vector<ll> vect[n+1];
     for(ll i=0;i<m;i++){
     	cin>>u>>v;
     	vect[u].push_back(v);
     	vect[v].push_back(u);
	 }
	 bool visited[n+1];
	 memset(visited,false,sizeof(visited));
	 ll ma = INT_MIN;
	 for(ll i=1;i<=n;i++){
	 	if(!visited[i]){
	 		ll c=0;
	 		dfs(i,visited,vect,c);
	 		ma = max(c,ma);
		 }
	 }
	 cout<<ma<<endl;
}

Measured memory_bytes: 23996
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

void dfs(int N, string now) {
    if ((int)now.size() == N) {
        cout << now << endl;
        return;
    }
    vector<bool> used(26, false);
    for (auto& c : now) {
        if (used[c - 'a']) {
            continue;
        }
        used[c - 'a'] = true;
        dfs(N, now + c);
    }
    rep(i, 0, 26) {
        bool not_exist = true;
        for (auto& c : now) {
            if (c == (char)(i + 'a')) {
                not_exist = false;
                break;
            }
        }
        if (not_exist) {
            dfs(N, now + (char)(i + 'a'));
            break;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    dfs(N, "a");
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int dx[8] = { 1,0,-1,0,1,-1,-1,1 };
int dy[8] = { 0,1,0,-1,1,1,-1,-1 };

int main() {
	int n; CI n;
	for (int i = 0;i<30; i++) {
		for (int j = 0;j<16; j++) {
			if (i * 4 + j * 7 == n) { CO "Yes" EN; return 0; }
		}
	}
	CO "No" EN;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int N;
map<int, int> mp;

int main(void)
{
	cin >> N;
	int a;
	for(int i = 0; i < N; i++){
		cin >> a;
		mp[a]++;
	}
	
	int ans = 0;
	for(auto it = mp.begin(); it != mp.end(); it++){
		if(it->second > it->first) ans += it->second - it->first;
		if(it->second < it->first) ans += it->second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long double,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int n = 1005;
int m;
vector<vector<pll>> graph(n,vector<pll>());

vector<long double>  Dijkstra(int start){
    vector<bool> seen(n,false);
    vector<long double> shortest(n,LINF);
    priority_queue<pll,vector<pll>,greater<pll>> pq;
    pq.push(pll(0,start));

    while(!pq.empty()){
        long double dist = pq.top().first;
        int node = pq.top().second;
        pq.pop();
        if(seen[node]) continue;

        shortest[node] = dist;
        seen[node] = true;

        for(pll next:graph[node]){
            int next_node = next.second;
            long double next_cost = next.first;
            if(seen[next_node]) continue;
            pq.push(pll(next_cost + dist,next_node));
        }
    }

    return shortest;
}



int main(){
    int xs,ys,xt,yt;
    cin >> xs >> ys >> xt >> yt;
    int n;
    cin >> n;
    vector<int> x(n),y(n),r(n);
    rep(i,n) cin >> x[i] >> y[i] >> r[i];

    rep(i,n){
        rep(j,i){
            double res = hypot(x[i]-x[j],y[i]-y[j]) - (double)r[i] - (double)r[j];
            res = max(res,(double)0);
            graph[i].push_back(pll(res,j));
            graph[j].push_back(pll(res,i));
        }
        double res = hypot(xs-x[i],ys-y[i]) - (double)r[i];
        res = max(res,(double)0);
        graph[i].push_back(pll(res,n));
        graph[n].push_back(pll(res,i));

        res = hypot(xt-x[i],yt-y[i]) - (double)r[i];
        res = max(res,(double)0);
        graph[i].push_back(pll(res,n+1));
        graph[n+1].push_back(pll(res,i));
    }

    graph[n].push_back(pll(hypot(xs-xt,ys-yt),n+1));
    graph[n+1].push_back(pll(hypot(xs-xt,ys-yt),n));

    vector<long double> ans = Dijkstra(n);
    cout << setprecision(20) << ans[n+1] << endl;

    return 0;
}


Measured memory_bytes: 52128
#!/bin/python

import math
import os
import random
import re
import sys

def dp(N):
    global yen
    if table.get(N) != None:
        return table.get(N)
    if N == 0:
        return 0
    if N < 0:
        return sys.maxint
    result = sys.maxint
    for i in range(len(yen)):
        result = min(result,dp(N-yen[i]))
    table[N] = 1+result
    return 1+result

def solution(N):
    return dp(N)
        
table = {}

if __name__ == '__main__':
    minVal = sys.maxint
    N = int(raw_input())
    yen = [59049,46656,7776,6561,1296,729,216,81,36,9,6,1]
    result = solution(N)

    print result

Measured memory_bytes: 14128
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define endl "\n"

using namespace std;

void dout() {
    cerr << endl;
}

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}


typedef pair <int, int> pii;
const int N = 2e5 + 3;
int n, k, add[N], ans[N];
vector <int> q[N];

void cleanup() {
    return;
}

void dfs(int v, int p) {
    ans[v] = ans[p] + add[v];
    for (auto i : q[v]) {
        if (i == p) {
            continue;
        }
        dfs(i, v);
    }
}

void solve() {
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        q[x].pb(y);
        q[y].pb(x);
    }
    for (int i = 0; i < k; i++) {
        int x, y;
        cin >> x >> y;
        add[x] += y;
    }
    dfs(1, 1);
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << " ";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
    int tc = 1;
//    cin >> tc;
    while (tc--) {
        solve();
        cleanup();
    }
}


Measured memory_bytes: 24192
#include <stdio.h>

int main()
{
  int N;
  long sum=0;
  scanf("%d",&N);
  for(int i=1;i<=N;i++){
    if(i % 3 == 0){}
    else if(i % 5 == 0){}
    else {
      sum += i;
    }
  }
  printf("%ld\n",sum); 
  return 0;
}

Measured memory_bytes: 1736
a=list(map(int, input().split()))
for i in range(1,len(a)):
    tmp=a[0]
    if tmp>a[i]:
        tmp=a[i]
        a[i]=a[0]
        a[0]=tmp
if a[1]>a[2]:
    tmp=a[2]
    a[2]=a[1]
    a[1]=tmp
print(a[0],a[1],a[2])


Measured memory_bytes: 5592
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;



 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}
	
	public void debug() {
	}
	
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String S = null;
	/*/
	InputUtil in = new InputUtil();
	//*/
	PrintWriter out = new PrintWriter(System.out);
	
	int N = 0;
	int A = 0;
	
	//int ans = -1;
	boolean ans = false;
	
	
	
	
	public void input() throws IOException {
		N = in.nextInt();
		A = in.nextInt();
	}
	
	public void solve() throws IOException {
		ans = ((N%500) <= A);
	}

	
	public void output() {
		out.println(ans?"Yes":"No");
		out.flush();
	}
}

class Point {
	int y;
	int x;
	public Point(int y, int x) {
		this.x=x;
		this.y=y;
	}
	
	public Point move(Point d) {
		Point p = new Point(y, x);
		p.x += d.x;
		p.y += d.y;
		return p;
	}
	
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}


Measured memory_bytes: 21204
n = int(input())
monster_list = [ int(v) for v in input().split() ]

def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
a = monster_list[0]
for i in range(n-1):
    a = gcd(a,monster_list[i+1])
print(a)


Measured memory_bytes: 62704
import java.util.Scanner;

public class Main
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt[] = new int[n];

        for (int i = 0; i < n; i++)
            cnt[sc.nextInt()]++;

        boolean flag = true;
        for (int i = 1; i < n && flag; i++)
            if (cnt[i] % 2 != 0)
                flag = false;

        if (flag)
        {
            int ans = 1;
            for (int i = 1; i < n; i++)
                if (cnt[i] == 2)
                {
                    ans *= 2;
                    ans %= (int) 1e9 + 7;
                }
            System.out.println(ans);
        } else
            System.out.println(0);
    }
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> cnt(N+1, 1);
    vector<bool> red(N+1, false);
    red[1] = true;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        red[b] = red[b] || red[a];
        cnt[b]++;
        cnt[a]--;
        if (cnt[a] == 0) red[a] = false;
    }
    cout << count(red.begin(), red.end(), true) << endl;
    return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int, n)
	for i:=0; i<len(nums); i++{
		fmt.Scan(&nums[i])
	}

	count := 0
	sort.Ints(nums)

	for i:=0; i<len(nums); i++{
		for j:=i+1; j<len(nums); j++{
			for k:=j+1; k<len(nums); k++{
				if nums[i] != nums[j] && nums[j] != nums[k] && nums[i] != nums[k]{
					if nums[i] + nums[j] > nums[k]{
						count++
					}
				}
			}
		}
	}

	fmt.Println(count)
}

Measured memory_bytes: 1844
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int x;
  cin >> x;
  cout << (x ? 0 : 1) << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3608
fn chmax<T: PartialOrd>(x: &mut T, a: T) {
    if *x < a {
        *x = a;
    }
}

fn main() {
    proconio::input! {
        n: usize,
        w: usize,
        item: [(usize, u64); n],
    }
    let mut dp = vec![0; w + 1];
    for (a, b) in item {
        for i in (a..=w).rev() {
            let p = dp[i - a] + b;
            chmax(&mut dp[i], p);
        }
    }
    let ans = dp[w];
    println!("{}", ans);
}

Measured memory_bytes: 2796
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long 
#define ld long double
#define f first
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
#define vi vector<int>
int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2] && s[0]=='R')
        cout<<3<<endl;
    else if(s[0]==s[1] && s[1]=='R')
        cout<<2<<endl;
    else if(s[1]==s[2] && s[2]=='R')
        cout<<2<<endl;
    else if(s[0]=='R' || s[1]=='R'||s[2]=='R')
    cout<<1<<endl;
    else
    cout<<0<<endl;
    return 0;
}


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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CY cout<<"Yes\n"
#define CN cout<<"No\n"
#define MOD 1000000007
using namespace std;
using ll = long long;
vector<ll> dp(100005,-1);
ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// ll rec(vector<ll>v,int k,int l,ll ans,int i,int f1,int f2)
// {

//     if(l==k)
//         return ans;
//     if(f1==1)
//     {
//         if(i>=v.size())
//         return INT_MAX;
//     }

//     return min(rec(v,k,l+1,max(ans,v[i]),i+2),rec(v,k,l,ans,i+1));
// }
ll bs(vector<ll>v,ll n)
{
    ll c=0;
    bool s=1;
    while(s)
    {
        s=0;
        c++;
        for(int i=0;i<n-1;i++)
        {
            if(v[i]>v[i+1])
                {swap(v[i],v[i+1]);s=1;}
        }
    }
    return c;
}
void solve()
{
    ll n; cin>>n;
    ll k;cin>>k;
    vector<ll>v(n);
    rep(i,n) cin>>v[i];
    sort(v.begin(), v.end());
    ll s=0;
    rep(i,k) s+=v[i];
    cout<<s;
}
int main() {
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    ll t;t=1;
 //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

set<ll> primes;

void make_primes(int s = limit) {

    for (int i = 2; i <= s; ++i) {
        bool is_prime = true;
        for (auto p : primes) {
            if (i % p == 0) {
                is_prime = false;
                break;
            }
        }
        if (is_prime) primes.insert(i);
    }
}

void factrization(int a, vector<int> &v) {
    for (auto p : primes) {
        if (a == 1) return;
        while (a % p == 0) {
            v.push_back(p);
            a /= p;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    make_primes(100);
    vector<int> v;
    for (int i = 1; i <= n; ++i) {
        factrization(i, v);
    }
    int factor[101] = {};
    for (auto p : v) factor[p]++;
    int ans = 0;

    //下記のパターンを調べる
    // p^2 * q^4 * r^4
    // p^2 * q^24
    // p^4 * q^14
    // p^74

    REP(i, 1, n + 1) REP(j, i + 1, n + 1) REP(k, j + 1, n + 1) {
        if (factor[i] >= 2 && factor[j] >= 4 && factor[k] >= 4) ans++;
        if (factor[i] >= 4 && factor[j] >= 2 && factor[k] >= 4) ans++;
        if (factor[i] >= 4 && factor[j] >= 4 && factor[k] >= 2) ans++;
    }

    REP(i, 1, n + 1) REP(j, i + 1, n + 1) {
        if (factor[i] >= 2 && factor[j] >= 24) ans++;
        if (factor[i] >= 4 && factor[j] >= 14) ans++;
        if (factor[i] >= 24 && factor[j] >= 2) ans++;
        if (factor[i] >= 14 && factor[j] >= 4) ans++;
    }

    REP(i, 1, n + 1) {
        if (factor[i] >= 74) ans++;
    }

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int dp[100005], a[100005], n;
int LIS_nlgn() {
  int len = 1;dp[0] = a[0];
  for (int i = 1; i < n; ++i) {
    if (a[i] >= dp[len - 1]) dp[len++] = a[i];
    else {
      int pos = upper_bound(dp, dp + len, a[i]) - dp;
      dp[pos] = a[i];
    }
  }
  return len;
}
int main() {
  cin >> n;
  for (int i = n - 1; i >= 0; i--) cin >> a[i];
  cout << LIS_nlgn() << endl;
}

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

int main() {
  int A,B,K; cin >> A >> B >> K;
  int min_ = min(A,B);
  int cnt = 0;
  for(int i = min_; i >= 1; i--) {
    if(A%i == 0 && B%i == 0) cnt++;
    if(cnt == K) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

"""
i番目を見ている時に、i+1番目と組にするか考える。
i+1はi+2と組にできるので、残せるなら残す。

"""

ans = 0
for i in range(N):
    if i != N-1:
        tmp = A[i] // 2
        ans += tmp
        A[i] -= tmp*2
        if A[i] != 0 and A[i+1] != 0:
            ans += 1
            A[i] = 0
            A[i+1] -= 1

    else:
        ans += A[i] // 2


print(ans)


Measured memory_bytes: 7072
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        //入力を保持する
        var chara = Char.Parse(Console.ReadLine());
        if (Char.IsUpper(chara))
        {
            Console.WriteLine("A");
        }
        else
        {
            Console.WriteLine("a");
        }
    }
}


Measured memory_bytes: 25792
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 1000005;
int a[maxn];
map<int,int> mp;
#define f(x) ((x % 2) ? (3 * x + 1) : (x / 2))
int main(int argc, char const *argv[])
{
	int s;
	cin>>s;
	a[1] = s;
	mp[s] = 1;
	for(int i = 2;; ++i)
	{
		a[i] = f(a[i - 1]);
		if(mp[a[i]])
		{
			printf("%d\n",i);
			return 0;
		}
		mp[a[i]] = 1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>

using namespace std;

static const char DOWN = '\\';
static const char EVEN = '_';
static const char UP = '/';

struct AREA {
  int index;
  int area;
};

int main() {
  string data;
  cin >> data;

  stack<int> input;
  vector<AREA> answers;
  AREA current = {};
  int lastIndex = 0;
  int total = 0;
  for (int i = 0; i < data.length(); i++) {
    switch (data[i]) {
    case DOWN:
      input.push(i);
      break;
    case EVEN:
      break;
    case UP:
      if (input.empty()) {
        continue;
      }
      lastIndex = input.top();
      input.pop();
      current.area = i - lastIndex;
      current.index = lastIndex;
      total += current.area;
      while (answers.size() > 0 && answers.back().index > lastIndex) {
        current.area += answers.back().area;
        answers.pop_back();
      }
      answers.push_back(current);
      break;
    default:
      break;
    }
  }

  cout << total << endl;  
  cout << answers.size();
  for (AREA answer : answers) {
      cout << " " << answer.area;
  }  
  cout << endl;

  return 0;
}



Measured memory_bytes: 3292
#include <stdio.h>
 
 
int main() {
 
  int n,G[101][101];
  int i,j,k,l,u,a,t;
 
 
  scanf("%d",&n);
 
  for(i=0;i<n+1;i++)
    for(j=0;j<n+1;j++) {
      G[i][j] = 0;
 
    }
 
  for(i=0;i<n;i++){
 
    scanf("%d %d ",&k,&u);
    //    printf("u = %d\n",u);
 
    for(j=0;j<u;j++) {
      scanf("%d",&a);
      G[k -1][a-1] = 1;
      // printf("G[%d][%d] = 1\n",i,k-1);
    }
  }
     
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) {
      printf("%d",G[i][j]);
      if(j != n-1) printf(" ");
    }
    printf("\n");
  }
 
 
  return 0;
 
     
     
}

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

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

    vector<int> res(n, 0);
    int ai;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> ai;
        res.at(ai - 1) += 1;
    }

    for (int i = 0; i < n; i++)
    {
        cout << res.at(i) << endl;
    }
}

Measured memory_bytes: 4048
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.chomp;

    if (A.front == 'W' || A.back == 'W') {
        writeln(0);
        return;
    }

    immutable long MOD = 10^^9 + 7;
    long ans = 1;
    long cnt = 0;

    foreach (a; A) {
        if (cnt == 0 && a == 'W') {
            writeln(0);
            return;
        } else if (cnt == 0) {
            cnt += 1;
        } else if (a == 'W') {
            if (cnt % 2 == 1) {
                cnt += 1;
            } else {
                ans = ans * cnt % MOD;
                cnt -= 1;
            }
        } else {
            if (cnt % 2 == 1) {
                ans = ans * cnt % MOD;
                cnt -= 1;
            } else {
                cnt += 1;
            }
        }
    }

    if (cnt != 0) {
        writeln(0);
    } else {
        foreach (i; 1..N+1) ans = ans * i % MOD;
        writeln(ans);
    }
}

Measured memory_bytes: 2684
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
	int a,b,c,ans;
	cin>>a>>b>>c;
	if(a==b) ans=c;
	else if(a==c) ans=b;
	else ans=a;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<n;++i){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define Mp make_pair
#define pb push_back
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 130;
const int dx[4] = {1, 0};
const int dy[4] = {0, 1};
int n, m, ans, v[N][N];
char mp[N][N];

bool valid(pii x) {
    return (1 <= x.fi && x.fi <= n && 1 <= x.se && x.se <= m) || x == Mp(n, m + 1);
}
int main(){
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= n; i++)
        scanf("%s", mp[i] + 1);
    mp[0][1] = mp[n][m + 1] = '.';
    priority_queue<pair<int, pii> > q; q.push(Mp(0, Mp(0, 1)));
    while(q.size()) {
        pii now = q.top().se; int val = q.top().fi; q.pop();
        if(now == Mp(n, m + 1)) {
            printf("%d\n", -val);
            return 0;
        }
        if(v[now.fi][now.se] == 1) continue;
        v[now.fi][now.se] = 1;
        for(int k = 0; k < 4; k++) {
			int tx = now.fi + dx[k], ty = now.se + dy[k];
			if(!valid(Mp(tx, ty)) || v[tx][ty]) continue;
            if(mp[tx][ty] == '#')
                q.push(Mp(val - (mp[now.fi][now.se] != '#'), Mp(tx, ty)));
            else q.push(Mp(val, Mp(tx, ty)));
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI=2147483647;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int n; cin >>n;
  map<string, int> card;
  rep(i, n){
    string s; cin >>s;
    card[s]++;
  }
  int m; cin >>m;
  rep(i, m){
    string s; cin >>s;
    card[s]--;
  }
  int res = 0;
  for (auto p : card){
    int v = p.second;
    chmax(res, v);
  }
  cout <<res <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define inf 1001001001
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(void) {
    int h, w; cin >> h >> w;
    char a[101][101];
    bool yoko[h], tate[w];
    rep(i, h) yoko[i] = false;
    rep(j, w) tate[j] = false;
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
            if(a[i][j] == '#')
                yoko[i]=true, tate[j]=true;
        }
    }
    rep(i, h) {
        if(!yoko[i]) continue;
        rep(j, w) {
            if(!tate[j]) continue;
            printf("%c",a[i][j]);
        }puts("");
    }
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIT = lambda: tuple(MI())
MIS = lambda: input().split()


N, Q = MI()
S = input()
queries = [(lambda t: (t[0], t[1] == "R"))(MIS()) for i in range(Q)]
search_result = [None] * N

def search(i):
    # is S[i] falls to (left, right)
    if i < 0:
        return (True, False)
    if i >= N:
        return (False, True)
    if search_result[i] is not None:
        return search_result[i]
    pos = i
    for t, d in queries:
        if t == S[pos]:
            pos += 1 if d else -1
            if pos < 0:
                return (True, False)
            if pos >= N:
                return (False, True)
    return (False, False)


def search_left():
    def isOK(i):
        return not search(i)[0]
    # lower_bound of search_result[i][0] == False or 0
    left, right = -1, N
    while (right - left > 1):
        mid = left + (right - left) // 2
        if (isOK(mid)):
            right = mid
        else:
            left = mid
    return right

def search_right():
    # lower_bound of search_result[i][1] == True or N
    def isOK(i):
        return search(i)[1]
    # lower_bound of search_result[i][0] == False or 0
    left, right = -1, N
    while (right - left > 1):
        mid = left + (right - left) // 2
        if (isOK(mid)):
            right = mid
        else:
            left = mid
    return right


def main():
    # left
    lb = search_left()
    rb = search_right()

    return rb - lb



if __name__ == "__main__":
    print(main())


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

int main() {
    long N , a , b , c;
    cin >> N;
    a = 2;
    b = 1;

    
    for(int i = 0; i < N - 1; i++) {
        c = b;
        b += a;
        a = c;
    }
    
    cout << b << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b;
  while(1){
    cin>> a >> b;
    if(a==0&&b==0)break;
    for(int i=1;i<=a;i++){
      for(int j=1;j<=b;j++){
	if(i%2==1&&j%2==1)cout<<"#";
	else if(i%2==1&&j%2==0)cout<<".";
	else if(i%2==0&&j%2==1)cout<<".";
	else if(i%2==0&&j%2==0)cout<<"#";
      }
      cout<< endl;
    }
    cout<< endl;
  }
  return 0;
}

Measured memory_bytes: 1156
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        TreeMap<Long,Integer> map = new TreeMap<Long,Integer>(Comparator.reverseOrder());
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            long a = sc.nextLong();
            if(map.containsKey(a)){
                map.put(a,map.get(a)+1);
            }else{
                map.put(a,1);
            }
        }
        long ans = 0;
        boolean get2 = false;
        boolean get4 = false;
        for(Map.Entry<Long,Integer> e : map.entrySet()){
            long k = e.getKey();
            int v = e.getValue();
            if(v == 1) continue;
            else if(v >= 2 && get2){
                ans *= k;
                get4 = true;
                break;
            }else if(v >= 4){
                ans = k*k;
                get4 = true;
                break;
            }else{
                ans = k;
                get2 = true;
            }
        }
        System.out.print(get4 ? ans : 0);
    }
}

Measured memory_bytes: 63212
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;

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 ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;

const ll INF=LLONG_MAX;

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

  int N; cin >>N;
  vvi abc(N+1,vi(3));
  rep(i,1,N+1) {cin >>abc[i][0] >>abc[i][1] >>abc[i][2];}
  vector<vll> dp(N+1,vll(3));
  rep(i,1,N+1) {
    rep(j,0,3) {
      rep(k,0,3) {
        if (j!=k) {
          dp[i][j]=max(dp[i][j],dp[i-1][k]+abc[i][j]);
        }
      }
    }
  }
  cout <<max({dp[N][0],dp[N][1],dp[N][2]}) <<'\n';
  return 0;
}


Measured memory_bytes: 14272
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
static const double pi = 3.141592653589793;

int main()
{
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double ang_tmp = (5 * h - m) / 30.0 + m / 360.0;
  double ang_c = abs(ang_tmp) * pi;

  double c = a * a + b * b - 2 * a * b * cos(ang_c);
  
  cout << fixed << setprecision(10) << sqrt(c) << endl;
  
  return 0;
}

Measured memory_bytes: 4164
//#include <bits/stdc++.h>
#include<iostream>
#include<numeric>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

int ctoi(char c) {
  if('0'<=c && c <= '9') return c-'0';
  return 0;
}

int main(){
  int N=0,A=0,B=0;
  cin >> N;
  if(N==1){
    cout << "Hello World" << endl;
  }else{
    cin >> A >> B;
    cout << A + B << endl;
  }
}

Measured memory_bytes: 256
import sys
import heapq
from operator import itemgetter
 
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a = IL()
print(a[2],a[0],a[1])

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

void input()
{ 
    #ifndef ONLINE_JUDGE 
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) ll a[n]; rep(i,0,n) cin>>a[i];
#define vector(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a,n) rep(i,0,n) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //

int main()
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
   	//input();
   	int a,b;
   	cin>>a>>b;
   	cout<<a*b;


}

 

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

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll sum = 0;
  ll now;
  cin >> now;
  rep(i, n-1){
    ll num;
    cin >> num;
    sum += min(b, (num-now)*a);
    now = num;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CTravelingSalesmanAroundLake {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int k, n; cin >> k >> n;
      vector<int> a(n);
      rep(i, n) {
        cin >> a[i];
      }
      int ret = k;
      rep(i, n-1) {
        chmin(ret, k-abs(a[i+1]-a[i]));
      }
      chmin(ret, k-(a[0]+k-a[n-1]));
      cout << ret << endl;


    }
};

signed main() {
  CTravelingSalesmanAroundLake solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1152
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, x, y;
  readf("%s %s %s\n", &n, &x, &y);
  auto g = new int[][](n, n);
  foreach (i; 0..n) {
    g[i][] = int.max / 2 - 1;
  }
  foreach (i; 0..n-1) {
    foreach (j; i+1..n) {
      g[i][j] = j - i;
      g[j][i] = j - i;
    }
  }
  g[x-1][y-1] = 1;
  g[y-1][x-1] = 1;

  foreach (k; [x-1, y-1]) {
    foreach (i; 0..n) {
      foreach (j; i+1..n) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }

  auto res = new int[](n);
  foreach (i; 0..n-1) {
    foreach (j; i+1..n) {
      res[g[i][j]-1]++;
    }
  }
  foreach (i; 0..n-1) {
    res[i].writeln;
  }
}


Measured memory_bytes: 17916
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
int dp[1005][1005];

signed main(){
  int h,w;
  cin>>h>>w;
  char a[1005][1005];
  lp(i,1005)lp(j,1005) a[i][j]='#';
  queue<pair<pair<int,int>,int> > q;
  lp(i,h){
    lp(j,w){
      cin>>a[i+1][j+1];
      if(a[i+1][j+1]=='#') q.push({{i+1,j+1},0});
    }
  }
  while(!q.empty()){
    int x=q.front().first.second;
    int y=q.front().first.first;
    int cnt=q.front().second;
    q.pop();
    if(a[y+1][x]=='.'){
      dp[y+1][x]=cnt+1;
      a[y+1][x]='#';
      q.push({{y+1,x},cnt+1});
    }
    if(a[y-1][x]=='.'){
      dp[y-1][x]=cnt+1;
      a[y-1][x]='#';
      q.push({{y-1,x},cnt+1});
    }
    if(a[y][x+1]=='.'){
      dp[y][x+1]=cnt+1;
      a[y][x+1]='#';
      q.push({{y,x+1},cnt+1});
    }
    if(a[y][x-1]=='.'){
      dp[y][x-1]=cnt+1;
      a[y][x-1]='#';
      q.push({{y,x-1},cnt+1});
    }
  }
  int ans=0;
  lp(i,1005)lp(j,1005) ans=max(ans,dp[i][j]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 25396