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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> f(n + 1, 1);
    for (int i = 2; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
            f[j]++;
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ans += i * f[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 42328
package main
  
import (
    "fmt"
)

func main() {
    var a, b int
    fmt.Scan(&a, &b)
    if (b-1)%(a-1) == 0 {
        fmt.Println((b - 1) / (a - 1))
    } else {
        fmt.Println(int((b-1)/(a-1)) + 1)
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = (1e+9) + 1;
const int mod = 1000000007;
const double pi = 3.141592653589;
vector<int> a;
int n, k;
/* function */
bool check(int p) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += (a[i] + (p - 1)) / p - 1;
    }
    if(sum <= k) return true;
    return false;
}
/* main */
int main(){
    cin >> n >> k;
    int ok = MAX, ng = 0;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    // penalty を２分探索
    // (ng ,..., ok]
    // (1 ~ 1e+9]
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << '\n';

}

Measured memory_bytes: 3976
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm> 
using namespace std;

set<string>S;
signed main() {
	int n; cin >> n;
	string a; cin >> a; S.insert(a);
	for (int i = 1; i < n; i++) {
		string b; cin >> b;
		if (*a.rbegin() != *b.begin()) { puts("No"); return 0; }
		S.insert(b);
		if (S.size() != i + 1) { puts("No"); return 0; }
		a = b;
	}
	puts("Yes");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    char s[8];
    cin>>s;
    if(s[0]=='S')
        cout<<"Cloudy"<<endl;
    else if(s[0]=='C')
        cout<<"Rainy"<<endl;
    else if(s[0]=='R')
        cout<<"Sunny"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 710;

int n, m;
bool G[MAX][MAX];
vector<int> cG[MAX];
int mark[MAX];
vector<int> t;

bool dfs(int v, int pv, int col){
    if(mark[v] >= 0) return mark[v] == col;
    mark[v] = col;
    ++t[col];
    for(int nv: cG[v])if(nv != pv){
        if(!dfs(nv, v, col ^ 1)) return false;
    }
    return true;
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, n)rep(j, n) G[i][j] = false;
    rep(i, m){
        int a, b;
        scanf("%d%d", &a, &b);
        --a; --b;
        G[a][b] = G[b][a] = true;
    }
    rep(i, n)For(j, i+1, n)if(!G[i][j]){
        cG[i].push_back(j);
        cG[j].push_back(i);
    }

    vector<pii> num;
    rep(i, n) mark[i] = -1;
    rep(i, n)if(mark[i] < 0){
        t = {0, 0};
        if(!dfs(i, -1, 0)){
            puts("-1");
            return 0;
        }
        num.emplace_back(t[0], t[1]);
    }

    int K = num.size();
    bool dp[K+1][n+1];
    rep(i, K+1)rep(j, n+1) dp[i][j] = false;
    dp[0][0] = true;
    rep(i, K)rep(j, n+1)if(dp[i][j]){
        dp[i+1][j+num[i].fi] = true;
        dp[i+1][j+num[i].se] = true;
    }
    int ans = m;
    rep(j, n+1)if(dp[K][j]) {
        chmin(ans, j*(j-1)/2 + (n-j)*(n-j-1)/2);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
  double deg1, deg2;
  cin >> deg1;
  cin >> deg2;
  double eps = 1e-8;
  for (double t = 0; t < 360.0; t += 0.5) {
    double p1 = deg1 + t;
    double p2 = deg2 + t;
    double n1 = deg1 - t;
    double n2 = deg2 - t;
    if (p1 > 360) { p1 -= 360; }
    if (p2 > 360) { p2 -= 360; }
    if (n1 < 0) { n1 += 360; }
    if (n2 < 0) { n2 += 360; }
    if (abs(p1 - n2) < eps) {
      printf("%.10lf\n", p1);
      break;
    }
    else if (abs(n1 - p2) < eps) {
      printf("%.10lf\n", n1);
      break;
    }
  }
}

Measured memory_bytes: 3276
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int l[m],r[m];
    rep(i,m) cin >> l[i] >> r[i];
    int L=0,R=n;
    rep(i,m){
        L = max(L,l[i]);
        R = min(R,r[i]);
    }
    L <= R ? cout << R - L + 1 << endl : cout << 0 << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void ppp(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(int n,int k){
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int jank(int a){
  char s[4]="spr";
  FOR(3)if(a==s[i])return i;
}
ll x[100000];
int main(void){
  int n;
  scanf("%d",&n);
  ll a[n];
  FOR(n)scanf("%lld",&a[i]);
  qsort(a,n,sizeof(ll),usort);
  FOR(n-1){
    if(a[i]==a[i+1]){
      PRS("NO");
      return 0;
    }
  }
  PRS("YES");
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main() {
    ll a,b;cin>>a>>b;
    ll x=__gcd(a,b);
    cout<<a*b/x<<endl;
}

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

//A
int main() {
    int N, odd, eve;
    double ans;
    std::cin >> N;
    eve = N/2;
    odd = N - eve;
    ans = (double) odd/N;

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX =2000007;
const int MOD = 998244353;
//

     signed main(){
     int n,ans=0;
     cin>>n;
     for(int i=1;i<=n;i++)ans+=i*(n/i)*(n/i+1)/2;
     cout<<ans<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 3632
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    long double R;
    cin >> R;

    cout << 2.0 * R * 3.14159265358979323846;
}

#pragma region main
main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3780
height, width = gets.split.map(&:to_i)
squares = Array.new(height) {Array.new(width, 0)}
queue = []

height.times do |h|
  gets.each_char.with_index do |e, w|
    if e == '#'
      queue << h * width + w
      squares[h][w] = 1
    end
  end
end

n_step = 0

while (q = queue.shift)

  h, w = q.divmod(width)
  n_step = squares[h][w]

  if h + 1 < height && squares[hh = h + 1][w] == 0
    squares[hh][w] = n_step + 1
    queue << hh * width + w
  end

  if 0 <= h - 1 && squares[hh = h - 1][w] == 0
    squares[hh][w] = n_step + 1
    queue << hh * width + w
  end

  if w + 1 < width && squares[h][ww = w + 1] == 0
    squares[h][ww] = n_step + 1
    queue << h * width + ww
  end

  if 0 <= w - 1 && squares[h][ww = w - 1] == 0
    squares[h][ww] = n_step + 1
    queue << h * width + ww
  end
end

puts n_step - 1



Measured memory_bytes: 21556
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var table [501][501]int

	var N, M, Q int
	fmt.Scan(&N, &M, &Q)
	for i := 0; i < M; i++ {
		sc.Scan()
		l, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		r, _ := strconv.Atoi(sc.Text())
		table[l][r]++
	}
	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			table[i][j] += table[i-1][j] + table[i][j-1] - table[i-1][j-1]
		}
	}
	w := bufio.NewWriter(os.Stdout)
	for i := 0; i < Q; i++ {
		sc.Scan()
		p, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		q, _ := strconv.Atoi(sc.Text())

		ans := table[q][q] - table[p-1][q] - table[q][p-1] + table[p-1][p-1]
		fmt.Fprintln(w, ans)
	}
	w.Flush()
}


Measured memory_bytes: 6828
s = input()

if s[0]==s[1] and s[0]==s[2]:
    print('No')

elif s[0] == s[1] and s[2]==s[3] :
    print('Yes')
elif s[0] == s[2] and s[1] == s[3]:
    print('Yes')
elif s[0] == s[3] and s[1]==s[2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<int> l(n),r(n),a(n),b(n),A(n),B(n);
  vector<pair<int,int>> c(n),d(n);
  int la=0,ra=1e9+5;
  int x=0,t;
  for(int i=0;i<n;i++){
    cin >> l[i] >> r[i];
    if(x<r[i]-l[i]+1){
      x=r[i]-l[i]+1;
      t=i;
    }
    c[i]=make_pair(l[i],r[i]);
    d[i]=make_pair(r[i],l[i]);
  }
  int L=0,R=1e9+5;
  for(int i=0;i<n;i++){
    if(i!=t){
      L=max(L,l[i]);
      R=min(R,r[i]);
    }
  }
  sort(c.begin(),c.end());
  sort(d.begin(),d.end());
  int lA=0,rA=1e9+5;
  for(int i=0;i<n;i++){
    la=max(la,c[i].first);
    ra=min(ra,c[i].second);
    a[i]=ra-la+1;
    lA=max(lA,d[i].second);
    rA=min(rA,d[i].first);
    A[i]=rA-lA+1;
  }
  int lb=0,rb=1e9+5;
  int lB=0,rB=1e9+5;
  for(int i=n-1;i>=0;i--){
    lb=max(lb,c[i].first);
    rb=min(rb,c[i].second);
    b[i]=rb-lb+1;
    lB=max(lB,d[i].second);
    rB=min(rB,d[i].first);
    B[i]=rB-lB+1;
  }
  int ans=0;
  for(int i=0;i<n-1;i++){
    ans=max(x+max(0,R-L+1),max(ans,max(a[i]+b[i+1],A[i]+B[i+1])));
  }
  cout << ans << endl;
}

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



int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	long long N;
	long long W;
	cin >> N >> W;
	vector<long long> w, v;
	for(long long i = 0; i < N; i++){
		long long x, y; cin >> x >> y;
		w.push_back(x);
		v.push_back(y);
	}
	vector< vector<long long> > knapsack(N + 1);
	//vector<long long> m(W, 0);
	//long long knapsack[100][100000]; An array cannot have more than 10^6 elements.
	for (long long i = 0 ; i <= N ; i++ )
   		knapsack[i].resize(W+1);

	for(long long j = 0; j <= W; j++){
		knapsack[N][j] = 0;
	}
	for(long long i = N-1; i >= 0; i--){
		for(long long j = 0; j <= W; j++){
			if(w[i] > j) knapsack[i][j] = knapsack[i+1][j];
			else knapsack[i][j] = max(knapsack[i+1][j-w[i]] + v[i], knapsack[i+1][j]);
		}
	}
	/*
	for(long long i = 0; i <= N; i++){
		for(long long j = 0; j <= W; j++){
			cout << knapsack[i][j] << " "; 
		}
		cout << "\n";
	}
	cout << "\n";
	*/
	cout << knapsack[0][W] << "\n";
}

Measured memory_bytes: 79488
import java.util.Scanner;

public class Main {
    int n, m;
    boolean[][] es;
    int[] as, bs;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        es = new boolean[n][n];
        as = new int[m];
        bs = new int[m];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            es[a][b] = es[b][a] = true;
            as[i] = a;
            bs[i] = b;
        }
    }

    private void solve() {
        int ans = 0;
        for (int i = 0; i < m; i++) {
            int a = as[i];
            int b = bs[i];
            es[a][b] = es[b][a] = false;
            if (!check())
                ans++;
            es[a][b] = es[b][a] = true;
        }
        System.out.println(ans);
    }

    private boolean check() {
        boolean[] fs = new boolean[n];
        dfs(0, 0, fs);
        boolean ret = true;
        for (boolean b: fs)
            ret &= b;
        return ret;
    }

    private void dfs(int node, int depth, boolean[] used) {
        if (used[node])
            return;
        used[node] = true;
        for (int i = 0; i < n; i++) {
            if (es[node][i] && !used[i])
                dfs(i, depth+1, used);
        }
    }

}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    string slim;
    cin>>slim;
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(i==0) {
            count++;
            continue;

        }
        if(slim[i]==slim[i-1]) continue;
        else count++;


    }
    cout<<count<<endl;





}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
//vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;

