akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, a, b, c;
int Q, K, x[100010], y[100010];

/*==================================================*/
/*function*/
vector<pair<ll, ll>> edge[100010];   //<ノード, 距離>
ll d[100010];   //始点ノードからノードiへの最短距離
ll start;  //開始ノード番号

void dijkstra() {
    priority_queue< pair<ll, ll> > PQ;  //<(-1)*最短距離, ノード番号>

    REP(i,0,N) d[i] = LLINF;
    d[start] = 0;
    PQ.push(make_pair(0,start));  //開始ノードを0とする。

    while(!PQ.empty()){
        ll curCost = -PQ.top().first;
        ll curNode = PQ.top().second;
        PQ.pop();

        if(d[curNode] < curCost) continue;
        //d[curNode] = curCost;

        REP(i,0,edge[curNode].size()){
            ll nextNode = edge[curNode][i].first;
            ll addCost = edge[curNode][i].second;

            if(d[nextNode] > d[curNode] + addCost){
                d[nextNode] = d[curNode] + addCost;
                PQ.push(make_pair(-d[nextNode], nextNode));
            }
        }
    }
}
/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N-1){
        cin>>a>>b>>c;
        edge[a-1].emplace_back(b-1, c);
        edge[b-1].emplace_back(a-1, c);
    }

    cin>>Q>>K;
    REP(i,0,Q){
        cin>>x[i]>>y[i];
    }

    start = K-1;
    dijkstra(); //Kを起点にすべてのノードへの最短距離を計算

    REP(i,0,Q){
        cout<<d[x[i]-1]+d[y[i]-1]<<endl;
    }
    return 0;
}


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

int main(){
  int a,b;
  cin >>a >>b;
  char x=a+'0';
  char y=b+'0';
  string s1(a,y);
  string s2(b,x);
  if(s1<s2) cout << s1<<endl;
  else cout << s2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 52;

char c[MAX_N][MAX_N];
int up[31],lf[31],rg[31],dw[31];
bool flag[31];
int n,H,W;
bool end_flag;

vector<int> G[31];
int color[31];
deque<int> L;
bool cycle;	//????????????

void visit(int u)
{
	if(color[u] == 0){
		cycle = true;	//DAG??§??????
		return;
	}
	if(color[u] == 1){
		return;
	}
	color[u] = 0;
	for(int i=0;i<G[u].size();i++){
		visit(G[u][i]);
	}
	color[u] = 1;
	L.push_front(u);
}

int main()
{
	scanf("%d",&n);
    for(int loop=0;loop<n;loop++){
        scanf("%d%d",&H,&W);
        end_flag = false;
        fill(up,up+30,INF);
        fill(lf,lf+30,INF);
        fill(rg,rg+30,-1);
        fill(dw,dw+30,-1);
        fill(flag,flag+30,false);
        rep(i,30){
            G[i].clear();
        }
        L.clear();
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cin >> c[i][j];
                if(c[i][j] != '.'){
                    int id = (int)(c[i][j] - 'A');
                    if(up[id] > i){
                        up[id] = i;
                    }
                    if(lf[id] > j){
                        lf[id] = j;
                    }
                    if(rg[id] < j){
                        rg[id] = j;
                    }
                    if(dw[id] < i){
                        dw[id] = i;
                    }
                    if(!flag[id]){
                        flag[id] = true;
                    }
                }
            }
        }
        for(int i=0;i<30;i++){
            if(flag[i]){
                for(int j = up[i];j <= dw[i];j++){
                    for(int k = lf[i];k <= rg[i];k++){
                        if(c[j][k] == '.'){
                            cout << "SUSPICIOUS\n";
                            end_flag = true;
                            break;
                        }
                        if((char)('A' + i) != c[j][k]){
                            G[i].push_back((int)(c[j][k] - 'A'));
                        }
                    }
                    if(end_flag){
                        break;
                    }
                }
            }
            if(end_flag){
                break;
            }
        }
        if(end_flag){
            continue;
        }
        rep(i,30){
            sort(G[i].begin(),G[i].end());
            G[i].erase(unique(G[i].begin(),G[i].end()),G[i].end());
        }
        rep(i,30){
    		color[i] = -1;
    	}
    	rep(i,30){
    		if(color[i] == -1){
    			cycle = false;
    			visit(i);
    		}
    		if(cycle){
    			break;
    		}
    	}
        if(cycle){
            cout << "SUSPICIOUS\n";
        }else{
            cout << "SAFE\n";
        }
    }
	return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(int argc, char const *argv[])
{
  int a; cin >> a;
  string s; cin >> s;
  cout << ((a>=3200)? s: "red") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.PB", "r", stdin );
	string str = "";
	int rectangle = 0, lozenge = 0;
	while (getline (cin, str ) ){
		int n = str.length();
		rep (i, n ){
			if (str[i] == ',' ) str[i] = ' ';
		} // end rep
		stringstream ss (str );
		int side1, side2, diagonal;
		ss >> side1 >> side2 >> diagonal;
		if (side1 == side2 || side1*side1 + side2*side2 == diagonal*diagonal ){
			if (side1 == side2 && side1*side1 + side2*side2 == diagonal*diagonal ){
				++rectangle; ++lozenge;
			}else
			if (side1 != side2 && side1*side1 + side2*side2 == diagonal*diagonal ){
				++rectangle;
			}else
			if (side1 == side2 && side1*side1 + side2*side2 != diagonal*diagonal ){
				++lozenge;
			} // end if
		} // end if
	} // end loop
	cout << rectangle << endl;
	cout << lozenge << endl;

//	printf ("%d\n", res );
		
	return 0;
}

