akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#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()

string s = "MARCH";
ll c[5] = {0};

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

    rep(i, n) {
        string t;
        cin >> t;
        rep(j, 5) {
            if(t[0] == s[j]) c[j]++;
        }
    }

    ll ans = 0;
    for(int i = 0; i < 5; i++) {
        for(int j = i + 1; j < 5; j++) {
            for(int k = j + 1; k < 5; k++) {
                ans += (c[i] * c[j] * c[k]);
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import heapq
n = int(input())
a = list(map(int,input().split()))


left_seq = sorted(a[0:n])
right_seq =  sorted(a[2*n:3*n],reverse=True)
for i in range(n):
  right_seq[i]=-right_seq[i]

#print(left_seq)
#print(right_seq)

#left_sum[i]はa_0からa_(n+i-1)までaのうち、大きいものをn個集めたときの和
#right_sum[i]はa_(n+i)からa_(3n-1)までaのうち、小さいものをn個集めたときの和
left_sum = [0]*(n+1)
right_sum = [0]*(n+1)
left_sum[0] =  sum(left_seq) 
right_sum[n] =  sum(right_seq) 

#print(left_seq)
for i in range(n):
  if left_seq[0]<a[n+i]:
    left_sum[i+1] = left_sum[i] + a[n+i] - left_seq[0]
    heapq.heappop(left_seq)
    heapq.heappush(left_seq, a[n+i])
  else:
    left_sum[i+1] = left_sum[i]
  #print(left_seq,left_sum[i+1],i+1)
  
#print(right_seq)
for i in range(n)[::-1]:
  if right_seq[0]<-a[n+i]:
    right_sum[i] = right_sum[i+1] + (-a[n+i]) - right_seq[0]
    #print(right_seq)
    heapq.heappop(right_seq)
    heapq.heappush(right_seq, -a[n+i])
    #print(right_seq)
  else:
    right_sum[i] = right_sum[i+1]
  #print(right_seq,right_sum[i],i)

ans = -float("inf")
for i in range(n+1):
  #print(left_sum[i],right_sum[i],left_sum[i]+right_sum[i])
  ans = max(ans,left_sum[i]+right_sum[i])
print(ans)

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

using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int MAX_N = 2e6 + 1;
int mod = 1e9 + 7;
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin >> a;
    cout << a + a * a + a * a * a;
}

Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORS(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define SORT(v,n) sort(v,v+n)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,n,0)
#define si(n) scanf("%d",&n)
#define sc(s) scanf("%s",s)
#define EPS (1e-7)
#define INF (1e9)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N,A,B;
int main(void){

    cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

char IsEliminated(vector<char> t, vector<char> d, string s, int n){
  char now;
  int pos;
  pos = n;
  now = s[pos];
  for (int i=0; i<t.size(); i++) {
    if (t[i] == now) {
      if (d[i] == 'L') {
        pos--;
      }else{
        pos++;
      }
    }
    if (pos > (int)s.size()-1) {
      return 'R';
    }else if (pos < 0) {
      return 'L';
    }
    now = s[pos];
  }
  return '0';
}

int leftedge_elim(vector<char> t, vector<char> d, string s){
  int ok, ng, mid;
  ok = -1;
  ng = (int)s.size();
  while(abs(ok-ng) > 1){
    mid = (ok+ng)/2;
    char ans = IsEliminated(t, d, s, mid);
    if (ans == 'L')
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}

int rightedge_elim(vector<char> t, vector<char> d, string s){
  int ok, ng, mid;
  ok = (int)s.size();
  ng = -1;
  while(abs(ok-ng) > 1){
    mid = (ok+ng)/2;
    if (IsEliminated(t, d, s, mid) == 'R')
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}

int main(int argc, const char * argv[]) {
  int N, Q; cin >> N >> Q;
  string s; cin >> s;
  
  vector<char> t(Q), d(Q);
  for (int i=0; i<Q; i++) {
    cin >> t[i] >> d[i];
  }
  
  int lelim, relim;
  lelim = leftedge_elim(t, d, s);
  relim = rightedge_elim(t, d, s);

  cout << relim - lelim - 1 << endl;
  
  return 0;
}

Measured memory_bytes: 1924
n = gets.to_i
city = [0] + gets.chomp.split(" ").map(&:to_i) + [0]

# 連続
cost2 = [0]
# 一つ飛ばし
cost3 = []
i = 0
city.each_cons(2) do |c1,c2|
  cost2 << cost2[i] + (c1 - c2).abs
  cost3 << (city[i] - city[i+2]).abs if i < n
  i+=1
end

n.times do |i|

  cost = cost2[i]
  cost = 0 if cost.nil?

  cost += cost3[i]

  cost += cost2.last - cost2[i+2]
  c2 = 0 if c2.nil?

  puts cost
end

Measured memory_bytes: 16244
import kotlin.math.*
import java.util.*

data class Visit(var seq: Int = 0, var visited: Boolean = false)

fun main(args: Array<String>) {
  val (_n, _k) = readLine()!!.split(' ')
  val n = _n.toInt()
  val k = _k.toLong()
  val a = readLine()!!.split(' ').map(String::toInt)

  val v = Array(n) { Visit() }
  val r = mutableListOf<Int>()
  var cur = 1
  var seq = 0
  while (!v[cur - 1].visited) {
    val visit = v[cur - 1]
    visit.seq = seq++
    visit.visited = true
    r += cur
    cur = a[cur - 1]
  }
  val p = v[cur - 1]
  val len = r.size - p.seq
  if (k <= p.seq) {
    println(r[k.toInt()])
  } else {
    println(r[p.seq + ((k - p.seq) % len).toInt()])
  }
}


Measured memory_bytes: 75876
/******************************************
* AUTHOR : Anik Das *
* NICK : sadn1ck *
* INSTITUTION : IIEST Shibpur *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ios_base& scientific (ios_base& str);
	string s="";
	cin >> s;
	if(s[2]==s[3]&&s[4]==s[5]){
      cout << "Yes";
    }
     else{
       cout << "No";
     }
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	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 same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i] >> B[i];
		--A[i];
		--B[i];
	}

	vector<long long> ans;

	ans.push_back(1LL * N * (N - 1) / 2);

	UnionFind s(N);

	for (int i = M - 1; i > 0; --i) {
		if (s.same(A[i], B[i])) {
			ans.push_back(ans.back());
		}
		else {
			ans.push_back(ans.back() - 1LL * s.size(A[i]) * s.size(B[i]));
			s.unite(A[i], B[i]);
		}
	}

	reverse(ans.begin(), ans.end());
	for (auto x : ans) {
		cout << x << endl;
	}
}


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

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

constexpr int MOD = 1000*1000*1000 + 7;

class arcD {
public:
    void solve(istream& in, ostream& out) {
        long long n, m;
        in >> n >> m;
        vector<long long> x(n), y(m);
        long long sumx = 0, sumy = 0;
        for (int i = 0; i < n; ++i) {
            in >> x[i];
            sumx += i * x[i] - (n - (i + 1)) * x[i];
            sumx %= MOD;
            
        }
        for (int i = 0; i < m; ++i) {
            in >> y[i];
            sumy += i * y[i] - (m - (i + 1)) * y[i];
            sumy %= MOD;
        }
        
        out << sumx * sumy % MOD << "\n";
    }
};


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

	arcD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1792
open Batteries
open Printf
let () =
  let a,b,c = Scanf.scanf "%d %d %d " (fun a b c -> a,b,c) in

  let ans = 
    let (l, _) = List.sort compare [a;b;c] |>
                 List.split_nth 2 in
    List.fold_left (+) 0 l
  in

  Printf.printf "%d\n" ans


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

int main() {
  int n, m;
  vector<long long> a, b;
  cin >> n >> m;
  a.resize(n);
  for (auto &p : a) cin >> p;
  b.resize(m);
  for (auto &p : b) cin >> p;
  auto c = convolution(a, b);
  for (int i = 0; i < n + m - 1; ++i) cout << c[i] << " \n"[i == n + m - 2];
  return 0;
}


Measured memory_bytes: 27176
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;
 
int gcd(int a, int b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
 
int main(){

    string s;
    cin >> s;

    int x=s.size();
    int ans=1;
    rep(i, x){
        if((i+1)%2==1){
            if(s[i]== 'L'){
                ans=0;
                break;
            } 
        }
        else {
            if(s[i]=='R') {
                ans=0;
                break;
            }
        }
    }

    if(ans) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
if M == 0:
    if N == 1:
        print(0)
    else:
        print("1" + "0" * (N - 1))
    exit()

dic = {}
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        exit()
    n = dic.get(s)
    if n is not None and n != c:
        print(-1)
        exit()
    dic[s] = c

lst = [0] * N
for k, v in dic.items():
    lst[k - 1] = v

if len(lst) != 1 and lst[0] == 0:
    lst[0] = 1

print("".join(map(str, lst)))


Measured memory_bytes: 3064
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int power(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int n, m;
vector<vector<int> > es;

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return 0;
  }
  es = vector<vector<int> >(n);
  for (int i = 0; i < m; ++i) {
    int s, t;
    scanf("%d%d", &s, &t);
    --s, --t;
    es[s].pb(t), es[t].pb(s);
  }
  return 1;
}

void solve() {
  vector<bool> used(n, 0);

  vector<int> ans[2];
  for (int v = 0; v < n; ++v) {
    if (sz(es[v])) {
      ans[0].pb(v), ans[1].pb(es[v][0]);
      used[v] = used[es[v][0]] = 1;
      break;
    }
  }

  int pos[2] = {0, 0};
  while (1) {
    bool ch = 0;
    for (int iter = 0; !ch && iter < 2; ++iter) {
      int v = ans[iter].back();
      for (int &it = pos[iter]; it < sz(es[v]); ++it) {
        int u = es[v][it];
        if (used[u]) {
          continue;
        }
        ch = 1;
        ans[iter].pb(u);
        used[u] = 1;
        pos[iter] = 0;
        break;
      }
    }
    if (!ch) {
      break;
    }
  }

  vector<int> res = ans[0];
  reverse(res.begin(), res.end());
  for (int i = 0; i < sz(ans[1]); ++i) {
    res.pb(ans[1][i]);
  }
  printf("%d\n", sz(res));
  for (int i = 0; i < sz(res); ++i) {
    printf("%d%c", res[i] + 1, " \n"[i == sz(res) - 1]);
  }
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 7336
import sys
input = sys.stdin.readline

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

diff = []

for i in range(n):
    d = a[i] - b[i]
    diff.append(d)

diff.sort()
ans = 0

if diff[0] >= 0:
    print(0)
    exit()

if sum(diff) < 0:
    print(-1)
    exit()

i = 0
j = n-1
memo = [0] * n
while True:
    if i >= j:
        print(sum(memo))
        exit()
    if diff[i] >= 0:
        print(sum(memo))
        exit()

    if diff[j] > -diff[i]:
        diff[j] += diff[i]
        memo[j] = 1
        memo[i] = 1
        i += 1

    elif diff[j] < -diff[i]:
        diff[i] += diff[j]
        memo[i] = 1
        memo[j] = 1
        j -= 1

    else:
        memo[i] = 1
        memo[j] = 1
        i += 1
        j -= 1




Measured memory_bytes: 18756
def spin(a)
	[a[0]] + a[5..6] + a[1..4] + [a[7]]
end

def roll(a)
	a[1..3] + [a[0]] + a[5..7] + [a[4]]
end

while gets
	hash = {}
	a = $_.chomp.split.map{|x| hash[x] ||= hash.size}.sort
	count = 0
	a[1..-1].permutation{|x|
		x.unshift 0
		stack = [x]	
		reached = {}
		ok = true

		while y = stack.pop
			next if reached[y]
			reached[y] = 0
			if hash[y]
				ok = false
				break
			end
			stack << spin(y)
			stack << roll(y)
		end

		hash[x] = 0
		count += 1 if ok
	}
	p count
end

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

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

    int n;
    cin >> n;

    if(n == 0){
        cout << 0 << endl;
        return 0;
    }

    string s = "";
    while(n != 1){
        if(n % 2){
            s += "1";
            n--;
        }else{
            s += "0";
        }
        n /= -2;
    }
    s += "1";

    reverse(s.begin(), s.end());
    
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	static int mod = 1000000007;
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int k = Integer.parseInt(st.nextToken());
      st = new StringTokenizer(br.readLine());
      String s = st.nextToken();
      long ans = 0;
      long[] fact = new long[2000001];
      fact[0] = 1;
      for(int i = 1; i < 2000001; i++)
    	  fact[i] = (fact[i-1]*i)%mod;
      long[] pow25 = new long[1000001];
      long[] pow26 = new long[1000001];
      pow25[0] = 1;
      pow26[0] = 1;
      for(int i = 1; i < 1000001; i++) {
    	  pow25[i] = (pow25[i-1]*25)%mod;
    	  pow26[i] = (pow26[i-1]*26)%mod;
      }
      long inv = pow(fact[s.length()-1],mod-2);
      for(int i = 0; i <= k; i++) {
    	  ans = (ans + multiply(pow25[i],multiply(multiply(pow26[k-i],fact[s.length()+i-1]),multiply(inv,pow(fact[i],mod-2)))))%mod;
      }
      out.println(ans);
      out.close();
   }
   static long multiply(long a, long b) {
	   return (a*b)%mod;
   }
   static long pow(long l, int p) {
	   if(p == 0)
		   return 1;
	   if(p == 1 || l == 1)
		   return l;
	   long temp = pow(l, p/2);
	   long temp1 = (temp*temp)%mod;
	   if(p%2 == 1)
		   temp1 = (temp1*l)%mod;
	   return temp1;
   }
}


Measured memory_bytes: 69632
import itertools
n, m = [int(i) for i in input().split()]
a = []
num = 1
for i in range(1, n+1):
  a.append(i*2)
for i in range(1, m+1):
  a.append(num)
  num = num + 2
c = []
c = list(itertools.combinations(a, 2))
goukei = 0
for i in range(len(c)):
  if sum(c[i]) % 2 == 0:
    goukei += 1
print(goukei)


Measured memory_bytes: 4468
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<time.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define miin(a,b,c) min((a), min((b), (c)))
#define maax(a,b,c) max((a), max((b), (c)))

int n, x[111];

int main(){
    scanf("%d", &n);
    for(int i=0;i<n;i++)scanf("%d", &x[i]);
    int sum = 0, ans = 99999999;
    for(int i=1;i<=100;i++){
        for(int j=0; j<n; j++){
            sum += (x[j] - i) * (x[j] - i);
        }
        ans = min(ans, sum);
        sum = 0;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<vector<int>> DP(100, vector<int>(N));
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R') DP.at(0).at(i) = i + 1;
    if (S.at(i) == 'L') DP.at(0).at(i) = i - 1;
  }
  for (int i = 0; i + 1 < 100; i++) {
    for (int j = 0; j < N; j++) {
      DP.at(i + 1).at(j) = DP.at(i).at(DP.at(i).at(j));
    }
  }
  vector<int> ans(N);
  for (int i = 0; i < N; i++) {
    ans.at(DP.at(99).at(i))++;
  }
  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << ans.at(i);
  }
  cout << "\n";
}

Measured memory_bytes: 40312
#include<stdio.h>

int main(){
  int x,y,s,saidai,r;
  scanf("%d %d",&x,&y);
  if(x>=y){
    s=x%y;
    while(y>0){
      r=s%y;
      s=y;
      y=r;
    }
    saidai=s;
  }
  else if(x<=y){
    s=y%x;
    while(x>0){
      r=s%x;
      s=x;
      x=r;
    }
    saidai=s;
  }
  printf("%d\n",saidai);
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
 
  sort(L.begin(), L.end());
  int tmp = 0;
  for (int i = 0; i < N - 1; i++) {
    tmp += L.at(i);
  }
 
  cout << (L.back() < tmp ? "Yes" : "No");
}

Measured memory_bytes: 256
import collections
N = int(input())
a = list(map(int, input().split()))

c = collections.Counter(a)
v = list(c.values())
k = list(c.keys())

if 0 in c and c[0] == N:
    print('Yes')
elif len(c) == 2 and 0 in c and c[0] == N/3:
    print('Yes')
elif len(c) == 3 and v[0]==v[1]==v[2] and k[0]^k[1]^k[2] == 0:
    print('Yes')
else:
    print('No')


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
};
bool operator<(const Edge& a,const Edge& b){return a.weight<b.weight;}
bool operator>(const Edge& a,const Edge& b){return a.weight>b.weight;}

int solve(const vvi& g,vi& rs,int i)
{
	int n=g.size();
	if(i==n){
		if(rs.size()==1) return 0;
		int res=0;
		for(int u:rs){
			int x=INF;
			for(int v:rs) if(u!=v)
				x=min(x,g[u][v]);
			res+=x;
		}
		return res;
	}
	
	int res=solve(g,rs,i+1);
	bool ok=true;
	for(int r:rs)
		if(g[i][r]==0){
			ok=false;
			break;
		}
	if(ok){
		rs.push_back(i);
		res=max(res,solve(g,rs,i+1));
		rs.pop_back();
	}
	return res;
}

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		if(m==0){
			cout<<0<<endl;
			continue;
		}
		
		vvi g(n,vi(n));
		rep(i,m){
			int u,v,w; cin>>u>>v>>w; u--,v--;
			g[u][v]=g[v][u]=w;
		}
		
		vi rs;
		cout<<solve(g,rs,0)<<endl;
	}
}

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

int main () {
	
	int n=0, k=0, val=0, i=0, res=0, idx=0;
	vector <int> vi;

	cin >> n >> k;

	for (i=0; i<n; i++) {
		cin >> val;
		if (val == 1) idx = i+1;
		vi.push_back(val);
	}

	if (n <= k) cout << "1" << endl;
	else {
		
		if (idx <= k || (n-idx) < k) {
			n -= (k-1);
			res = n/(k-1);
	 
			if (n%(k-1) != 0) res++;
	 
			res++;
		}
	 
		else {
			res = 0;
			res += idx / (k-1);
			if (idx%(k-1) != 0) res++;
			res += (n-(idx+k-1)) / (k-1);
			if ((n-(idx+k-1)) % (k-1) != 0) res++;
		}
	

		cout << res << endl;	
	}

	

	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
using namespace std;
int N;
int A[100005];
int ind;
int a,b;
int main()
{
    cin>>N;
    for(int i=1;i<=N;i++)cin>>A[i];
    sort(A+1,A+1+N);
    ind=N;
    while(ind&&A[ind]!=A[ind-1])ind--;
    if(!ind){cout<<0;return 0;}
    a=A[ind];
    swap(A[ind],A[N]);
    swap(A[ind-1],A[N-1]);
    N-=2;
    sort(A+1,A+1+N);
    ind=N;
    while(ind&&A[ind]!=A[ind-1])ind--;
    if(!ind){cout<<0;return 0;}
    b=A[ind];
    cout<<1LL*a*b;
    return 0;
}


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

bool done[5000];
vector<int> wins[5000], sorted;
void dfs(int n)
{
  done[n] = true;
  for(auto m : wins[n])
    if(!done[m])
      dfs(m);
  sorted.push_back(n);
}


int N, M;
int main()
{
  cin >> N >> M;
  for(int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    wins[--a].push_back(--b);
  }
  for(int i = 0; i < N; i++)
    if(!done[i])
      dfs(i);

  bool plural = false;
  for(int i = N - 1; i >= 0; i--)
  {
    auto m = sorted[i];
    cout << m + 1 << endl;
    if(i == 0)
      break;

    bool b = true;
    for(auto n : wins[m])
      b &= n != sorted[i - 1];
    plural |= b;
  }
  cout << plural << endl;
}

Measured memory_bytes: 2152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll MOD=1000000007;
ll dp[101010];

ll modpow(ll a, ll n = MOD-2) {
	ll r = 1;
    a %= MOD;
	while(n) {
        r=r*((n%2)?a:1)%MOD;
        a=a*a%MOD;
        n>>=1;
    }

	return r;
}

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

	int N, K;
	cin >> N >> K;

	ll sum = 0;
	for(int i=K; i>=1; i--) {
		dp[i] = modpow(K/i,N);
		for (int j=i*2;j<=K;j+=i) dp[i] -= dp[j];
		sum += i*dp[i]%MOD;
	}
	cout << sum%MOD << endl;

    return 0;
}


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

int main()
{
	int N;
	ll M;
	cin >> N >> M;
	vector<pair<ll, ll>> ab;
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		ab.emplace_back(A, B);
	}
	sort(ab.begin(), ab.end());
	ll res = 0;
	for (int i = 0; i < N && M > 0; i++) {
		ll val = min(M, ab[i].second);
		res += val * ab[i].first;
		M -= val;
	}
	cout << res << endl;
	return 0;
}


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

# define x first
# define y second 
# define mp make_pair

# define pb push_back
# define vec vector
# define sz(a) int(a.size())

# define y1 kek_y1                  
# define left kek_left
# define right kek_right

using namespace std;

typedef long  long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int Sz = 1110111;
const int Mod = (int)1e9 + 7;
const int MX = (1<<30) - 1; // 1e9
const ll MXLL = (1ll<<62) - 1;        

inline void Read_rap() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}
void files (string name) {
	if (fopen ((name+".in").c_str(), "r")) {
		freopen ((name+".in").c_str(), "r", stdin);
		freopen ((name+".out").c_str(), "w", stdout);
	}
}                       
int n;

int x[Sz], y[Sz];
   
int r[Sz];

const int N = 1003;

ld dist[N][N];

int main()
{
	Read_rap();

	cin >> x[1] >> y[1];
	cin >> x[2] >> y[2];
	cin >> n;
	for (int i = 3; i <= n+2; i++) 
		cin >> x[i] >> y[i] >> r[i];
        	
    n += 2;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			ld D = sqrt ( (x[i] - x[j]) * 1ll * (x[i] - x[j]) + (y[i] - y[j]) * 1ll * (y[i] - y[j]));
			dist[i][j] = max ((ld)0.0, D - r[i] - r[j]);
		}
	}                    
	vec<bool> used(n + 1, 0);
	vec<ld> d(n + 1, 4e9);
	d[1] = 0;    
	for (int t = 0; t < n-1; t++) {
		int v = -1;
		for (int i = 1; i <= n; i++) {
			if (!used[i] && (v == -1 || d[v] > d[i]))
				v = i;
		}                   
		used[v] = 1;
		for (int to = 1; to <= n; to++) {
			//if (!used[to])
				d[to] = min (d[to], d[v] + dist[v][to]);
		}
	}
	cout << fixed <<setprecision (10) << d[2];


	return 0;
}











//Coded by Z....	
    

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

int main(void){
    int A, B;
    cin >> A >> B;
    int sum{0};
    if(A>B){
        sum+=A;
        A-=1;
    }
    else{
        sum+=B;
        B-=1;
    }
    if(A>B){
        sum+=A;
        A-=1;
    }
    else{
        sum+=B;
        B-=1;
    }
    cout << sum << endl;


}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,seq[100000],k,i;
  long long int sum,max;
  do{
    scanf("%d %d",&n,&k);
    if(!n&&!k) break;
    for(i=0;i<n;i++) scanf("%d",seq+i);
    for(i=0,sum=0;i<k;i++) sum+=seq[i];
    for(max=sum,i=k;i<n;i++){
      sum+=seq[i];
      sum-=seq[i-k];
      if(max<sum) max=sum;
    }
    printf("%lld\n",max);
  }while(1);
  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[101010];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i]--;
	}
	
	i64 ans = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == i){
			ans++;
			if(i>0 && a[i-1] == i-1){
				swap(a[i], a[i-1]);
			}
			else if(a[i+1] == i+1){
				swap(a[i], a[i+1]);
			}
			else if(i!=n-1){
				swap(a[i+1], a[i]);
			}
			else{
				swap(a[i-1], a[i]);
			}
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], K = l[1], S = l[2];
            var elseS = S == 1000000000 ? S - 1 : S + 1;


            var ans = new List<int>();

            for (var i = 1; i <= N; i++)
            {
                if (i <= K) ans.Add(S);
                else ans.Add(elseS);
            }

            Console.WriteLine(string.Join(" ", ans));
        }
    }
}


Measured memory_bytes: 25948
#include<stdio.h>
#include<stdlib.h>
struct node{
  int key;
  struct node *parent;
  struct node *right;
  struct node *left;
};
typedef struct node *Node;
Node T;
#define NIL NULL;
void Insert(int);
int Find(int);
void Preorder(Node);
void Inorder(Node);
int main()
{
  int n,i,key;
  char S[7];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",S);
    if(S[0]=='i'){
      scanf("%d",&key);
      Insert(key);
    }
    else if(S[0]=='f'){
      scanf("%d",&key);
      if(Find(key))printf("yes\n");
      else printf("no\n");
    }
    else{
      Inorder(T);
      printf("\n");
      Preorder(T);
      printf("\n");

    }
  }
  return 0;
}

void Insert(int key)
{
  Node y,x,z;
  y=NIL;
  x=T;
  z=malloc(sizeof(struct node));
  z->key=key;
  z->left=NIL;
  z->right=NIL;
  while(x!=NULL){
    y=x;
    if( z->key < x->key )x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NULL){
    T=z;
  }
 else if(z->key<y->key){
      y->left=z;
  }
  else{
    y->right=z;
  }
}

int Find(int key)
{
  Node TT;
  TT=T;
  while(TT!=NULL && TT->key!=key){
    if(key<TT->key)TT=TT->left;
    else TT=TT->right;
  }
  if(TT==NULL)return 0;
  else return 1;
}
void Preorder(Node T)
{
  printf(" %d",T->key);
  if(T->left!=NULL){
    Preorder(T->left);
  }
  if(T->right!=NULL){
    Preorder(T->right);
  }

}

void Inorder(Node T)
{
  if(T->left!=NULL && T->right!=NULL){
    Inorder(T->left);
    printf(" %d",T->key);
    Inorder(T->right);

  }
  if(T->left!=NULL && T->right==NULL){
   Inorder(T->left);
     printf(" %d",T->key);
  }

  if(T->right!=NULL && T->left==NULL){
  printf(" %d",T->key);
 Inorder(T->right);

  }
  if(T->left==NULL && T->right==NULL)printf(" %d",T->key);

}


Measured memory_bytes: 20460
#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>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;}
template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

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

int main() {
    int n,m;cin >> n >>m;
    vector<int> h(n);
    vector<bool> seen(n,true);
    for(int i=0;i<n;i++){
	cin >> h[i];
    }
    for(int i=0;i<m;i++){
	int a,b;cin >> a >> b;
	a--;b--;
	if(h[a]>=h[b]) seen[b] = false;
	if(h[a]<=h[b]) seen[a] = false;
    }
    int ans = 0;
    for(int i=0;i<n;i++){
	if(seen[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (x/d >= k) {
        x -= k*d;
    } else {
        k -= x/d;
        x -= (x/d)*d;
        if (k%2==1) x = abs(x-d);
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3640
def main():
    r, g, b, n = map(int, input().split())

    count = 0

    for i in range(3001):
        for j in range(3001):
            v = (i*r) + (j*g) 
            if n >= v and (n-v)%b == 0: 
                count += 1



    print(count)
                

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());

    ll A = 0, B = 0;
    rep(i, n) {
        if (i % 2 == 0)
            A += a[i];
        else
            B += a[i];
    }
    cout << A - B << "\n";
    return 0;
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for (int n = 0 ; n < N ; n++) {
			List<Integer> sides = new ArrayList<Integer>();
			sides.add(sc.nextInt());
			sides.add(sc.nextInt());
			sides.add(sc.nextInt());
			Collections.sort(sides);
			int a = sides.get(0), b = sides.get(1), c = sides.get(2);
			if (c*c == (a*a + b*b))
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23404
import sys
sys.setrecursionlimit(500000)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    A = list(mi())
    dic = {}
    l = []
    for a in A:
        if not a in dic:
            dic[a] = 0
        dic[a] += 1

    for k, v in dic.items():
        if v >= 2:
            l.append(k)
        if v >= 4:
            l.append(k)
        
    l.sort(reverse=True)

    if len(l) >= 2:
        print(l[0]*l[1])
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 98556
from collections import Counter
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for i in range(N):
	l = [A[i],B[i],C[i]]
	c = Counter(l)
	mode = c.most_common(1)[0][1]
	if mode == 1:
		ans += 2
	if mode == 2:
		ans += 1
print(ans)



	

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
vl a;
int main(){FAST;
cin>>n;
for(ll i=0;i<n;i++){
	ll x;cin>>x;
	a.pb(x);
}
sort(all(a));
ld X = (ld)a[n-1]/2;
ld dif = INF;
ll ans;
for(ll i=0;i<n-1;i++){
	ld tmp = fabs(a[i]-X);
	if(tmp<dif){
		ans = a[i];
		dif = tmp;
	}
}
cout<<a[n-1]<<' '<<ans;
return 0;
}

Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		int[] a = new int[3];
		a[0] = sc.nextInt(); a[1] = sc.nextInt(); a[2] = sc.nextInt();
		Arrays.sort(a);
		if(a[0]==a[1]&&a[1]==a[2]) {
			System.out.println(0);
		} else {
			int d =(2*a[2]-a[1]-a[0]); 
			if(d%2==0) {
				System.out.println(d/2);
			} else {
				int d2 = (2*(a[2]+1)-a[1]-a[0]-1);
				System.out.println(d2/2+1);
			}
		}
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	
	vector<vector<vector<vector<int>>>> ACGT(N+1,vector<vector<vector<int>>>(4,vector<vector<int>>(4,vector<int>(4,(0)))));
	ACGT.at(0).at(3).at(3).at(3)=1;
	for(int i=0;i<N;i++){
		for(int c1=0;c1<4;c1++){
			for(int c2=0;c2<4;c2++){
				for(int c3=0;c3<4;c3++){
					if(ACGT.at(i).at(c1).at(c2).at(c3)==0)	continue;
					
					for(int c4=0;c4<4;c4++){
						if(c2==0 && c3==2 && c4==1)	continue;
						if(c2==0 && c3==1 && c4==2)	continue;
						if(c2==2 && c3==0 && c4==1)	continue;
						if(c1==0 && c2==2 && c4==1)	continue;
						if(c1==0 && c3==2 && c4==1)	continue;
						
						ACGT.at(i+1).at(c2).at(c3).at(c4)+=ACGT.at(i).at(c1).at(c2).at(c3);
						ACGT.at(i+1).at(c2).at(c3).at(c4)%=MOD;
					}
				}
			}
		}
	}
	
	long long ans=0;
	for(int c1=0;c1<4;c1++){
		for(int c2=0;c2<4;c2++){
			for(int c3=0;c3<4;c3++){
				ans+=ACGT.at(N).at(c1).at(c2).at(c3);
				ans%=MOD;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int ans = 0;
		ans = N * A;
		if(ans <= B){
			System.out.println(ans);
		}
		else{
			System.out.println(B);
		}
		stdIn.close();
	}
}

Measured memory_bytes: 35720
path,time = map(int,input().split())
lists = []
for i in range(path):
    lists.append(list(map(int,input().split())))

lists2 = []
for i in range(path):
    if lists[i][1] <= time:
        lists2.append(lists[i])

if not lists2:
    print("TLE")
else:
    lists2.sort(key=lambda x:x[0])
    print(lists2[0][0])

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var s string

	ss := map[string]int{
		"SUN": 7,
		"MON": 6,
		"TUE": 5,
		"WED": 4,
		"THU": 3,
		"FRI": 2,
		"SAT": 1,
	}

	fmt.Scan(&s)
	fmt.Println(ss[s])
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 100

//スタックの定義
typedef  struct stack{
  int size;
  int count;
  char data[SIZE];
  char *top;
}stack;

//スタックの初期化
void initialize_stack(stack *stk){
  stk->count = 0;
  stk->size = SIZE;
  stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk,char elem){
  if(stk->count >= stk->size){
    exit(1);
  }
  else{
    stk->top--;
    *(stk->top) = elem;
    stk->count++;
  }
}

//データの取り出し
char pop(stack *stk){
  char latest;
  latest = *(stk->top);
  stk->top++;
  stk->count--;
  return latest;
}
    
int main(void){
  char string[11];
  stack stk;
  int i;
  initialize_stack(&stk);//stkの初期化
  scanf("%s",string);
  //Bでなかったらその文字をstkに入れ、Bだったらstkから1文字取る
  for(i=0;i<strlen(string);i++){
    if(string[i] != 'B'){
      push(&stk, string[i]);
    }
    else if(stk.count > 0){
      pop(&stk);
    }
  }
  //stk内の文字列の出力
  for(i=0;i<stk.count;i++){
    printf("%c",stk.data[SIZE-1-i]);
  }
  return 0;
}

Measured memory_bytes: 1664
x?(a,b)=if x then a else b
readInt :: String -> Int
readInt = read

main = do
  [n,k] <- map readInt.words<$>getLine
  s <- getLine
  putStrLn $ solve k s

solve :: Int -> String -> String
solve k = beam k 1 []

beam :: Int -> Int -> String -> String -> String
beam k i p (x:xs) = (k==i)?(ans,next) where
  ans = p ++ [low x] ++ xs
  next = beam k (i+1) p' xs
  p' = p ++ [x]

low x
 | x == 'A' = 'a'
 | x == 'B' = 'b'
 | x == 'C' = 'c'


Measured memory_bytes: 508
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

#define fst first
#define snd second

using namespace std;

using ll = long long;
using PII = pair<int, int>;

struct stick{
	int l_d, r_d;
	int par, l, r;
};

stick s[101];

ll gcd(ll x, ll y){
	if(y == 0) return x;
	return gcd(y, x%y);
}

ll dfs(ll st){
	if(st == 0) return 1;
	ll l_w = dfs(s[st].l);
	ll r_w = dfs(s[st].r);
	ll res = (l_w*r_w*s[st].l_d*s[st].r_d)/gcd(l_w*s[st].l_d, r_w*s[st].r_d);
	res = res/s[st].l_d + res/s[st].r_d;
	return res;
}

int main(void){
	int n;

	while(cin >> n && n){
		memset(s, 0, sizeof s);
		FOR(i, 1, n+1){
			s[i].par = i;
		}
		FOR(i, 1, n+1){
			int a;
			cin >> s[i].l_d >> s[i].r_d >> s[i].l >> s[i].r;
			a = gcd(s[i].l_d, s[i].r_d);
			s[i].l_d /= a;
			s[i].r_d /= a;
			s[s[i].l].par = i;
			s[s[i].r].par = i;
		}
		int start = 1;
		while(s[start].par != start){
			start = s[start].par;
		}
		cout << dfs(start) << endl;
	}
}

Measured memory_bytes: 2940
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=sum(b)
for i in range(n):
  if a[i]<=b[i]:
    b[i]-=a[i]
    a[i]=0
    if a[i+1]<=b[i]:
      b[i]-=a[i+1]
      a[i+1]=0
    else:
      a[i+1]-=b[i]
      b[i]=0
  else:
    a[i]-=a[i]
    b[i]=0
print(ans-sum(b))

Measured memory_bytes: 24100
from functools import reduce
from math import log2
from operator import mul


def end_of_loop():
    raise StopIteration


def main():
    N, K = map(int, input().split())
    MAX_SHIFT = int(log2(K) + 1)
    print(sum(reduce(mul, (0.5
                           if i << j < K
                           else end_of_loop()
                           for j in range(MAX_SHIFT)), 1)
              for i in range(1, N + 1)) / N)
    return


main()


Measured memory_bytes: 3572
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {
    n:u32,
    y:u32
  }
  let mut v: Vec<(u32, u32, u32)> = vec![];
  for i in 0..n + 1 {
    for j in 0..n + 1 {
      if i + j > n {
        continue;
      }
      let k = n - i - j;
      let price = i * 1000 + j * 5000 + k * 10000;
      if price == y {
        v.push((k, j, i))
      }
    }
  }
  if v.len() > 0 {
    println!("{} {} {}", v[0].0, v[0].1, v[0].2);
  } else {
    println!("-1 -1 -1");
  }
}


Measured memory_bytes: 2196
list = []
timelist=[]
min_time = 10
for i in range(5):
    list.append(int(input()))
for i in list:
    if i%10 == 0:
        timelist.append(i)
    else:
        timelist.append((10-(i%10))+i)
        if i%10 < min_time:
            min_time = i%10
print(sum(timelist)-10+min_time)

Measured memory_bytes: 3060
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: String -> [(Int, Int)]
solve s = assocs (iter (listArray (0,25) (replicate 26 0)) s) where
    iter ar [] = ar
    iter ar (c:cs) = iter (incr ar c) cs
    incr ar c = case maybeIdx c of
        Just x  -> ar // [(x, ar ! x + 1)]
        Nothing -> ar
    maybeIdx c = case generalCategory c of
        LowercaseLetter -> Just (ord c - ord 'a')  
        UppercaseLetter -> Just (ord c - ord 'A')
        _ -> Nothing
                
main :: IO() 
main = do
    l   <- getContents
    mapM_ putStrLn $ map (\(i, e)-> chr (i+ord 'a'):" : "++show e) (solve l)



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

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

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

int a[500010]={0};

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

	int n=s.size();

	for (int i = 0; i < n; i++){
		if(s[i]=='<'){
			a[i+1]=max(a[i+1],a[i]+1);
		}
	}

	for (int i = n-1; i >= 0 ; i--){
		if(s[i]=='>'){
			a[i]=max(a[i],a[i+1]+1);
		}
	}

	ll sum=0;
	for (int i = 0; i < n+1; i++){
		sum+=a[i];
	}
	cout<<sum<<endl;

	
	return 0;
}
	


Measured memory_bytes: 2820
#include<stdio.h>
#define MAX 100
#define INFTY 1<<21
#define WHITE 0
#define GRAY  1
#define BLACK 2

int n , M[MAX][MAX];

int prim() {
  int i,v,u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(i = 0;i<n;i++) {
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1) {
    minv = INFTY;
    u = -1;
    for(i = 0;i<n;i++) {
      if(minv > d[i] && color[i] != BLACK) {
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0;v<n;v++) {
      if(color[v] != BLACK && M[u][v] != INFTY) {
      if(d[v] > M[u][v]) {
        d[v] = M[u][v];
        p[v] = u;
        color[v] = GRAY;
      }
      }
    }
  }
  int sum = 0;
  for(i = 0;i<n;i++) {
    if(p[i] != -1) sum += M[i][p[i]];
  }

  return sum;
}

int main() {
  int i,j,e;
  scanf("%d\n", &n);

  for(i = 0;i<n;i++) {
    for(j=0;j<n;j++) {
      scanf("%d\n", &e);
      M[i][j] = (e == -1) ? INFTY:e;
    }
  }

  printf("%d\n", prim());

  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
 
int main(void) {
  
  int N,M,X,A[200];
  
  scanf("%d %d %d\n",&N,&M,&X);

/*  if(N<0 || N>100 || M<0 || M>100 || X<0 || X>N-1){
    return 0;
  }*/

  for(int i=0;i<200;i++){
    A[i]=0;
  }
  
  for(int i=0; i<M; i++){
    int data = 0;

    if(scanf("%d", &data)==1){
      A[data] = 1;
    }
  }
  
  int left=0;
  int right=0;
  for(int i=0;i<X;i++){
    if(A[i]==1){
      left++;
    }
  }
  
  int all_right=0;
  for(int i=X;i<200;i++){
    if(A[i]==1){
      right++;
    }
  }
  
  if(left<right){
    printf("%d",left);
  }else{
    printf("%d",right);
  }
 
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m=sc.nextInt();
		int d=m-n;
		int ans=0;
		for(int i=1;i<=d;i++) {
			ans+=i;
		}
		System.out.println(ans-m);
	}
}

Measured memory_bytes: 25300