const int inf = 1000000000;

int main() {
	int n,m,x;
	cin >> n >> m >> x;
	v.resize(n);
	vv.resize(12, vector<int>(12, 0));
	rep(i, 0, n) {
		cin >> v[i];
		rep(j, 0, m)cin >> vv[i][j];
	}

	int ans = inf;
	rep(s, 0, 1 << n) {
		int cost = 0;
		vector<int> w(n);
		rep(i, 0, n) {
			if ((s >> i) & 1) {
				cost += v[i];
				rep(j, 0, m)w[j] += vv[i][j];
			}
		}
		bool ok = true;
		rep(j, 0, m)if (w[j] < x)ok = false;
		if (ok)ans = min(ans, cost);
	}
	if (ans == inf) cout << -1 << '\n';
	else cout << ans << '\n';
	return 0;
	
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		
		// 計算
		long result = 1;
		int MOD = 1000000007;
		if(n%2 == 0){
		    int num = 1;
		    for(int i = 0; i < n/2; i++){
		        if(a[2*i] != num || a[2*i+1] != num){
		            result = 0;
		            break;
		        }else{
		            result = result*2%MOD;
		            num += 2;
		        }
		    }
		}else{
		    int num = 0;
		    if(a[0] != num){
		        result = 0;
		        System.out.println(result);
		        return;
		    }
		    num += 2;
		    for(int i = 0; i < n/2; i++){
		        if(a[2*i+1] != num || a[2*i+2] != num){
		            result = 0;
		            break;
		        }else{
		            result = result*2%MOD;
		            num += 2;
		        }
		    }
		}
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

int main() {
  
  int n;
  string s;
  cin >> n >> s;
  
  string t,u;
  int count,saidai = 0;
  

  for ( int i = 1; i < n; i++){
    t = s.substr(0,i);
    u = s.substr(i,n-i);
    count = 0;
    
    sort(t.begin(),t.end());
    sort(u.begin(),u.end());
    
    t.erase(unique(t.begin(),t.end()),t.end());
    u.erase(unique(u.begin(),u.end()),u.end());
    
    
    for ( int j = 0; j < t.size(); j++){
      for ( int k = 0; k < u.size(); k++){
        if ( t[j] == u[k] ){
          count++;
        }
      }
    }
    saidai = max(saidai,count);
  }
   
  cout << saidai << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double r = Double.parseDouble(scanner.next());

        double area = r * r * Math.PI;
        double perimeter = 2.0 * r * Math.PI;

        System.out.printf("%6.6f %6.6f", area, perimeter);
    }
}