Measured memory_bytes: 1220
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        String S = in.next();
        String T = in.next();
        int a = in.nextInt();
        int b = in.nextInt();
        String U = in.next();
        if(S.equals(U)){
            println((a-1) +" "+ b);
        }
        else{
            println(a +" " + (b-1));
        }
        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 21076
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int n,m,cap;
vector<PI> G[4000];
bool lpg[4000];
bool vis[4000][4000];

map<string,int> stoi;
int getnum(string s){
  if(stoi.count(s))return stoi[s];
  int sz=SZ(stoi);
  return stoi[s]=sz;
}

void solve(){
  stoi.clear();
  memset(lpg,0,sizeof(lpg));
  memset(vis,0,sizeof(vis));  
  string src,dest;
  cin>>src>>dest;
  int st=getnum(src),go=getnum(dest);
  
  rep(i,n+1)G[i].clear();
  rep(i,n){
    string p,q;
    int c;
    cin>>p>>q>>c;
    int u=getnum(p);
    int v=getnum(q);
    G[u].pb(mp(v,c));
    G[v].pb(mp(u,c));
  }
  rep(i,m){
    string s;
    cin>>s;
    int t=getnum(s);
    //if(t>4000)exit(0);
    lpg[t]=1;
  }

  priority_queue<pair<int,PI> >q;
  q.push(mp(0,mp(cap*10,st)));
  while(!q.empty()){
    int cc=-q.top().F;
    int ca=q.top().S.F;
    int cv=q.top().S.S;

    q.pop();
    if(lpg[cv])ca=cap*10;
    if(vis[cv][ca])continue;
    vis[cv][ca]=true;
    if(cv==go){
      cout<<cc<<endl;
      return;
    }

    rep(i,SZ(G[cv])){
      int to=G[cv][i].F;
      int co=G[cv][i].S;
      if(co>ca)continue;
      int nca=ca-co;
      //if(to>4000 || nca>4000)break;
      if(vis[to][nca])continue;
      q.push(mp(-cc-co,mp(nca,to)));
    }
  }
  cout<<-1<<endl;
}

main(){
  while((cin>>n>>m>>cap)&&n)
    solve();
}

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

int dp[303][303][303];
vector<pair<int,int>> V[333];

