akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        int[] arr = new int[n];
        st = new StringTokenizer(f.readLine());
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(st.nextToken());
        }
        int dp[]=new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0]=0;
        for(int i=0;i<n;i++){
            for(int j=i;j>=0 && j>=i-k;j--){
                //jump from all ones before
                dp[i]=Math.min(dp[i],dp[j]+Math.abs(arr[i]-arr[j]));
            }
        }
        System.out.println(dp[n-1]);
        f.close();
    }
}


Measured memory_bytes: 35160
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-19 20:45:36
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template <class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { int flag = 0; for (auto e : vec) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { int flag = 0; for (auto e : st) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { int flag = 0; for (auto e : mp) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { for (T& e : vec) is >> e; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

const double PI = acos(-1);

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

  double r; cin >> r;

  cout << setprecision(17) << 2 * PI * r << endl;

  return 0;
}

Measured memory_bytes: 3800
#include<iostream> 
#include<string>
#include<algorithm>
using namespace std;
int A[100];
void output(int a[],int N) {
	cout << a[0];
	for (int i = 1; i < N; i++) {
		cout << " " << a[i];
	}
	cout << endl;
}
int main()
{
	int N,v;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	v = 0;
	for (int i = 0; i < N; i++) {
		for (int j = N-1; j >0; j--) {
			if (A[j] < A[j - 1]) {
				int temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				v++;
			}
		}
	}
	cout << A[0];
	for (int i = 1; i < N; i++) {
		cout<<" "<< A[i];
	}
	cout << endl;
	cout << v << endl;
}


Measured memory_bytes: 3124
import sys
array_abc = list(map(int,input().split()))
K = int(input())

if not ( 1 <= min(array_abc),max(array_abc) <= 50 ):
    sys.exit()
if not ( 1 <= K <= 10 ):
    sys.exit()

print(sum(array_abc) + max(array_abc) * (2 ** K - 1))

Measured memory_bytes: 9092
/*** I came, I saw, I conquered. ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;typedef unsigned long long ull;
#define sc(a) cin >> a
#define pf(a) cout << a << endl
#define forIn(arr, num) for(ll i = 0; i < num; i++) cin >> arr[i];
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define mod 1000000007
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define GET_SET_BITS(a) (__builtin_popcount(a))
#define GET_SET_BITSLL(a) ( __builtin_popcountll(a))
#define GET_TRAIL_ZERO(a) (__builtin_ctz(a))
#define GET_LEAD_ZERO(a) (__builtin_clz(a))
#define GET_PARITY(a) (__builtin_parity(a))
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
void go() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
/*----------------------------------------------------------------*/
void solve() {
    int n;
    sc(n);

    vector<ll> dp(n + 1, 0);
    dp[0] = 1;
    for(int i = 3;i <= n;i++) {
        for(int j = 3;j <= i;j++) {
            dp[i] = (dp[i] + dp[i - j]) % mod;
        }
    }

    pf(dp[n]);
}

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

Measured memory_bytes: 3640
import sys
from bisect import bisect_right


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n, m, k = _ia()
    a = [0] + list(_ia())
    b = [0] + list(_ia())
    for i in range(n):
        a[i+1] += a[i]
    for i in range(1, m):
        b[i+1] += b[i]

    mx = 0
    for i, tot in enumerate(a):
        km = k - tot
        if km < 0:
            continue

        j = bisect_right(b, km) - 1
        tot += b[j]
        if tot <= k:
            mx = max(mx, i+j)

    return mx


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


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

int main() {
	int n;
	cin>>n;
	int b[n-1];
	for(int i=0;i<n-1;i++)
		cin>>b[i];
	int ans=0;
	ans+=b[n-2];
	for(int i=n-3;i>=0;i--)
	{
		ans+=min(b[i],b[i+1]);
	}
	ans+=b[0];
	cout<<ans;
	return 0;
}

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

using namespace std;
typedef long long ll;
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; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL << 60;

int main(){

  int n;cin>>n;
  int d[n+10];rep(i,0,n)cin>>d[i];

  ll ans=0;
  rep(i,0,n-1){
    rep(j,i+1,n){
      ans+=d[i]*d[j];
    }
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

		PrintWriter out = new PrintWriter(System.out);
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for (int i = 0; i < n; i++) {
			byte s = Byte.parseByte(scan.next());
			byte g = Byte.parseByte(scan.next());
			if(s<g || s<=5) out.println(range(s,g));
			else{
				if(g>=6) out.println(range(s,9)+" "+range(5,0)+" "+range(1,g));
				else out.println(range(s,9)+" "+range(5,g));
			}
		}
		out.flush();
	}

	static String range(int p,int q){
		int d = p<q ? 1:-1;
		String mes = "";
		for (int i = p; i != q; i+=d) {
			mes+=i+" ";

		}
		return mes+q;
	}
}

Measured memory_bytes: 17200
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
int n,a,b,c,d;
cin>>n>>a>>b>>c>>d;
int a1=((int)(n/a))*b;
int a2=((int)(n/c))*d;
if(n%a!=0){a1+=b;}
if(n%c!=0){a2+=d;}
	cout<<min(a1,a2)<<endl;
return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int ans;
    ans = max(a+b, a-b);
    ans = max(ans, a*b);
    cout << ans << endl;
    return 0;
}

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

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

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

unordered_map<long long, long long> mp;
unordered_map<long, long> mp2;

int main()
{
    long long n,k,a;

    cin >> n;
    cin >> k;

    for(long long i = 1; i <= n; i++){
        cin >> a;
        mp[i] = a;

        if(i > k){
            if(a > mp[i - k]){
                cout << "Yes\n";
            }else{
                cout << "No\n";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 11404
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
ll computeXOR(ll n)
{
    // Modulus operator are expensive on most of the
    // computers. n & 3 will be equivalent to n % 4.

    switch(n & 3) // n % 4
    {
    case 0: return n;     // if n is multiple of 4
    case 1: return 1;     // If n % 4 gives remainder 1
    case 2: return n + 1; // If n % 4 gives remainder 2
    case 3: return 0;     // If n % 4 gives remainder 3
    }
}
void solve()
{
    ll n,m,k,x,y,res=0,l,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1,cnt2=0;
   cin>>n>>m;
   res=computeXOR(n-1)^computeXOR(m);
   cout<<res;

}
int main()
{   speed_up
    ll t;
   // cin>>t;
    t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s[]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int main(){
    string o;
    cin>>o;
    for(int i=0;i<7;i++){
        if(o==s[i]){
            cout<<7-i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Edge
{
public:
    int to, cap, rev;
    Edge(){};
    Edge(int to0, int cap0){to = to0; cap = cap0;}
    Edge(int to0, int cap0, int rev0){to = to0; cap = cap0; rev = rev0;}
};

int maxFlow(const vector<vector<Edge> >& edges0, int source, int sink)
{
    static vector<vector<Edge> > edges;
    static vector<bool> used;

    class Func{
    public:
        static int dfs(int s, int t, int f){
            if(s == t)
                return f;
            used[s] = true;
            for(unsigned i=0; i<edges[s].size(); ++i){
                Edge& e = edges[s][i];
                if(!used[e.to] && e.cap > 0){
                    int g = dfs(e.to, t, min(f, e.cap));
                    if(g > 0){
                        e.cap -= g;
                        edges[e.to][e.rev].cap += g;
                        return g;
                    }
                }
            }
            return 0;
        }
    };

    int n = edges0.size();
    edges.assign(n, vector<Edge>());
    for(int i=0; i<n; ++i){
        for(unsigned j=0; j<edges0[i].size(); ++j){
            const Edge& e = edges0[i][j];
            edges[i].push_back(Edge(e.to, e.cap, edges[e.to].size()));
            edges[e.to].push_back(Edge(i, 0, edges[i].size()-1));
        }
    }

    int ret = 0;
    for(;;){
        used.assign(n, false);
        int f = Func::dfs(source, sink, INT_MAX);
        if(f == 0)
            return ret;
        ret += f;
    }
}

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

    vector<vector<Edge> > edges(2*n+1);
    for(int i=0; i<n; ++i)
        edges[2*i].push_back(Edge(2*i+1, 1));

    while(--m >= 0){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;

        edges[2*a+1].push_back(Edge(2*n, 1));
        edges[2*b+1].push_back(Edge(2*n, 1));

        if(maxFlow(edges, 1, 2*n) == 2)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;

        edges[2*a+1].pop_back();
        edges[2*b+1].pop_back();

        edges[2*a+1].push_back(Edge(2*b, 1));
        edges[2*b+1].push_back(Edge(2*a, 1));
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long>A(N);
  for(int i=0; i<N; i++)cin >> A.at(i);
  
  long long nagasa, naka1, naka2, ans;
  nagasa = naka1 = naka2 = ans =0;
  
  for(int i=0; i<N; i++){
    nagasa += A.at(i);
  }
  
  for(int i=0; i<N; i++){
    naka1 += A.at(i);
    if(naka1*2>=nagasa)break;
    naka2 += A.at(i);
  }
  
  
  ans += min(2*naka1-nagasa, nagasa-naka2*2);
  
  cout << ans << endl;
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  vector<long> A(N);
  rep(i, 0, N) {
    cin >> A[i];
  }

  int ans = 1000000000;
  rep(i, 0, N) {
    double n = 1.0;
    int m = 0;
    while (1) {
      int x = pow(2.0, n);
      if (A[i] % x == 0) {
        m = max(m, int(n));
      } else {
        ans = min(ans, m);
        break;
      }
      ++n;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include<iomanip>
using namespace std;
using ll=long long;
const ll INF=1000000000000000000;
 
struct edge {
    ll to;
    ll cost;
};
// <最短距離, 頂点の番号>
using P = pair<ll, ll>;
 


void dijkstra(vector<edge> *G, ll V, ll s, ll *d) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    que.push(P(0, s));
    d[s]=0;
 
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    const ll MAX_V=100005;
    vector<edge> G[MAX_V];
    ll d[MAX_V];

    ll N;
    cin >> N;
    for(ll i=0;i<N-1;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        edge e1 = {a-1,c};
        G[b-1].push_back(e1);
        edge e2 = {b-1,c};
        G[a-1].push_back(e2);
    }
    ll Q,K;
    cin >> Q >> K;
    dijkstra(G,N,K-1,d);
    vector<ll> out;
    for(ll i=0;i<Q;i++){
        ll x,y;
        cin >> x >> y;
        out.push_back(d[x-1]+d[y-1]);
    }
    for(ll v : out){
        cout << v << endl;
    }
}

Measured memory_bytes: 11120
while True:
    h, w = map(int, input().split())
    if (h, w) == (0, 0):
        break
    else:
        for i in range(h):
            if i == 0:
                print('#' * w, sep='')
            elif i == (h-1):
                print('#' * w)
                print()
            else:
                print(f"#", "." * (w - 2), "#", sep='')


Measured memory_bytes: 5636
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for (i=0; i<n1; i++) L[i] = A[left+i];
  for (i=0; i<n2; i++) R[i] = A[mid+i];
  i = j = 0;
  L[n1].value = R[n2].value = SENTINEL;
  for (k=left; k<right; k++){
    if (L[i].value <= R[j].value){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right){
  int mid;
  if (right - left > 1){
    mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int  n, int p, int r){
  int j;
  struct Card t, x;
  x = A[r];
  int i = p - 1;
  for (j=p; j<r; j++){
    if (A[j].value <= x.value){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if (p < r){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q-1);
    quickSort(A, n, q+1, r);
  }
}

int main(){
  int i, n, v;
  char S[10];
  struct Card A[MAX], B[MAX];
  int stable = 1;

  scanf("%d", &n);
  for (i=0; i<n; i++){
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

  for (i=0; i<n; i++){
    if (A[i].suit != B[i].suit) stable = 0;
  }

  if (stable) printf("Stable\n");
  else printf("Not stable\n");
  for (i=0; i<n; i++){
    printf("%c %d\n", B[i].suit, B[i].value);
  }

  return 0;
}



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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

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

int main(){
	double h,a;
	cin>>h>>a;

	cout<<ceil(h/a)<<endl;


	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func choose2(n int) int {
	return n * (n - 1) / 2
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	a := make([]int, n)
	cnt := make(map[int]int)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		cnt[a[i]]++
	}

	var sum int
	for _, n := range cnt {
		sum += choose2(n)
	}

	for i := 0; i < n; i++ {
		ans := sum
		ans -= choose2(cnt[a[i]])
		ans += choose2(cnt[a[i]] - 1)
		fmt.Println(ans)
	}
}


Measured memory_bytes: 14720
#include<iostream>

using namespace std;

class Dice {
    public:
        int D1;
        int D2;
        int D3;
        int D4;
        int D5;
        int D6;

        Dice(int d1, int d2, int d3, int d4, int d5, int d6);
        void Rotate_E();
        void Rotate_N();
        void Rotate_S();
        void Rotate_W();

};

Dice::Dice(int d1, int d2, int d3, int d4, int d5, int d6) {
    D1 = d1;
    D2 = d2;
    D3 = d3;
    D4 = d4;
    D5 = d5;
    D6 = d6;
}

void Dice::Rotate_E() {
    int tmp;

    tmp = D3;
    D3 = D1;
    D1 = D4;
    D4 = D6;
    D6 = tmp;
}

void Dice::Rotate_N() {
    int tmp;

    tmp = D5;
    D5 = D1;
    D1 = D2;
    D2 = D6;
    D6 = tmp;
}

void Dice::Rotate_S() {
    int tmp;

    tmp = D5;
    D5 = D6;
    D6 = D2;
    D2 = D1;
    D1 = tmp;
}

void Dice::Rotate_W() {
    int tmp;

    tmp = D3;
    D3 = D6;
    D6 = D4;
    D4 = D1;
    D1 = tmp;
}

int main () {

    int d1, d2, d3, d4, d5, d6;
    cin >> d1 >> d2 >> d3 >> d4 >> d5 >> d6;
    Dice Dice1(d1, d2, d3, d4, d5, d6);

    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int a, b;
        cin >> a >> b;

        if (Dice1.D3 == b || Dice1.D4 == b) {
            Dice1.Rotate_E();
        }

        while (Dice1.D2 != b) {
            // cout << "Now Loading\n" << endl;
            Dice1.Rotate_N();
        }

        while (Dice1.D1 != a) {
            // cout << "Now Loading2\n" << endl;
            Dice1.Rotate_E();
        }

        cout << Dice1.D3 << endl;
    }

    return 0;
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll n,a[100010],q,b[100010],c[100010],sum=0;
map<ll,ll> mp;

int main(void){
	cin>>n;
	rep(i,n)cin>>a[i];
	cin>>q;
	rep(i,q)cin>>b[i]>>c[i];
	rep(i,n){
		mp[a[i]]++;
		sum+=a[i];
	}
	rep(i,q){
		sum = sum + mp[b[i]]*(c[i]-b[i]);
		mp[c[i]]+=mp[b[i]];
		mp[b[i]]=0;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 11836
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

test_case = []
for i in range(n):
    x1, y1 = xy[i]
    test_case.append((x1, y1))
    test_case.append((y1, -x1))
    test_case.append((-y1, x1))

ret = 0
for x1, y1 in test_case:
    sx, sy, tx, ty = 0, 0, 0, 0
    for j in range(n):
        x2, y2 = xy[j]
        if x1 * x2 + y1 * y2 > 0 or (x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 >= 0):
            sx += x2
            sy += y2
    ret = max(ret, math.hypot(sx, sy), math.hypot(tx, ty))
print(ret)

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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double concentration = -1;
    int ans_sum, ans_sugar;
    for (int i = 0; i <= f / (100 * a); ++i) {
        for (int j = 0; 100 * b * j <= f - 100 * a * i; ++j) {
            int water = 100 * a * i + 100 * b * j;
            int sugar_can_be_dissolved = (a * i + b * j) * e;
            // cout << "water " << water << " sugar " << sugar_can_be_dissolved << endl;
            for (int k = 0; k <= min(sugar_can_be_dissolved / c, (f - water) / c); ++k) {
                for (int l = 0; d * l <= min(sugar_can_be_dissolved - c * k, (f - water) - c * k); ++l) {
                    double tmp = ((double)k * c + l * d) / ((double)water + k * c + l * d);
                    tmp *= 100.0;
                    if (tmp >= concentration && (k * c + l * d) <= sugar_can_be_dissolved) {
                        ans_sum = water + k * c + l * d;
                        ans_sugar = k * c + l * d;
                        concentration = tmp;
                    }
                }
            }
        }
    }

    cout << ans_sum << " " << ans_sugar << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
main(){
	string str[33],tmp;
	int data[33];
	for(int i=0;i<=33;++i)data[i]=0;
	int k=0;
	while(cin>>tmp){
		//if(tmp=="nil")break;
		for(int i=0;i<=k;++i){
			if(str[i]==tmp){
				data[i]++;
				break;
			}
			if(i==k){
				str[i]=tmp;
				data[i]++;
				++k;
				break;
			}
		}
	}
	string a;
	int ans[2]={0,0};
	for(int i=0;i<=k;++i){
		if(data[i]>data[ans[0]]){
			ans[1]=data[i];
			ans[0]=i;
		}
	}
	a=str[ans[0]];
	ans[0]=ans[1]=0;
	for(int i=0;i<=k;++i){
		if(ans[1]<str[i].size()){
			ans[1]=str[i].size();
			ans[0]=i;
		}
	}
	cout<<a<<" "<<str[ans[0]]<<endl;
	
}

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();
  if (n <= k)
    cout << s << endl;
  else
    cout << s.substr(0, k) << "..." << endl;
  return 0;
}


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

int main()
{
    long long W, H, x,y;

    cin >> W>>H>>x>>y;

    double ans = (double)W * H / 2.0;

    if(W==x*2.0 && H==y*2.0){
        cout<<ans<<" "<<1;
    }else{
        cout<<ans << " " << 0;
    }

    return 0;
}

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

inline int ans(int n, int m, int x)
{
	int a = 0;
	if (n == 0 && m == 0) return 1;
	if (n > 0) for (int i = x; i < 10; i++) if (m - i >= 0) a += ans(n - 1, m - i, i + 1);
	return a;
}

int main(void)
{
	int  n, s, num[] = {1,2,3,4,5,6,7,8,9};
	while (cin >> n >> s)
	{
		if (n == 0 && s == 0) break;
		cout << ans(n, s, 0) << endl;
	}
	return 0;
}


Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int n;
    cin >> n;
    vector<int> v(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    vector<int> v_temp = v;
    sort(v.begin() + 1, v.end());
    for (int i = 1; i <= n; i++) {
        if (v_temp[i] >= v[n / 2 + 1]) {
            cout << v[n / 2] << endl;
        } else {
            cout << v[n / 2 + 1] << endl;
        }
    }
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

// const ll mod = 1000000007;
const ll mod = 998244353;

const int MAX_N = 2500020;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void create_table(int n) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= n;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[n] = pow_mod(fact[n],-1);
    for (int i = n;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= n;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    int n,m;
    cin >> n >> m;
    create_table(2500010);
    ll ans = combi(n+3*m-1,3*m);
    for (int i = 0;i < m;++i) {
        (ans -= n*combi(n-1+i-1,i)) %= mod;
    }
    for (int i = m+1;i <= min(n,3*m);++i) if ((3*m-i)%2 == 0) {
        (ans -= combi(n,i)*combi(n+(3*m-i)/2-1,(3*m-i)/2)) %= mod;
    }
    cout << (ans+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 58880
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

struct Dice
{
	vi d;
	static const int top = 0, frt = 1, rit = 2, lft = 3, bck = 4, btm = 5;
	Dice(){
		rep(i, 6) d.pb(i + 1);
	}
	Dice(vi d):d(d){}
	Dice(int _d[]){
		rep(i, 6) d.pb(_d[i]);
	}
	void spin(int f1, int f2, int f3, int f4){
		int tmp = d[f1];
		d[f1] = d[f2];
		d[f2] = d[f3];
		d[f3] = d[f4];
		d[f4] = tmp;
	}
	void spinN(){
		spin(top, frt, btm, bck);
	}
	void spinS(){
		spin(top, bck, btm, frt);
	}
	void spinE(){
		spin(top, lft, btm, rit);
	}
	void spinW(){
		spin(top, rit, btm, lft);
	}
	void spinCW(){
		spin(frt, rit, bck, lft);
	}
	void spinCCW(){
		spin(frt, lft, bck, rit);
	}

	void spin(char c){	
		if(c == 'N') spinN();
		else if(c == 'S') spinS();
		else if(c == 'E') spinE();
		else if(c == 'W') spinW();	
	}
	void spin(string s){
		for(char c : s){
			spin(c);
		}
	}
	void spin(int t, int f){
		rep(i, 4){
			if(d[top] == t) break;
			spinN();
		}
		rep(i, 4){
			if(d[top] == t) break;
			spinE();
		}
		rep(i, 4){
			if(d[frt] == f) break;
			spinCW();
		}
	}
	void spinTop(int f){
		if(f == frt) spinN();
		else if(f == btm) rep(i, 2) spinN();
		else if(f == bck) spinS();
		else if(f == lft) spinE();
		else if(f == rit) spinW();
	}

	void spinSmall(){
		Dice tmp(d);
		rep(i, 6){
			if(tmp[top] < d[i]) continue;
			Dice d2(d);
			d2.spinTop(i);
			rep(j, 4){
				if(d2 < tmp) tmp.d = d2.d;
				d2.spinCW();
			}
		}
		d = tmp.d;
	}

	int operator[] (int n) const{
		return d[n];
	}
	bool operator == (const Dice& dice) const{
		rep(i, 6){
			if(d[i] != dice[i]) return false;
		}
		return true;
	}
	bool operator < (const Dice& dice) const{
		rep(i, 6) {
			if(d[i] != dice[i]) return d[i] < dice[i];
		}
		return false;
	}
};


int main(){
	vi v(6);
	rep(i, 6) cin>>v[i];
	Dice dice(v);
	rep(i, 6) cin>>v[i];
	Dice dice2(v);
	dice.spinSmall();
	dice2.spinSmall();
	cout<<(dice==dice2?"Yes":"No")<<endl;
}

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

int main()
{
    int n, m, a, sum = 0;

    cin >> n >> m;

    for( int i = 0 ; i < m; i++ )
        cin >> a;

    while( n != 0 )
    {
        sum += n / 2;
        n /= 2;
    }

    cout << sum - m << endl;

    return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>

struct Point {double x, y;};

void koch(int n, struct Point a, struct Point b) {
    if(n==0) return;
    struct Point s, t, u;
    double th=M_PI*60.0/180.0;

    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

    koch(n-1, a, s);
    printf("%.8f %.8f\n",s.x, s.y);
    koch(n-1, s, u);
    printf("%.8f %.8f\n",u.x, u.y);
    koch(n-1, u, t);
    printf("%.8f %.8f\n",t.x, t.y);
    koch(n-1, t, b);

}

int main() {
    struct Point a, b;
    int n;

    scanf("%d",&n);
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;

    printf("%.8f %.8f\n",a.x,a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n",b.x,b.y);
    return 0;
}



Measured memory_bytes: 2112
using System;

namespace ABC111_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            for (int i = 111; i <= 999; i+=111)
            {
                if (n <= i)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 13140
AB = input().split()

A = int(AB[0])
B = int(AB[1])

## x * 0.08 = A
## x * 0.1 = B

if A % 0.08 > 0:
  AA = A//0.08 + 1
else:
  AA = A//0.08
if B % 0.1 > 0:
  BB = B//0.1 + 1
else:
  BB = B//0.1
  
if AA > BB:
  solution = int(AA)
else:
  solution = int(BB)
  
if int(solution * 0.08) != A or int(solution * 0.1) != B:
  print(-1)
else:
  print(solution)

Measured memory_bytes: 3064
n, m, c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    a = list(map(int,input().split()))
    t = 0
    for j in range(m):
        t += a[j]*b[j]
    if t + c > 0:
        ans += 1
print(ans)

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

int main()
{	
	int t, h, s;

	cin >> t >> h >> s;

	while (t >= 0 || h >= 0 || s >= 0) {
		int r = 7200 - t * 3600 - h * 60 - s;

		cout << setw(2) << setfill('0') << r / 3600 << ":" 
			<< setw(2) << setfill('0') << (r % 3600) / 60 << ":" 
			<< setw(2) << setfill('0') << r % 60 << endl
			<< setw(2) << setfill('0') << r / 1200 << ":" 
			<< setw(2) << setfill('0') << ((r * 3) % 3600) / 60 << ":" 
			<< setw(2) << setfill('0') << (r * 3) % 60 << endl;

		cin >> t >> h >> s;
	}

	return 0;
}



Measured memory_bytes: 3128
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calcDist :: [Int] -> [Int]
calcDist (x:[]) = []
calcDist (x:x2:xs) = (x2 - x) : calcDist (x2:xs) 

main = do
  [k, n] <- getIntList
  xs <- getIntList
  let fl = head xs + k - last xs
  let ds = calcDist xs
  let distMax =  maximum(fl:ds)
  print $ k - distMax

Measured memory_bytes: 29052
#include <iostream>

using namespace std;

int main()
{
  int N;

  cin >> N;

  int a[N];
  int ans=0;

  for(int i=0;i<N;i++)
  {
    cin >> a[i];
  }

  for(int j=0;j<N;j++)
  {
    ans += a[j]-1;
  }

  cout << ans;
}


Measured memory_bytes: 256
# cording:utf-8
# Nをn Tをt_limitとして整数で入力
n,t_limit = (int(x) for x in input().split())
# ci,tiのリストを作っておく
cost_list = list()
time_list = list()
# n回繰り返す
while n >= 1:
    ci,ti = (int(x) for x in input().split())
    if ti <= t_limit:   #tiがTを超えないとき
        cost_list.append(ci)    #cost_listにciを追加する
        time_list.append(ti)    #time_listにtiを追加する
        n = n - 1
    else:
        n = n - 1
if not time_list:   #time_listが空の時
    print('TLE')
else:
    print(min(cost_list))

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello
{

    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            ans += (int.Parse(s[1]) - int.Parse(s[0])) + 1;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
x,y=list(map(int, input().split()))

_dict={1:1,
       2:3,
       3:1,
       4:2,
       5:1,
       6:2,
       7:1,
       8:1,
       9:2,
       10:1,
       11:2,
       12:1,}

if _dict[x]==_dict[y]:
  print('Yes')
else:
  print('No')

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

int main(){
	ll a,b,c,d; cin>>a>>b>>c>>d;
	cout<<max({a*c,a*d,b*c,b*d})<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s;
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    sort(t.begin(), t.end());
    s.push_back(t);
  }
  sort(s.begin(), s.end());
  long long ans = 0;
  for (int i = 0; i < n;) {
    long long cnt = 1;
    string tmp = s[i];
    int j = i + 1;
    while (1) {
      if (j >= n || tmp != s[j]) {
        i = j;
        break;
      }
      ans += cnt;
      cnt++;
      j++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N, K; //N回目、Kをたす
  cin >> N >> K;
  
  int x = 1;
  
  for (int i = 0; i < N; i++)
  {
    
    if(x * 2 > x + K)
    {
      x = x + K; //Bの方が小さいときxにBを代入する
    }
    else
    {
      x = x * 2;
    }
  }
  
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
multiset<pair<int,int>> s1;
multiset<int> s2;
int ans;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        s1.insert(make_pair(x,y));
        
    }
    
    for(int i=1;i<=m;i++){
        while(s1.size() && (*s1.begin()).first == i){
            s2.insert((*s1.begin()).second);
            s1.erase(s1.begin());
        }
        if(s2.size()){
            auto it = s2.end();
            it--;
            ans+=*it;
            s2.erase(it);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-10;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

long long p[210000];
long long sum[210000];
int main(){
	int a;scanf("%d",&a);
	long long cur=0;
	for(int i=0;i<a;i++){
		scanf("%lld",p+i);
		cur+=p[i];
		sum[i]=cur;
	}
	std::sort(sum,sum+a+1);
	long long ret=0;
	int now=0;
	for(int i=0;i<a+1;i++){
		if(i<a&&sum[i]==sum[i+1]){
			now++;
			continue;
		}
		now++;
		ret+=(long long)now*(now-1)/2;
		now=0;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int n,m,i,j;
	char ch[64];
	string str;
	
	for(;;)
	{
		cin >> m >> n  ;
		if(n==0 && m==0)
			break;
		
		int ans[1024]={0};
		for(i=0;i<m;i++)
			ans[i]=i+1;
		
		j=0;
		int flag=m;
		for(i=1;i<=n;i++)
		{
			cin >> str ;
			
			sprintf(ch,"%d",i);
			if(flag>1)
			{
				if(i%3==0 && i%5==0)
				{
					if(str!="FizzBuzz")
					{
						ans[j]=0;
						flag--;
					}
				}
				else if(i%3==0)
				{
					if(str!="Fizz")
					{
						ans[j]=0;
						flag--;
					}
				}
				else if(i%5==0)
				{
					if(str!="Buzz")
					{
						ans[j]=0;
						flag--;
					}
				}
				else
				{
					if(str!=ch)
					{
						ans[j]=0;
						flag--;
					}
				}
				j++;
				int c;
				for(c=j;ans[c]==0;)
				{
					c++;
					if(c>m-1)
						c=0;
				}
				j=c;
			}
		}
		int las;
		for(i=m-1;ans[i]==0;--i){}
		
		las=i;
		
		for(i=0;i<m;i++)
		{
			if(ans[i]!=0)
			{
				cout << ans[i] ;
				if(i<las)
					cout << " " ;
			}
		}
		cout << endl;
	}
}

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

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int n, k, finans=0;
int a[N], f[N], mult[N], ans[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int32_t main()
{
	IOS;
	cin >> n >> k;
	for(int i = k; i >= 1; i--)
	{
		ans[i] = pow(k / i, n, MOD);
		for(int j = 2; i * j <= k; j++)
		{
			ans[i] -= ans[i*j];
			ans[i] += MOD;
			ans[i] %= MOD;
		}
		finans += i * ans[i];
		finans %= MOD;
	}
	cout << finans;
	return 0;
}

Measured memory_bytes: 4428
//#pragma warning (disable:4996)
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
using ll = long long;

int  main() {
	ll X, Y, Z;
	cin >> X >> Y >> Z;
	cout << floor((X - Z) / (Y + Z)) << endl;
}


Measured memory_bytes: 3756
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    V = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    ans = 0
    for v, c in zip(V, C):
        if v > c:
            ans += v - c

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  string s;
  cin >> s;
  ll n=s.size();
  vector<vector<ll>> dp(n+1,vector<ll>(4,0));
  dp[n][3] = 1;
  dp[n][2] = 0;
  dp[n][1] = 0;
  dp[n][0] = 0;
  for(int i=n-1;i>=0;i--){
    for(int j=3;j>=0;j--){
      if(j<3){
        ll m1,m2;
        if(s[i]=='?'){
          m1 = 3;
        }else{
          m1 = 1;
        }
        if(s[i]-'A'==j||s[i]=='?'){
          m2 = 1;
        }else{
          m2 = 0;
        }
        dp[i][j] = m1*dp[i+1][j] + dp[i+1][j+1]*m2;
      }else{
        ll m;
        if(s[i]=='?') m = 3;
        else m = 1;
        dp[i][j] = dp[i+1][j]*m;
      }
      dp[i][j] %= MOD;
    }
  }
  cout << dp[0][0]<<endl;
}


Measured memory_bytes: 7424
fun main(args: Array<String>) {
    val (N, T) = readLine()!!.split(" ").map{it.toInt()}
    val P = Array(N) {
        val a = readLine()!!.split(" ").map{it.toLong()}
        Pair(a[0].toInt(), a[1])
    }.sortedBy { it.first }

    val dp = Array(6010) { 0L }

    for (i in P.indices) {
        for (j in T - 1 downTo 0) {
            dp[j + P[i].first] = Math.max(dp[j + P[i].first], dp[j] + P[i].second)
        }
    }

    println(dp.max())
}


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

int main(){
  char s[29];
  int i;

  scanf("%s", s);

  for(i = 0;i <= 18;i++){
    if(i == 5 || i == 13) printf(" ");

    else printf("%c", s[i]);
  }
  return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
S=input()
countall=0
countb=0
for i in range(N):
    if S[i]=="a":
        if countall<A+B:
            print("Yes")
            countall=countall+1
        else:
            print("No")
    elif S[i]=="b":
        if (countall<A+B)and(countb<B):
            countall=countall+1
            countb=countb+1
            print("Yes")
        else:
            print("No")
    else:
        print("No")



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

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

using namespace std;

const int maxn = 300 + 15;

int n , m , a[maxn][maxn] , choose[maxn] , cnt[maxn];


int main( int argc , char * argv[] ){
	n = read() , m = read();
	for(int i = 1 ; i <= n ; ++ i)
		for(int j = 1 ; j <= m ; ++ j)
			a[i][j] = read();
	int ans = 1 << 30;
	for(int i = 1 ; i <= m ; ++ i) choose[i] = 1;
	for(int r = 1 ; r <= m ; ++ r){
		memset( cnt , 0 , sizeof( cnt ) );
		for(int i = 1 ; i <= n ; ++ i)
			for(int j = 1 ; j <= m ; ++ j)
				if( choose[ a[i][j] ] ){
					++ cnt[ a[i][j] ];
					break;
				}
		int ret = 0 , Mx = 1;
		for(int i = 1 ; i <= m ; ++ i){
			ret = max( ret , cnt[i] );
			if( cnt[i] > cnt[Mx] )
				Mx = i;
		}
		ans = min( ans , ret );
		choose[Mx] = 0;
	}
	printf( "%d\n" , ans );
	return 0;
}

Measured memory_bytes: 640
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll n;
string s;
cin>>n>>s;
if(n>=3200)
    cout<<s<<"\n";
else
    cout<<"red\n";

}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);

	for (int i = 0; i < N; i++)
	{
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		if (i % 2 == 0)
			sum += a.at(N - 1 - i);
		else
			sum -= a.at(N - 1 - i);
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

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

int main() {
  int N;
  cin >> N;
  
  cout << lcm(N,2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    // Your code here!
    double n;
    int i;
    
    while(cin>>n, n!=0){
        double li[1001]={};
        double sum=0.0;
        
        for(i=0; i<n; i++){
            cin>>li[i];
            sum+=li[i];
        }
        
        double mean=sum/n;
        double var=0;
        
        for(i=0; i<n; i++){
            var += (li[i]-mean)*(li[i]-mean)/n;
        }
        printf("%.8f\n",sqrt(var));
    }
    
    return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> tree(n);
  vector<p> tmp(n-1);
  map<p, int> mp;
  for (int i = 0; i < n-1; i++) {
    int from, to;
    cin >> from >> to;
    from--; to--;
    tree[from].push_back(to);
    tree[to].push_back(from);
    tmp[i] = {from, to};
  }

  queue<p> q;
  q.push({0, 0});
  vector<bool> visited(n);

  int k = 0;
  while (!q.empty()){
    int from = q.front().first;
    int color = q.front().second;
    int ncolor = 0;
    q.pop();
    visited[from] = true;
    for (int i = 0; i < int(tree[from].size()); i++) {
      int next = tree[from][i];
      if(visited[next]) continue;
      ncolor++;
      if(ncolor == color) ncolor++;
      k = max(k, ncolor);
      q.push({next, ncolor});
      mp[{from, next}] = ncolor;
      mp[{next, from}] = ncolor;
    }
  }

  cout << k << endl;
  for (int i = 0; i < n-1; i++) {
    cout << mp[{tmp[i].first, tmp[i].second}] << endl;
  }

}


Measured memory_bytes: 20224
S = input()

max_len = 0
for i in range(len(S)):
    for j in range(i, len(S)+1):
        tmp = S[i:j]
        for t in tmp:
            if t != 'A' and t != 'C' and t != 'G' and t != 'T':
                break
        else:
            if len(tmp) >= max_len:
                max_len = len(tmp)

print(max_len)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  reverse(vec.begin(),vec.end());
  int INF = 1e9+10;
  vector<int> dp(N,INF);
  vector<int>::iterator pos;
  int idx;
  for(int i=0; i<N; i++){
    pos = upper_bound(dp.begin(),dp.end(),vec.at(i));
    idx = distance(dp.begin(),pos);
    dp.at(idx) = vec.at(i);
  }
  
  int ans = 0;
  for(int i=0; i<N; i++){
    //cout << dp.at(i) << " ";
    if(dp.at(i) != INF){
      ans = i;
    }
  }
  cout << ans+1 << endl;    
}

Measured memory_bytes: 1024