Measured memory_bytes: 26348
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

def read_int_list():
    return list(map(int,input().split(' ')))

def read_s_list_loop(n):
    return [input() for _ in range(n)]

T = input()
out = []
for i in range(len(T)):
    if T[i] == '?':
        out.append('D')
    else:
        out.append(T[i])
print(''.join(out))

Measured memory_bytes: 82200
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;

int main(){
    string s,t;
    cin >> s >> t;
    int count = 0;
    REP(i, 3){
    	if(s[i] == t[i]){
        	count++;
        }
	}
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;

public class Main {

    private static final String TLE = "TLE";

    public static String process(TestCase testCase) {
        final int N = testCase.N;
        final int T = testCase.T;
        final List<Integer> c = testCase.c;
        final List<Integer> t = testCase.t;

        Optional<Integer> minCost = Optional.empty();

        for (int i = 0; i < N; ++i) {
            final int cost = c.get(i);
            final int time = t.get(i);
            if (time <= T) {
                if (minCost.isPresent()) {
                    minCost = minCost.map(curr -> Math.min(curr, cost));
                } else {
                    minCost = Optional.of(cost);
                }
            }
        }

        return minCost.map(String::valueOf).orElse(TLE);
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int T = sc.nextInt();

        List<Integer> c = new ArrayList<>();
        List<Integer> t = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            c.add(sc.nextInt());
            t.add(sc.nextInt());
        }

        return new TestCase(N, T, c, t);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int N;
        final int T;
        final List<Integer> c;
        final List<Integer> t;

        public TestCase(int N, int T, List<Integer> c, List<Integer> t) {
            this.N = N;
            this.T = T;
            this.c = c;
            this.t = t;
        }
    }
}