int main(){
  int N,M; cin>>N>>M;
  rep(i,M){
    int l,r,x; cin>>l>>r>>x;
    V[r].push_back({l,x});
  }
  ll ans=0;
  dp[0][0][0]=1;
  rep(i,N+1) rep(j,N+1) rep(k,N+1){
    int r=max({i,j,k});
    for(auto p:V[r]){
      int l=p.first, x=p.second, cnt=0;
      if(l<=i&&i<=r) cnt++;
      if(l<=j&&j<=r) cnt++;
      if(l<=k&&k<=r) cnt++;
      if(cnt!=x) dp[i][j][k]=0;
    }
    if(r==N){
      (ans+=dp[i][j][k])%=MOD;
      continue;
    }
    (dp[r+1][j][k]+=dp[i][j][k])%=MOD;
    (dp[i][r+1][k]+=dp[i][j][k])%=MOD;
    (dp[i][j][r+1]+=dp[i][j][k])%=MOD;
  }

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


Measured memory_bytes: 108800
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main()
{
  string str;
  cin >> str;
  
  int sum = 0;
  while(1){
    if(str.empty()) break;
    
    char c = str[0];
    int n = c - '0';
    sum += n;
    str.erase(0,1);  
  }
  
  string ans;
  if(sum%9 == 0) ans = "Yes";
  else ans = "No";
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    
    if (x-r>=0 && x+r<=W){
        if(y-r>=0 && y+r<=H){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3104
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(max(a,d),max(b,c))
#define MAX   1e9
#define MIN  -1e9
#define PI 3.14159265358979
#define eps 1e-9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(long long int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(long long int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl
#define inp(a,start,len) for(long long int i = start;i < len;i++) cin>>a[i]
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}


int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll T = 1;
	// cin>>T;
	while(T--){
		ll n;
		cin>>n;
		if(n == 0)
			cout<<1;
		else
			cout<<0;
	}
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>

void solve(int N, std::vector<int> H)
{
  int max_count = 0;
  int current_count = 0;
  for (int i = 1; i < N; i++)
  {
    if(H[i-1]>=H[i])
    {
      current_count ++;
    }
    else{
      current_count = 0;
    }
    if(current_count > max_count)
    {
      max_count = current_count;
    }
  }
  std::cout << max_count << std::endl;

}

int main(void)
{
  int N;
  std::cin >> N;
  std::vector<int> H(N);
  for(auto i0 = 0; i0 < N; ++i0)
  {
    std::cin >> H[i0];
  }
  solve(N,H);
  return 0;
}


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

int main()
{
    int n; cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    map<ll, int> mp;
    ll ans = 0;
    vector<ll> r(n);
    rep(i, n){
        mp[i+v[i]]++;
        r[i] = i-v[i];
    }
    rep(i, n){
        ans += mp[r[i]];
    }
    cout << ans << endl;
    system("pause");
}

Measured memory_bytes: 29056
using System;
namespace Ino{
    class Ino{
        static void Main(){
            string[] n_q = Console.ReadLine().Split(' ');
            int n = int.Parse(n_q[0]);
            int q = int.Parse(n_q[1]);
            char[] s = Console.ReadLine().ToCharArray();

            int[] a = new int[n+1];
            int[] c = new int[n+1];
            a[0] = 0;
            c[0] = 0;
            c[1] = 0;
            for(int i=1;i<n;i++){
                if(s[i-1]=='A' && s[i]=='C'){
                    a[i]=a[i-1]+1;
                    c[i+1]=c[i]+1;
                }
                else{
                    a[i]=a[i-1];
                    c[i+1]=c[i];
                }
            }
            a[n]=a[n-1];
          /*
          for(int i=0;i<n+1;i++){
            Console.Write(a[i]);
            Console.Write(c[i]);
            Console.Write("\n");
          }
          */

            for(int i=0;i<q;i++){
                string[] l_r = Console.ReadLine().Split(' ');
                int l = int.Parse(l_r[0]);
                int r = int.Parse(l_r[1]);
                Console.WriteLine(c[r]-a[l-1]);
            }
        }
    }
}

Measured memory_bytes: 16968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<int, int> P;
ll modnum = 1e9+7;



int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    sort(a.rbegin(), a.rend());

    ll ans = 0;
    for(int i=1; i<n; i++) {
        if(min(a[i], a[0]-a[i]) > min(ans, a[0]-ans)) {
            ans = a[i];
        }
    }

    cout << a[0] << " " << ans << endl;

    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    int cnt = 0;
    for(int i = 0; i < N-2; i++)
    {
        if((p[i+1]>p[i]&&p[i+1]<p[i+2])||(p[i+1]<p[i]&&p[i+1]>p[i+2])) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int r, D, x, x1;

    scanf("%d %d %d", &r, &D, &x);

    for(int i=0; i<10; i++)
    {
        x1 = r*x-D;
        x = x1;
        printf("%d\n", x1);
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;


int main(){
    int N, t;
    cin >>N;
    int C[501], S[501], F[501];

    for(int i =0 ; i < N-1; i++){
        cin >> C[i] >> S[i] >> F[i];

    }

    for(int i =0 ; i < N-1; i++){
        t =0;
        for(int j=i ; j < N-1; j++){
            if(t <= S[j]){
                t = S[j];
            }
            else{
                t = ((t- S[j] + F[j] -1) / F[j]) * F[j]+ S[j];    
            }
            t += C[j];
        }
        cout << t << endl;
    }
    
    cout << "0" << endl;
    return 0;
}
    

Measured memory_bytes: 256
using System;

public class Test
{
	public static void Main()
	{
	    int n = 0;
	    n = int.Parse(Console.ReadLine());
	    
		int[] b = new int[n];
        string[] temp = Console.ReadLine().Split(' ');
        
		for(int i=0;i<n;i++){
		    b[i] = int.Parse(temp[i]);
		    
		}
	    int m = 0;
	    m = int.Parse(Console.ReadLine());
	    string[,] str = new String[m,2];
	    string[] tmp;
		for(int i =0;i<m;i++){
		    tmp = Console.ReadLine().Split(' ');
		    str[i,0] = tmp[0];
		    str[i,1] = tmp[1];
		}
		
		int[] ans = new int[n];
		int abc = 0;
		for(int i =0;i<m;i++){
		    b.CopyTo(ans,0);

		    ans[int.Parse(str[i,0]) - 1] = int.Parse(str[i,1]);
		    abc = 0;
		    for(int j =0;j<n;j++){
		        abc = abc + ans[j];
		    }
		    Console.WriteLine(abc);
		}
		

	}
}

Measured memory_bytes: 2776
N, W = map(int, input().split())
W_list = []
V_list = []
for i in range(N):
    w, v = map(int, input().split())
    W_list.append(w)
    V_list.append(v)
dp = [[0]*(W+1)]
for n in range(N):
    tmp = [0] * (W + 1)
    tmp_w = W_list[n]
    tmp_v = V_list[n]
    for w in range(W+1):
        if w-tmp_w >= 0:
            tmp[w] = max(dp[-1][w], dp[-1][w-tmp_w] + tmp_v)
        else:
            tmp[w] =dp[-1][w]
    dp.append(tmp)
print(dp[-1][-1])    

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

int main(){
  vector<long long int> A(3);
  for(int i=0;i<3;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  if(A.at(2)%2==0){
    cout << 0 << endl;
  }else{
    cout << A.at(0)*A.at(1) << endl;
  }
}

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

using namespace std;
using ll = long long;
using pll = pair<ll,ll>;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<(b*c>=a?"Yes":"No");
    return 0;
}


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

using namespace std;

int main (void)
{	
	int n;
	cin >> n;
	if (n == 25)
	{
		cout << "Christmas" << endl;
	}
	else if (n == 24)
	{
		cout << "Christmas Eve" << endl;
	}
	else if (n == 23)
	{
		cout << "Christmas Eve Eve" << endl;
	}
	else
	{
		cout << "Christmas Eve Eve Eve" << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int d = a / b;
		int r = a % b;
		double f = (double)a / (double)b;
		System.out.printf("%d %d %.8f",d ,r , f);
	}
}

Measured memory_bytes: 26356
#include <iostream>
#include <cstdio>

using namespace std;

const int P=998244353;
const int N=1000005;

int fact[N],invf[N];
int n,m,ans;

inline int quick_power(int x,int y)
{
	int ret=1;
	for (;y;y>>=1,x=1ll*x*x%P) if (y&1) ret=1ll*ret*x%P;
	return ret;
}

void pre()
{
	fact[0]=1;
	for (int i=1;i<=n+m;++i) fact[i]=1ll*fact[i-1]*i%P;
	invf[n+m]=quick_power(fact[n+m],P-2);
	for (int i=n+m;i>=1;--i) invf[i-1]=1ll*invf[i]*i%P;
}

inline int C(int n,int m){return 1ll*fact[n]*invf[m]%P*invf[n-m]%P;}

inline void update(int &x,int y){(x+=y)%=P;}

int main()
{
	//freopen("yesorno.in","r",stdin),freopen("yesorno.out","w",stdout);
	scanf("%d%d",&n,&m),pre();
	if (n<m) n^=m^=n^=m;
	for (int i=1;i<=m;++i) update(ans,1ll*C(i<<1,i)%P*C(n+m-(i<<1),n-i)%P);
	ans=(1ll*ans*quick_power(2ll*C(n+m,n)%P,P-2)%P+n)%P;
	printf("%d\n",ans);
	//fclose(stdin),fclose(stdout);
	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef vector<ll> Vl;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;



int n, m;

int main() {

	cin >> n >> m;

	cout << (n * (n - 1) / 2) + (m * (m - 1) / 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
 
int32_t main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
    	cin>>a[i]>>b[i]>>c[i];
    }
    int dp[n+1][3];
    dp[1][0]=a[0];
    dp[1][1]=b[0];
    dp[1][2]=c[0];
    int mx=0;
    for(int i=2;i<=n;i++){
    	int t1,t2;
    	t1 = max(mx,a[i-1]+dp[i-1][1]);
    	t2 = max(mx,a[i-1]+dp[i-1][2]);
    	dp[i][0] = max(t1,t2);
    	t1 = max(mx,b[i-1]+dp[i-1][0]);
    	t2 = max(mx,b[i-1]+dp[i-1][2]);
    	dp[i][1] = max(t1,t2);
    	t1 = max(mx,c[i-1]+dp[i-1][0]);
    	t2 = max(mx,c[i-1]+dp[i-1][1]);
    	dp[i][2] = max(t1,t2);
    }
 	int *ans =  max_element(dp[n],dp[n]+3);
    cout<<*ans;
    return 0;
}

Measured memory_bytes: 8276
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<cassert>
#include<sstream>
#include<complex>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<cctype>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (2147483647)
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS) 
#define MAX_N 500010
 
using namespace std;
 
template<class T>
class RMQ{
private:
  int n;
  T dat[2*MAX_N-1];
public:
  void init(int n_){
    n = 1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++)dat[i] = inf;//
  }
  
// k????????????(0-indexed)???a?????????´
  void update(int k,T a){
    k += n-1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = min(dat[k*2+1],dat[k*2+2]);
    }
  }
  
  T query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return inf;
    else if(a<=l && r<=b)return dat[k];
      
      T vl = query(a,b,k*2+1,l,(l+r)/2);
      T vr = query(a,b,k*2+2,(l+r)/2,r);
      return min(vl,vr);
  }
 
//n????????????§?????????????????????????\??????????£????????????¨ 
  T _query(int a,int b){
    return query(a,b,0,0,n);
  }
};
 
 
int main()
{
  int n,q,com,x,y;
  //scanf("%d%d",&n,&q);
  cin >> n >> q;
  RMQ<int> rmq;
  rmq.init(n+1);
  rep(i,q)
    {
      //scanf("%d%d%d",&com,&x,&y);
      cin >> com >> x >> y;
      if(com == 0)rmq.update(x,y);
      else        cout << rmq._query(x,y+1) << endl;
    }
 
  return 0;
}

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


int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A){
    if(A.size() ==  n + 1) {
        int score = 0;
        rep(i,q){
            if (A[b[i]] - A[a[i]] == c[i]) score += d[i];
        }
        ans = max(ans, score);
        return;
    }
    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q){
        cin  >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
def f(a, b, x):
    return int(a * x / b) - a * int(x / b)


num = list(map(int, input().split()))
a = num[0]
b = num[1]
n = num[2]
x = (int(n/b) + 1) * b - 1
max_num = f(a, b, min(b-1, n))
print(max_num)

Measured memory_bytes: 61868
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1362",problemID = "B",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    a,b,h,m = invr()
    if True:
        if (h == 12): 
            h = 0
        if (m == 60): 
            m = 0
        hour_angle = 0.5 * (h * 60 + m) 
        minute_angle = 6 * m
        q = abs(hour_angle - minute_angle) 
        q = min(360 - q, q) * math.pi / 180
    print(math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * math.cos(q))))
                
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