Measured memory_bytes: 29012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); ++i);
using namespace std;

bool func(string S, int x, int y) {
	for (int i = x; i < y; i++) {
		if (S.at(i) != S.at(S.length() - 1 - i)) {
			return false;
		}
	}
	return true;
}

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

	string S1 = S.substr(0,(S.length() - 1) / 2);
	if (func(S, 0, (S.length() - 1) / 2) && func(S1, 0, round(float(S1.length() - 1) / 2))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

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

    long long int n, res;
    cin >> n;

    res = ((1 + n) * n) / 2;
    res -= 3 * (((n / 3) + 1) * (n / 3)) / 2;
    res -= 5 * (((n / 5) + 1) * (n / 5)) / 2;
    res += 15 * (((n / 15) + 1) * (n / 15)) / 2;

    cout << res << endl;
}




Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
  int a,b;
  scanf("%d",&a);
 scanf("%d",&b);
 if(a>b)
   printf("a > b\n");
 if(a==b)
   printf("a == b\n");
  if(a<b)
   printf("a < b\n");
  return 0;
}

Measured memory_bytes: 580
def main():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()

    if u == s:
        print(a - 1, b)
    else:
        print(a, b - 1)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 2940
# import sys
# sys.setrecursionlimit(10 ** 6)
import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(H, W, M, BOMs):
    h_count = [[0, i] for i in range(H + 1)]
    w_count = [[0, i] for i in range(W + 1)]
    bom_map_h = [[] for i in range(H + 1)]
    BOMs.sort(key=lambda x: x[1])
    for bom in BOMs:
        h_count[bom[0]][0] += 1
        w_count[bom[1]][0] += 1
        bom_map_h[bom[0]].append(bom[1])
    h_count.sort(reverse=True)
    w_count.sort(reverse=True)
    h_max = h_count[0][0]
    w_max = w_count[0][0]
    ans = h_max + w_max - 1
    flg = False
    for hc in h_count:
        if hc[0] < h_max:
            break
        for wc in w_count:
            if wc[0] < w_max:
                break
            aaa = bom_map_h[hc[1]]
            bbb = bisect.bisect_left(bom_map_h[hc[1]], wc[1])
            if len(aaa) == bbb or aaa[bbb] != wc[1]:
            # if bom_map_h[hc[1]][bisect.bisect_left(bom_map_h[hc[1]], wc[1])] != wc[1]:
            # if not wc[1] in bom_map_h[hc[1]]:
                ans = h_max + w_max
                flg = True
                break
        if flg:
            break
    print(ans)


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    H, W, M = map(int, input().split())
    BOMs = [[int(i) for i in input().split()] for _ in range(M)]
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]

    # import random
    # H, W = 10, 10
    # M = random.randint(1, H * W)
    # BOMs = []
    # bom_map = [[0] * W for _ in range(H)]
    # i = 0
    # while i < M:
    #     h = random.randint(1, H)
    #     w = random.randint(1, W)
    #     if bom_map[h - 1][w - 1] == 0:
    #         i += 1
    #         bom_map[h-1][w-1]=1
    #         BOMs.append([h, w])
    # print(H, W, M)
    # import pprint
    # pprint.pprint(BOMs)

    # H, W, M = 10,10,7
    # BOMs = [[2, 2], [2, 3], [1, 6], [4, 6], [7, 3], [10, 6], [5, 5]]
    solve(H, W, M, BOMs)


Measured memory_bytes: 228888
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])cout<<"Yes"<<endl;
    else fin("No");
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n;
    cin >> n;

    vector<ll> elements;
    for(ll i=1; i*i<=n; i++){
        if(n%i == 0){
            elements.push_back(i);
            if(i*i != n){
                elements.push_back(n/i);
            }
        }
    }

    ll res = 0;
    for(auto const& e : elements){
        if(e > 1 && n/(e-1) == n%(e-1)){
            res += e-1;
        }
    }

    //vdebug(elements);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
     vector<vector<vector<int>>> rooms(4,vector<vector<int>>(3,vector<int>(10,0)));
     int n;
     cin>>n;
     for(int i=0;i<n;++i)
     {
         int b,f,r,v;
         cin>>b>>f>>r>>v;
         rooms[b-1][f-1][r-1]+=v;
     }
     for(int i=0;i<4;++i)
     {
         for(int j=0;j<3;++j)
         {
             for(int k=0;k<10;++k)
             {
                 cout<<" "<<rooms[i][j][k];
             }
             cout<<endl;
         }
         if(i!=3)cout<<"####################"<<endl;
     }
 }


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
vector<int> data(100010,-1);

int root(int x){
    return (data[x] < 0)? x : data[x]=root(data[x]);
}

bool unite(int x, int y){
    x=root(x);
    y=root(y);
    if( x != y ){
        if( data[y] < data[x] ) swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }
    return x!=y;
}

bool find(int x, int y){
    return root(x) == root(y);
}

int size(int x){
    return -data[ root(x) ];
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> p(n);
    rep(i,0,n) {
        cin>>p.at(i);
        p.at(i)--;
    }
    
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        x--;y--;
        unite(x,y);
    }
    
    int ans=n;
    rep(i,0,n){
        if(root(i)!=root(p.at(i))) ans--;
    }
    
    cout<<ans<<endl;
}


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