def power_two(n):
    if n == 1:
        return(True)
    sttr = str(n)
    len_str = len(sttr)
    sttr = list(sttr)
    num = 0
    if (len_str == 1 and sttr[len_str - 1] == '1'): 
        return(False)
    while (len_str != 1 or sttr[len_str - 1] != '1'):
        if ((ord(sttr[len_str - 1]) - ord('0')) % 2 == 1):
            return(False)
        j = 0; 
        for i in range(len_str):  
            num = num * 10 + (ord(sttr[i]) - ord('0')); 
            if (num < 2): 
                if (i != 0):  
                    sttr[j] = '0'
                    j += 1
                continue
  
            sttr[j] = chr((num // 2) + ord('0'))
            j += 1; 
            num = (num) - (num // 2) * 2
        len_str = j
    return(True)

def log_two(n): 
    return(math.log(n) / math.log(2))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

Measured memory_bytes: 63472
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  200005
#define mod 1000000007
#define PII pair<int, int>
#define lowbit(x) (x&-x)
#define PI acos(-1.0)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
	//ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug1
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
	//ofstream outputs("output.txt");
	//cout.rdbuf(outputs.rdbuf());
#endif

	int n;
	cin >> n;
	cout << n / 3 << endl; 
	return 0;
}

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

#define LLINF 12345678901234567LL

struct addedge{
	int L;
	int R;
	long long C;
};

vector<long long> dist;
int N,M,n;
vector<addedge> A;

bool sort_addedge(const addedge &x,const addedge &y){
	if(x.R==y.R)return x.L<y.L;
	else return x.R<y.R;
}

void update(int i,long long x){
	i+=n-1;
	dist[i]=x;
	while(i>0){
		i=(i-1)/2;
		dist[i]=min(dist[i*2+1],dist[i*2+2]);
	}
}

long long query(int a,int b,int k,int l,int r){
	if(r<=a || b<=l)return LLINF;
	if(a<=l && r<=b)return dist[k];
	long long ret1=query(a,b,2*k+1,l,(l+r)/2);
	long long ret2=query(a,b,2*k+2,(l+r)/2,r);
	return min(ret1,ret2);
}

int main(){
	cin >> N >> M;
	n=1;
	while(n<N)n*=2;
	
	dist=vector<long long>(2*n-1,LLINF);
	
	for(int i=0;i<M;i++){
		addedge a;
		cin >> a.L >> a.R >> a.C;
		a.L--;
		a.R--;
		A.push_back(a);
	}
	
	sort(A.begin(),A.end(),sort_addedge);
	
	update(0,0LL);
	for(auto a:A){
		//cout << query(a.L,a.R,0,0,n) << endl;
		update(a.R,min(dist[a.R+n-1],query(a.L,a.R,0,0,n)+a.C));
	}
	
	long long ans= (dist[N-1+n-1]==LLINF)?(-1):(dist[N-1+n-1]);
	cout << ans << endl;
	
	//for(int i=0;i<N;i++)cout << dist[i+n-1] << " ";
	return 0;
}

Measured memory_bytes: 4468
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int ab = sc.nextInt();
        int bc = sc.nextInt();
        int ca = sc.nextInt();

        int ans = (ab * bc) / 2;
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<int> c(26);
vector<vector<int>> s(365, vector<int>(26, 0));
vector<int> last(26, -1);
vector<int> t(365, -1);
int d;
inline int scoreing() {
    int res = 0;
    vector<int> tmp_last(26, -1);
    for(int i = 0; i < d; i++) {
        tmp_last[t[i]] = i;
        res += s[i][t[i]];
        for(int j = 0; j < 26; j++) {
            res -= c[j] * (i - tmp_last[j]);
        }
    }
    return res;
}
int main() {
    cin >> d;
    for(int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    int score = 0;
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            score -= c[j] * (i - last[j]);
        }
        int ind = -1;
        int tmp = score;
        for(int k = 0; k < 26; k++) {
            if(tmp < score + s[i][k] + c[k] * (i - last[k])) {
                ind = k;
                tmp = score + s[i][k] + c[k] * (i - last[k]);
            }
        }
        t[i] = ind;
        last[t[i]] = i;
        score = tmp;
    }
    int max = 5000;
    int cnt = 0;
    int lim = d / 5;
    std::mt19937 mt(0);
    while(cnt < max) {
        int mode = cnt / 50 % 5;
        int rnd = mt() % lim + lim * mode;
        rnd = min(d - 1, rnd);
        int new_s = t[rnd];
        int now_sc = scoreing();
        for(int i = 0; i < 26; i++) {
            t[rnd] = i;
            if(now_sc < scoreing()) {
                now_sc = scoreing();
                new_s = i;
            }
        }
        t[rnd] = new_s;
        cnt++;
    }
    for(int i = 0; i < d; i++) {
        cout << t[i] + 1 << endl;
    }
}

Measured memory_bytes: 3668
import java.util.Scanner;
public class Main {
	public static int ms(int[] a) {
		int min = 0;
		int x = 0;
		int max = Integer.MIN_VALUE;
		for(int i=0; i<a.length; i++) {
			x += a[i];
			max = Math.max(max, x-min);
			min = Math.min(min, x);
		}
		return max;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int n = sc.nextInt();
				if(n==0) break;
				int[] a = new int[n];
				for(int i=0; i<n; i++) {
					a[i] = sc.nextInt();
				}
				System.out.println(ms(a));
			}
		}
	}
}