int main() {
    string str1, str2;
    int m, h;
    while (true) {
        cin >> str1;
        if (str1 == "-") {
            break;
        }
        str2 = str1;
        cin >> m;
        while (m--) {
            cin >> h;
            for (int i = 0; i < str1.size(); ++i) {
                str2[i] = str1[(i + h) % str1.size()];
            }
            str1 = str2;
        }
        cout << str1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <numeric>
#include <queue>
#include <sstream>
#include <set>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    int64_t q,h,s,d ;
    int64_t n ;
    cin >> q >> h >> s >> d ;
    cin >> n ;
    q *= 4 ;
    h *= 2 ;
    int64_t buy = min(min(q,h),s) ;
    int64_t ans = 0 ;
    if (2*buy < d)
    {
        ans = buy*n ;
    }else
    {
        ans += d * (n/2) ;
        ans += buy * (n%2) ;
    }
    
    cout << ans << endl ;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();

		int AB = Math.abs(a-b);
		int AC = Math.abs(a-c);
		int BC = Math.abs(b-c);

		//AとCが直接会話可能または、AとBが直接会話可能かつBとCが直接会話可能
		if (AC <= d || (AB <= d && BC <= d)) {
			System.out.println("Yes");

		//AとCが会話不可能
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 25172
S = input()

Ans = "WA"
if S[0]=="A" and S[2:-1].count("C")==1:
    cnt = 0
    for s in S[1::]:
        if s in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
            cnt += 1
    if cnt == 1:
        Ans = "AC"

print(Ans)

Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int h, w;
int dp[2000][2000];
bool a[2000][2000];
signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			if (s[j] == '.') a[i][j] = 1;
			else a[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!a[i][j]) continue;
			dp[i][j] %= Mod;
			dp[i + 1][j] += a[i + 1][j] * dp[i][j];
			dp[i][j + 1] += a[i][j + 1] * dp[i][j];
		}
	}
	cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 20608
#include <iostream>
#include <cmath>
 
using ll = long long;
 
 
ll F(const ll &x) {
    ll ans;
    switch(x%4) {
        case 0:
            ans = x;
            break;
        case 1:
            ans = 1;
            break;
        case 2:
            ans = x+1;
            break;
        case 3:
            ans = 0;
            break;
        default:
            break;
    }
    return ans;
}
 
void solve(const ll &A, const ll &B) {
    std::cout << ( F(A-1) ^ F(B) ) << std::endl;
}
 
int main() {
    ll A, B;
    std::cin >> A >> B;
    solve(A, B);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        string S = Console.ReadLine();

        int winNum = S.Count(c => c == 'o');

        var remain = 15 - S.Length;

        if(winNum + remain >= 8)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int ans = (n+max(h,w)-1) / max(h,w);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int num[10];
	int flag;
	int i;
	int x;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &num[i]);
	}
	
	flag = 1;
	while (flag == 1){
		flag = 0;
		for (i = 0; i < 10 - 1; i++){
			if (num[i] < num[i + 1]){
				x = num[i];
				num[i] = num[i + 1];
				num[i + 1] = x;
				flag = 1;
			}
		}
	}
	
	for (i = 0; i < 3; i++){
		printf("%d\n", num[i]);
	}
	
	return (0);
}

Measured memory_bytes: 0
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<u32>()[0];

    if n%10 == 9 || n/10 == 9{
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    vector<ll> fmemo;
    vector<ll> imemo;
    vector<ll> ifmemo;
    
    Combination(int maxn) : maxn(maxn){
        fmemo.resize(maxn + 1);
        imemo.resize(maxn + 1);
        ifmemo.resize(maxn + 1);
        for(ll i = 1; i <= maxn; i++){
            imemo[i] = modpow(i, MOD - 2);
        }
    }

    ll fact(ll n){
        if(n == 0) return 1;
        if(fmemo[n]) return fmemo[n];
        return fmemo[n] = n * fact(n - 1) % MOD;
    }

    ll ifact(ll n){
        if(n == 0) return 1;
        if(ifmemo[n]) return ifmemo[n];
        return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
    }

    ll com(ll n, ll k){
        if(k > n) return 0;
        if(k == n || k == 0) return 1;
        return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
    }
};

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    Combination com(n * m);
    ll c = com.com(n * m - 2, k - 2);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(i + j == 0) continue;
            if(i == 0 || j == 0) ans = (ans + c * (i + j) % MOD * (n - i) * (m - j) % MOD) % MOD;
            else ans = (ans + c * (i + j) % MOD * (n - i) * (m - j) * 2 % MOD) % MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 14324
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int mx = 0 , cnt = 0 , n;
  cin >> n;
  while(n--)
  {
      int a,b;
      cin >> a >> b;
      if(a==b)cnt++;
      else cnt = 0;
      mx = max(mx,cnt);
  }
  if(mx>=3)
    cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <map>
#include <set>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    map<pair<int, int>, set<int>> pair_index;
    for(int i=0; i<n; i++){
        double x;
        int pow2=0, pow5=0;
        unsigned long long val;
        scanf("%lf", &x);
        val=llround(x*1e9);
        while(val%2==0){
            pow2++;
            val/=2;
        }
        while(val%5==0){
            pow5++;
            val/=5;
        }
        pair_index[*new pair(pow2, pow5)].insert(i);
    }
    unsigned long long counter=0;
    for(auto i=pair_index.begin(); i!=pair_index.end(); i++){
        for(auto j=i; j!=pair_index.end(); j++){
            if(min(i->first.first+j->first.first, i->first.second+j->first.second)>=18){
                if(i==j){
                    counter+=i->second.size()*(j->second.size()-1)/2;
                }else if(*i<*j){
                    counter+=(i->second.size()*j->second.size());
                }
            }
        }
    }
    printf("%llu\n", counter);
    return 0;
}

/*Logic:
 * Since floating points are stored as approximate value.
 * Direct multiplication will result in some anomaly.
 * To avoid that we multiplied the given floating point or regular number
 * with 10^9, because the highest number of digits after decimal is 9.
 * This will make the numbers to be in the form
 * number/10^9.
 * Now, if we multiply say (x/10^9 * y/10^9) then we get
 * xy/10^18.
 * To get an integer, all we have to do is cancel out the denominator.
 * So xy has be z*(10^(>=9)).
 * Now we also know that 10^p is basically (2^p)*(5^p).
 * Here, p has to be equal to or greater that 9.
 *
 * Now, comes to the problem of handling TLE.
 * Since the dataset is 2*10^6 and 2 sec, regular brute force gave me TLE.
 * So in order to handle that a map with key (2^p)*(5^q) where p varies and q varies
 * and as value stores the indices of where key was found.
 * Now, for any pair of keys min(p1+p2, q1+q2) >=18, then all we multiply the number
 * of values from the keys.
 * If for the same key min(p1+p1, q1+q1) >=18, then all possible combinations are required.
 * Thus number of values*(number of values-1)/2.
 * Summation of all of these results in the answer.
 */

Measured memory_bytes: 19372
/* binary_indexed_tree.cpp
    BIT を用いて、区間和の更新や計算を高速に行う。

    verified: AOJ DSL_2_B
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp


    応用: 転倒数の計算( i<j において a_i > a_j となる数を数える)
        j(0~n-1)について以下を繰り返す
            1. j-sum(a_j)を答えに加える
            2. add(a_j,1)
        sum(a_j)は i<j における a_i<= a_j となる数なので、 j-sum(a_j) で j を固定したときの転倒数が求まる
        計算量は O(n long n)

    応用: 集合の中で w 番目に小さいものや、ある要素が何番目に小さいかが高速に分かる
        ・add(a,1): 集合への要素 a の追加(a 番目を 1 にする)
        ・add(a,-1): 集合への要素 a の削除(a 番目を 1 から 0 にする)
        ・sum(a): a が何番目(1はじまり)に小さいか
        ・lower_bound(w): w 番目(1はじまり)に小さい要素 a は何か
        値の範囲が N までとした時、メモリO(N), 計算量O(logN)だけかかる

        verified: ARC033 C - データ構造
            https://atcoder.jp/contests/arc033/tasks/arc033_3
*/

#include <bits/stdc++.h>
using namespace std;

#include <bits/stdc++.h>
using namespace std;