Measured memory_bytes: 35988
N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

visited = [-1 for i in range(N)]
count = 0
cycle_start = -1
now = 0
trav_length, cycle_length = 0, 0

while True:
    if visited[now] != -1:
        cycle_start = now
        cycle_length = count - visited[now]
        break
    visited[now] = count
    now = A[now] - 1
    trav_length += 1
    count += 1


to_cycle_length = trav_length - cycle_length

if K <= N:
    now = 1
    while K > 0:
        K -= 1
        now = A[now - 1]
    print(now)
else:
    K -= to_cycle_length
    K %= cycle_length
    now = cycle_start + 1
    while K > 0:
        K -= 1
        now = A[now - 1]
    print(now)

Measured memory_bytes: 32380
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define PP pair<P,int>
using namespace std;


int n, m, ans;
vector<vector<int>> g(10);

void dfs(vector<int>v, int x){
    if(v.size() == n)ans++;


    for(auto i:g[x]){
        bool had = false;
        for(auto j:v){
            if(i == j) had = true;
        }
        if(had) continue;
        vector<int>u = v;
        u.push_back(i);
        dfs(u ,i);
    }
}

int main(){
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ans = 0;
    vector<int>v={0};
    dfs(v, 0);
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion 

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

	int n;
	cin >> n;
	vi a(n);
	map<LL, LL>m;
	set<LL>s;
	f(i, 0, n) {
		cin >> a[i];
		m[a[i]]++;
		s.insert(a[i]);
	}
	LL ans = 0;
	for (auto ite = s.begin(); ite != s.end(); ite++) {
		if (m[*ite] > *ite) {
			ans += m[*ite] - *ite;
		}
		else if (m[*ite] < *ite) {
			ans += m[*ite];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 500100;

int n, q;
int color[maxn];
int result[maxn];
vector<pair<int,int> > intervals[maxn];

int tree[4*maxn];

int lstindex[maxn];

void update(int uind, int uval, int li=1, int ri=n, int index=1) {
	if(li == ri) tree[index] += uval;
	else {
		int mid = (li + ri) / 2;

		if(uind <= mid) update(uind, uval, li, mid, 2*index);
		else update(uind, uval, mid+1, ri, 2*index+1);

		tree[index] = tree[2*index] + tree[2*index+1];
	}
}

int query(int ql, int qr, int li=1, int ri=n, int index=1) {
	if(li > qr || ri < ql) return 0;
	else if(li >= ql && ri <= qr) return tree[index];
	else {
		int mid = (li + ri) / 2;
		return query(ql,qr,li,mid,2*index) + query(ql, qr,mid+1,ri,2*index+1);
	}
}

int main() {
	cin>>n>>q;
	for(int i=1;i<=n;i++) {
		cin>>color[i];
	}

	int l, r;
	for(int i=1;i<=q;i++) {
		cin>>l>>r;
		intervals[r].pb(mp(l, i));
	}

	memset(lstindex, -1, sizeof(lstindex));

	for(int i=1;i<=n;i++) {
		int curr = color[i];
		if(lstindex[curr] == -1) {
			update(i, 1);
		}
		else {
			update(lstindex[curr], -1);
			update(i, 1);
		}

		lstindex[curr] = i;

		for(auto j:intervals[i]) {
			result[j.second] = query(j.first, i);
		}
	}

	for(int i=1;i<=q;i++) {
		cout<<result[i]<<"\n";
	}
}

Measured memory_bytes: 35332
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}


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


	int N = getint();

	ll kotae = (ll(N) * (N + 1) * (2 * N + 1) / 6 + ll(N) * (N + 1) / 2) / 2;

	rep(i, N - 1) {
		int u = getint(), v = getint();
		if (u > v) swap(u, v);

		kotae -= ll(u) * (N - v + 1);
	}

	printf("%lld\n", kotae);



	Would you please return 0;
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1000000000;

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second<b.second;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    ll n;
    cin >>n;
    ll a[n][3];
    for(int i=0;i<n;i++){
    	for(int j=0;j<3;j++) cin >>a[i][j];
	}
	ll dp[n][3];
	for(int i=0;i<3;i++) dp[0][i]=a[0][i];
	
	for(int i=1;i<n;i++){
		for(int j =0;j<3;j++){
			ll mn=0;
			for(int k=0;k<3;k++){
				if(j!=k){
					mn=max(dp[i-1][k]+a[i][j],mn);
				}
				dp[i][j]=mn;
			}
		}
	}
	ll m=0;
	for(int i=0;i<3;i++) m = max(dp[n-1][i],m);
	
	cout <<m<<"\n";
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int y;
        cin>>y;
        int ans=0;
        double score=0;
        for(int i=0;i<n;i++){
            double b,r,t;
            cin>>b>>r>>t;
            if(t==1){
                double it=1+y*(r/100);
                if(it>score)score=it,ans=b;
            }
            else if(t==2){
                double it=1+(r/100);
                double x=1;
                for(int j=0;j<y;j++)x*=it;
                if(x>score)score=x,ans=b;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	int ar[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>ar[i];
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(ar[1]-ar[0]);
	for (int i = 2; i < n; ++i)
	{
		dp[i]=min((dp[i-1]+abs(ar[i]-ar[i-1])),dp[i-2]+abs(ar[i]-ar[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}

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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    while(true){
		double x = Double.valueOf(sc.readLine());
		double h = Double.valueOf(sc.readLine());
		if(x==0 && h==0)
		    break;
		System.out.println(x*x+2.0*x*Math.sqrt(h*h+(x/2)*(x/2)));
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9736
S = str(input())

if S[0] == S[1] == S[2] == "R":
    print(3)
elif S[0] == S[1] == "R":
    print(2)
elif S[1] == S[2] == "R":
    print(2)
elif not S[0] == S[1] == S[2] == "S":
    print(1)
else:
    print(0)


Measured memory_bytes: 8972
#include <bits/stdc++.h>
using namespace std;
#define retunr return
#define pb push_back
#define mp make_pair
#define null NULL
#define sc(x) scanf("%d", &x)
#define sc64(x) scanf("%I64d", &x)
#define pr(x) printf("%d", (x))
#define sp putchar(' ')
#define ln putchar('\n')
#define pr64(x) printf("%I64d", (x))
#define rep(i,l,r) for (int i = l, lim = r;i <= lim; ++i)
#define repr(i,l,r) for (int i = r, lim = l;i >= lim; --i)
#define fi first
#define se second
#define SET(__set, val) memset(__set, val, sizeof __set)
#define fill(a,v,n) memset((a),(v),sizeof(a[0])*(n))
#define copy(a,b,n) memcpy((a),(b),sizeof(a[0])*(n))
#define ALL(x) (x.begin(),x.end())
#define prf(x) printf("%.20f", x)
#define for_each_edge(u) for(int i = point[u];i;i=G[i].n)
typedef unsigned int uint;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 100010
#define M 1024
#define MOD 1000000007
void _add(int &a, int b){a = (a+b)%MOD;}
void _sub(int &a, int b){a = (a+MOD-b)%MOD;}
void _mul(int &a, int b){a = (ll)a*b%MOD;}
void _max(int &a, int b){a = max(a,b);}
void _min(int &a, int b){a = min(a,b);}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b,a%b);}
ll pw(ll a, ll b){ll res(1);while(b){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
ll pwM(ll a, ll b, ll mod){ll res(1);while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int infi = 2147483647;
const ll infl = 1223372036854775807ll;
const db PI = 3.14159265358979323846;

/*
struct E{
	int v, w, n;
}G[N];
int cnt, point[N];
void adde(int u, int v, int w = 0){
	G[++cnt]=(E){v,w,point[u]},point[u]=cnt;
	G[++cnt]=(E){u,w,point[v]},point[v]=cnt;
}
void Ginit(){
	cnt = 0;
	SET(point,0);
}
*/
/*
struct hh{
	int a, b;
	bool operator < (const hh &x) const{
		if(a==x.a)return b<x.b;
		return a<x.a;
	}
}a[N];
*/
int n, m, k,q,x[N];
ll ansl[N], ansr[N];
ll posl[N], posr[N];
int main(){
//	freopen("1", "r", stdin);
	sc(n);sc(k);
	int l = 0;
	rep(i,1,n){
		sc(x[i]);
		if(x[i]>=0 && l == 0)l = i;
	}
	if(l == 0)l = n+1;
	rep(i,1,n)ansl[i] = ansr[i] = infl;
	if(l <= n){
		int tmp = 1;
		ansr[1] = x[l];
		posr[1] = x[l];
		rep(i,l+1,n){
			tmp++;
			ansr[tmp] = ansr[tmp-1]+x[i]-x[i-1];
			posr[tmp] = x[i];
		}
	}
	if(l-1 >= 1){
		l--;
		int tmp = 1;
		ansl[1] = 0-x[l];
		posl[1] = x[l];
		repr(i,1,l-1){
			tmp++;
			ansl[tmp] = ansl[tmp-1]+x[i+1]-x[i];
			posl[tmp] = x[i];
		}
	}
	ll ans = infl;
	rep(x,0,k)ans = min(ans, ansl[x]+min(0-posl[x],posr[k-x])+ansr[k-x]);
	pr64(ans),ln;
	
/*
	int Case;
	sc(Case);
	rep(ca, 1, Case){
	    printf("Case #%d: ", ca);
	}
*/
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 28;
int t[maxn], y[maxn], p[maxn];
vector <pair<int, pair<int, int>>> v;
string ans[maxn];
int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		v.push_back({y, {i, x}});
	}
	sort(v.begin(), v.end());
	for(auto x: v){
		t[x.second.second] ++;
		//cout << x.second.second << " &\n";
		int a = x.second.second, b = 1e5, c1 = 0;
		while(a / b == 0){
			c1 ++;
			b /= 10;	
		}
	//	cout << c1 << " *\n";
		a = t[x.second.second], b = 1e5;
		int c2 = 0;
		while(a / b == 0){
			c2 ++;
			b /= 10;	
	//		cout << c2 <<  "  ********** " << b << "\n";

		}
	//	cout << c2 << " &&\n";
		for(int i = 0; i < c1; i++)
			ans[x.second.first] += "0";
		ans[x.second.first] += to_string(x.second.second); 
		for(int i = 0; i < c2; i++)
			ans[x.second.first] += "0";
		ans[x.second.first] += to_string(t[x.second.second]);
	}
	for(int i = 0; i < m; i++)
		cout << ans[i] << "\n";
}

Measured memory_bytes: 9716
from collections import Counter

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

count = sorted(Counter(A).items())
more_than_2 = [0, 0]

for item in count:
    if item[1] >= 2:
        more_than_2.append(item[0])
    if item[1] >= 4:
        more_than_2.append(item[0])

print(more_than_2[-1] * more_than_2[-2])


Measured memory_bytes: 21412
import math
a=list(map(int,input().split()))
a.sort()
tmp1=a[2]-a[0]
tmp2=a[2]-a[1]
if((tmp1+tmp2)%2):
    print(math.ceil((tmp1+tmp2)/2)+1)
else:
    print(int((tmp1+tmp2)/2))

Measured memory_bytes: 3060