/* BIT: 区間和の更新や計算を行う構造体
    初期値は a_1 = a_2 = ... = a_n = 0
    ・add(l,r,x): [l,r) に x を加算する
    ・sum(i): a_1 + a_2 + ... + a_i を計算する
    ・query(l,r): [l,r) の区間の和を求める
    計算量は全て O(logn)
*/
template <typename T>
struct BIT {
    int n;             // 要素数
    vector<T> bit[2];  // データの格納先
    BIT(int n_) { init(n_); }
    void init(int n_) {
        n = n_ + 1;
        for (int p = 0; p < 2; p++) bit[p].assign(n, 0);
    }

    void add_sub(int p, int i, T x) {
        for (int idx = i; idx < n; idx += (idx & -idx)) {
            bit[p][idx] += x;
        }
    }
    void add(int l, int r, T x) {  // [l,r) に加算
        add_sub(0, l, -x * (l - 1));
        add_sub(0, r, x * (r - 1));
        add_sub(1, l, x);
        add_sub(1, r, -x);
    }

    T sum_sub(int p, int i) {
        T s(0);
        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
            s += bit[p][idx];
        }
        return s;
    }
    T sum(int i) { return sum_sub(0, i) + sum_sub(1, i) * i; }

    // [l,r) の区間和を取得
    T query(int l, int r) { return sum(r - 1) - sum(l - 1); }
};

using ll = long long;
int main() {
    ll N, K;
    cin >> N >> K;
    BIT<ll> bit1(N + 2), bit2(N + 2);
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        bit1.add(i + 1, i + 2, A[i]);
    }

    for (int k = 0; k < K; k++) {
        ll sum = bit1.query(1, N + 1);
        if (sum == N * N) break;
        for (int i = 0; i < N; i++) {
            int l = max(1, i + 1 - (int)bit1.query(i + 1, i + 2));
            int r = min((int)N + 1, i + 2 + (int)bit1.query(i + 1, i + 2));

            bit2.add(l, r, 1);
        }
        bit1 = bit2;
        bit2.init(N + 1);
    }

    for (int i = 0; i < N; i++) {
        cout << bit1.query(i + 1, i + 2);
        if (i != N - 1) cout << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 10388
import numpy as p
n,M=map(int,input().split())
l=n*3+1
d=p.zeros((l,n*5),p.int64)
d[0][0]=d[1][1]=d[2][2]=d[2][-1]=1
for i in range(3,l):j,k=i-1,i-2;d[i]=(d[i-3]*k*j+p.roll(d[k],-1)*j+p.roll(d[j],1))%M
print(d[-1][:l].sum()%M)

Measured memory_bytes: 481488
//submitted by sldinkar
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod (int)1000000007
#define MOD (int)10000000007
#define infinity (int)(1e18)

#define all(a) a.begin(),a.end()
#define ll long long
#define int long long
#define pb push_back
#define precision(n) fixed<<setprecision(n)
#define endl "\n"
#define no "NO"
#define yes "YES"


#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define test(t) int t; cin >> t; while (t--)
#define init(a, i) memset(a, i, sizeof(a))


#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define vii vector<pi>

#define f first
#define s second

int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int lcm(int a,int b) {return a*b/gcd(a,b);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}

bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
bool isPowerOfTwo(int x) {   return x && (!(x&(x-1))); }



// main code starts from here

int a[100001]={0},b[100001]={0},c[100001]={0};
int n,k;
int dp[100001][4];

int Cost(int ind,int flag){
    if(ind==n)return 0;

    if(dp[ind][flag]!=-1)return dp[ind][flag];


    if(flag==0){
        return dp[ind][flag]=max(a[ind]+Cost(ind+1,1),max(b[ind]+Cost(ind+1,2),c[ind]+Cost(ind+1,3)));
    }
    else if(flag==1){
        return dp[ind][flag]=max(b[ind]+Cost(ind+1,2),c[ind]+Cost(ind+1,3));
    }
    else if(flag==2){
        return dp[ind][flag]=max(a[ind]+Cost(ind+1,1),c[ind]+Cost(ind+1,3));
    }
    else if(flag==3){
        return dp[ind][flag]=max(a[ind]+Cost(ind+1,1),b[ind]+Cost(ind+1,2));
    }
}

signed main()
{
    fast;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
    memset(dp,-1,sizeof dp);
    cout<<Cost(0,0)<<endl;
    return 0;
}

Measured memory_bytes: 13780