akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <numeric>
#define ll long long
#define MODD 998244353
#define MAXA 1000000
using namespace std;


int main() {
    string S;
    cin>>S;
    int N=S.size();
    
    vector<int> counts;
    for(int i=0;i<N;) {
        int j=i;
        while(j+1<N && S[j+1]==S[i])
            j++;
        counts.push_back(j-i+1);
        i=j+1;
    }
    

    
    
    long long K;
    cin>>K;
    
    if (counts.size() == 1) {
        cout << (long long)(N*K)/2 << endl;
        return 0;
    }
    
    vector<pair<long long,long long>> counts_counts;
    
    
    if (K == 1) {
        for(int x : counts) {
            counts_counts.push_back({x,1});
        }
    } else if (S.back() == S.front()) {
        for(int i=1;i<counts.size()-1;i++) {
            counts_counts.push_back({counts[i],K});
        }
        counts_counts.push_back({counts.front(),1});
        counts_counts.push_back({counts.back(),1});
        counts_counts.push_back({counts.back()+counts.front(),K-1});
    } else {
        for(int i=0;i<counts.size();i++) {
            counts_counts.push_back({counts[i],K});
        }
    }
    
    ll ans = 0;
    for(auto x : counts_counts) {
        ans += x.second * (x.first/2);
    }
    cout << ans << endl;
    
    
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

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

		int n = Integer.parseInt(scanner.next());
		String s = scanner.next();

		int red = 0;

		for(int i = 0; i < n; i++){
			char c = s.charAt(i);
			if(c == 'R')
				red++;
		}

		int blue = n - red;

		if((red - blue) > 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


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

int main() {
  int N;
  cin >> N;
  
  string tmp;
  priority_queue<string> S;
  
  for (int i; i < N; i++) {
    cin >> tmp;
    S.push(tmp);
  }
  
  string tmp1 = S.top();
  int cnt = 1; 
  
  while(!S.empty()) {
    S.pop();
    if(S.top() != tmp1) {
      cnt++;
    }
    tmp1 = S.top();
  }
  cout << cnt << endl; 
}

Measured memory_bytes: 11668
#include <stdio.h>

int main(void){
	int a,b,suma,sumb,n,i;
	while(1){
		scanf("%d",&n);
		if(n==0)
			break;
		suma=0;sumb=0;
		for(i=0;i<n;i++){
			scanf("%d%d",&a,&b);
			if(a>b)
				suma+=a+b;
			if(a<b)
				sumb+=a+b;
			if(a==b){
				suma+=a;
				sumb+=b;
			}
		}
		printf("%d %d\n",suma,sumb);
	}
	return 0;
}

Measured memory_bytes: 600
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val Array(a, b, h, m) = readDoubles

  val radM = 360d * m / 60d
  val radH = radM / 12d + 360d * h / 12d

  val cc = pow(a, 2) + pow(b, 2) - 2d * a * b * cos(toRadians(radM - radH))
  println(String.format("%.10f", pow(cc, 0.5)))
}

trait StdInHelper {
  def readInts = readLine.split(" ").map(_.toInt)
  def readLongs = readLine.split(" ").map(_.toLong)
  def readDoubles = readLine.split(" ").map(_.toDouble)
}


Measured memory_bytes: 54928
from collections import deque
from copy import deepcopy


# detection of a cycle
def detect_cycle(N, repn):
    color = ['WHITE'] * (N + 1)
    unfinished_vertex = set([i for i in range(1, N + 1)])
    cycle = []
    Repn = deepcopy(repn)

    def dfs(u0):
        deq = deque([u0])
        color[u0] = 'GRAY'

        while deq != deque([]) and cycle == []:
            u = deq[-1]
            if len(Repn[u]) != 0:
                v = Repn[u].popleft()
                if color[v] == 'WHITE':
                    color[v] = 'GRAY'
                    deq.append(v)
                elif color[v] == 'GRAY':
                    cycle.append(v)
            else:
                deq.pop()
                color[u] = 'BLACK'
                unfinished_vertex.remove(u)

        return deq

    while cycle == [] and unfinished_vertex != set([]):
        u = unfinished_vertex.pop()
        unfinished_vertex.add(u)
        deq = dfs(u)
        #print('deq = {}, cycle = {}'.format(deq, cycle))
    #print('deq = {}'.format(deq))
    if cycle != []:
        v = cycle.pop()
        while True:
            u = deq.pop()
            cycle.append(u)
            if u == v:
                break
        cycle.reverse()
        return cycle # cycle = [v -> ... -> u (-> v)]
    else:
        return []

# one-step minimization of a cycle
def minimize_cycle(cycle, repn):
    length = len(cycle)
    cycle_idx = {u : i for i, u in enumerate(cycle)}
    minimized = False

    for i, u in enumerate(cycle):
        if minimized == True:
            break
        else:
            for v in repn[u]:
                if v in cycle_idx.keys():
                    j = cycle_idx[v]
                    if i + 1 == j:
                        continue
                    elif i == length - 1 and j == 0:
                        continue
                    elif i < j:
                        reduced_cycle = cycle[:(i + 1)] + cycle[j:]
                        minimized = True
                        break
                    else:
                        reduced_cycle = cycle[j:(i + 1)]
                        minimized = True
                        break

    if minimized == True:
        return reduced_cycle, minimized
    else:
        return cycle, minimized


def main():
    N, M = map(int, input().split())
    repn = [deque([]) for i in range(N + 1)]
    for _ in range(M):
        a, b = map(int, input().split())
        repn[a].append(b)

    cycle = detect_cycle(N, repn)
    #print('cycle detected: {}'.format(cycle))
    if cycle == []:
        print(-1)
        exit()

    minimized = True
    while minimized == True:
        cycle, minimized = minimize_cycle(cycle, repn)
        #print('cycle minimized: {}, {}'.format(minimized, cycle))

    print(len(cycle))
    for u in cycle:
        print(u)


if __name__ == '__main__':
    main()


Measured memory_bytes: 58200
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
sx,sy,tx,ty = gi
stx1 = tx-sx
stx2 = tx-sx+1
sty1 = ty-sy
sty2 = ty-sy+1
str = []
rep stx1 do |i|
str << 'R'
end

rep sty1 do |i|
str << 'U'
end

rep stx1 do |i|
str << 'L'
end

rep sty1 do |i|
str << 'D'
end

str << 'D'

rep stx2 do |i|
str << 'R'
end

rep sty2 do |i|
str << 'U'
end

str << 'L'
str << 'U'

rep stx2 do |i|
str << 'L'
end

rep sty2 do |i|
str << 'D'
end

str << 'R'

puts str.join


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;



signed main(){
	int L;
	cin >> L;
	double d = L / 3.0;
	printf("%.20lf\n",d*d*d);
}

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

using namespace std;

typedef long long ll;

ll mn = 4e18;
ll mn1 = 4e18, mn2 = 4e18;
ll n, m, k;
ll a[100005], b[100005], c[100005], d[100005], e[100005];

int main()
{
    cin>>n>>m>>k;
    for(ll i = 1; i <= n; i++) cin>>a[i], mn1 = min(mn1, a[i]);
    for(ll i = 1; i <= m; i++) cin>>b[i], mn2 = min(mn2, b[i]);
    for(ll i = 0; i < k; i++)
    {
        cin>>c[i]>>d[i]>>e[i];
        mn = min(mn, a[c[i]] + b[d[i]] - e[i]);
    }
    cout<<min(mn, mn1 + mn2)<<endl;
    return 0;
}


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

int main(){
  long long int N;
  cin >> N;
  //int x;
  //x = N/2;
  long long int so = 0;
  for(long long int x = sqrt(N); x>=1; x--){
    if(N % x == 0){
      so = x;
      break;
    }
  }
  long long int sum = N / so + so -2;
  cout << sum << endl;
  return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n, k, s; cin >> n >> k >> s;

    V<int> ans;
    for(int i = 0; i < n - k; i++){
        if(s != 1e9) ans.push_back(s + 1);
        else ans.push_back(s - 1);
    }
    while(0 < k){
        ans.push_back(s);
        k--;
    }

    sort(ALL(ans));
    for(int a : ans){
        cout << a << endl;
    }

    return 0;
}


Measured memory_bytes: 3864
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;
    std::sort(a.begin(), a.end());
    std::cout << a[n / 2] - a[n / 2 - 1] << std::endl;

    return 0;
}


Measured memory_bytes: 640
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


int main() {
	int X;
	cin >> X;
	if (X == 7 || X == 5 || X == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    vector<vector<int>> dist = vvec(H, W, INF);
    dist[0][0] = 0;
    queue<pair<int, int>> q;
    q.emplace(0, 0);
    while (!q.empty()) {
        auto v = q.front(); q.pop();
        for (int d = 0; d < 2; ++d) {
            int nx = v.first + dx[d], ny = v.second + dy[d];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (dist[nx][ny] <= dist[v.first][v.second] + (S[v.first][v.second] != S[nx][ny])) continue;
            dist[nx][ny] = dist[v.first][v.second] + (S[v.first][v.second] != S[nx][ny]);
            q.emplace(nx, ny);
        }
    }
    if (S[0][0] == '#' && S[H - 1][W - 1] == '#') {
        write(dist[H - 1][W - 1] / 2 + 1);
    }
    else {
        write((dist[H - 1][W - 1] + 1) / 2);
    }
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  vector<int> a(5);
  int k;
  for (int i = 0; i < 5; i++) cin >> a[i];
  cin >> k;
  bool res = a[4] - a[0] <= k;
  cout << (res ? "Yay!" : ":(") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,n,x,a=0;
    cin >> n >> x;
    int l[n],d[n+1]={0};
    for(i=0;i<n;i++){
        cin >> l[i];
    }
    for(i=0;i<n;i++){
        d[i+1] = d[i]+l[i];

    }
    for(i=0;i<n+1;i++){
        if(d[i]<=x){
            a++;
        }

    }
    cout << a ;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>

int main(void){
	std::string s;
	std::cin >>s;
	s[3]='8';
	std::cout<<s<<std::endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
using static Read;

class Program
{
    public static void Main()
    {
        var n = IntArray();
        Sort(n);
        if(n[0] == 5 && n[1] == 5 && n[2] == 7)
        {
            WriteLine("YES");
        }
        else
        {
            WriteLine("NO");
        }
    }
}

static class Read
{
    static Queue<string> queue = new Queue<string>();
    static void Enqueue()
    {
        ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a));
    }
    public static int Int()
    {
        if(queue.Count == 0)
            Enqueue();
        return int.Parse(queue.Dequeue());
    }
    public static long Long()
    {
        if(queue.Count == 0)
            Enqueue();
        return long.Parse(queue.Dequeue());
    }
    public static double Double()
    {
        if(queue.Count == 0)
            Enqueue();
        return double.Parse(queue.Dequeue());
    }
    public static string String()
    {
        if(queue.Count == 0)
            Enqueue();
        return queue.Dequeue();
    }
    public static int[] IntArray()
    {
        return ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static long[] LongArray()
    {
        return ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
    }
    public static double[] DoubleArray()
    {
        return ReadLine().Split(' ').Select(a => double.Parse(a)).ToArray();
    }
    public static string[] StringArray()
    {
        return ReadLine().Split(' ');
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <queue>

int main() {
    int N, Q;
    std::cin >> N >> Q;
    std::vector<std::priority_queue<int>> v(N);
    for (int q = 0; q < Q; ++q) {
        int t;
        std::cin >> t;
        if (t == 0) {
            int i, x;
            std::cin >> i >> x;
            v[i].push(x);
        } else if (t == 1) {
            int i;
            std::cin >> i;
            if (!v[i].empty()) std::cout << v[i].top() << std::endl;
        } else {
            int i;
            std::cin >> i;
            if (!v[i].empty()) v[i].pop();
        }
    }
    return 0;
}



Measured memory_bytes: 3992
#Combinationクラス
class Combination:

    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [pow(self.fact[i] ,MOD - 2 ,MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        '''k!を求める'''
        return self.fact[k]

    def inverse_factorial(self, k):
        '''k!の逆元を求める'''
        return self.inv_fact[k]

    def combination(self, k, r):
        '''kCrを求める'''
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


h, w, a, b = map(int,input().split())
MOD = 10**9 + 7
comb = Combination(h+w, MOD)
ans = 0
for i in range(0, h-a):
    ans += comb.combination((b-1)+i,i) * comb.combination((w-b-1)+(h-i-1), w-b-1)
    ans = ans % MOD
print(ans)

Measured memory_bytes: 18924
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    int min = INT_MAX;
    for (int i = 0; i < n; i++)
    {
        int ci, ti;
        cin >> ci >> ti;

        if (ti <= t)
        {
            if (ci < min)
                min = ci;
        }
    }
    min == INT_MAX ? cout << "TLE" : cout << min;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};


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

    cout << N << ":";
    for(int i=2; i*i<= N; i++) {
        while (N % i == 0) {
            N /= i;
            cout << ' ' << i;
        }
    }

    if(N!=1){
        cout << ' ' << N;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(int argc, char const *argv[]) {
  int A, B;
  cin >> A >> B;
  if (A + B < 24) {
    cout << A + B << endl;
  } else {
    cout << A + B - 24 << endl;
  }
  return 0;
}


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

__int128 N;
__int128 f(__int128 x){
	return (N+2*x-1) / (2*x);
}

__int128 s1(long long N){
	__int128 sum = 0;
	long long T= sqrt(N/2) - 1e-10;
	T++;
	__int128 now = N/2;
	for(long long i = 1 ; i <= T ; i++){
		sum += N/2 - now;
		sum += N/2 - now;
		now = f(i);
	}
	sum += (__int128)(N/2-T) * (N/2-T);
	
	return sum;
}

int main(){
	long long N_;
	while( cin >> N_ && N_ ){
		N = N_;
		__int128 sum = s1(N);
		__int128 result = 4*(2*N)+2*N*N-8*sum;
		string s;
		while( result > 0 ){
			s = string(1,'0'+(int)(result%10)) + s;
			result /= 10;
		}
		cout << s << endl;
		
	}
}

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

#define pb push_back
const int N = 2e5L + 11;
using ll = long long;
ll a[N], sum[N];

ll k;
ll ans = 0;
void solve(int l, int r) {
	if(l + 1 == r) return;
	int m = (l + r) / 2;
	vector <pair <ll, int>> v;
	for(int i = l; i < m; i ++)
		v.pb({sum[i] - i * k, 0});
	for(int i = m; i < r; i ++)
		v.pb({sum[i] - i * k, 1});
	sort(v.begin(), v.end());

	int acc = 0;
	for(auto i : v)
		if(i.second == 1)
			ans += acc;
		else
			acc ++;
	solve(l, m);
	solve(m, r);
}

int main() {
	ios :: sync_with_stdio(0);
	int n; cin >> n;
	cin >> k;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = 1; i <= n; i ++)
		sum[i] = sum[i - 1] + a[i];
	solve(0, n + 1);
	cout << ans << '\n';
}

Measured memory_bytes: 10956
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int p_MAX = 55555;
vector<int> prime;
int calc_prime()
{
  bool notPrime[p_MAX];
  int n = sqrt(p_MAX)+1;
  notPrime[0]=1;
  notPrime[1]=1;
  for(int i=0;i<=n;i++){
    if(notPrime[i])
      continue;
    int m = p_MAX/i;
    for(int j=2;j<=m;j++)
      notPrime[j*i]=1;
  }
  prime.clear();
  for(int i=0;i<p_MAX;i++)
    if(!notPrime[i])
      prime.push_back(i);
  return 0;
}
int main()
{
  int n,i;
  cin >> n;
  calc_prime();
  for(i=0;i<prime.size()&&n>0;i++)
    if(prime[i]%5==1){
      cout << prime[i] << " ";
      n--;
    }
  return 0;
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  ll N, K;
  cin >> N >> K;

  ll a = N%K;
  ll b = K-a;
  cout << min({a,b}) << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


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

int main() {
  int count, A, B;
  count = 0;
  cin >> A >> B;
  
  for (int i = A ; i < B + 1 ; i++ ){
    int X, Y, a, b, d, e;
    X = i / 1000;
    Y = i % 100;
    a = X / 10;
    b = X % 10;
    d = Y / 10;
    e = Y % 10;
    
    if ( a == e && b == d) {
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    REP(i, N) cin >> x[i];
    vector<int> y(M);
    REP(i, M) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    int l = max(X, x[x.size() - 1]);
    int r = min(Y, y[0]);

    if (l < r) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }

    return 0;
}


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

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

    string S;
    cin >> S;

    if(S.size() == 3){
        reverse(S.begin(), S.end());
    }

    cout << S << "\n";

    return 0;
}

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

ll calc(ll a,ll f,ll b){
    ll d = a*f-b;
    return max(0ll,(d+f-1)/f);
}


int main(){
	// おまじない
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N,K;
	// 出入力
	cin>>N>>K;
    ll A[N];
    ll a_sum=0;
    ll F[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
        a_sum+=A[i];
    }
    // cout << a_sum<<"\n";
    if(a_sum<=K){
        cout<<0<<"\n";
        return 0;
    }
	for(int i=0;i<N;i++){
        cin>>F[i];
    }
    sort(A,A+N);
    sort(F,F+N,greater<ll>());
    vector<pair<ll,ll>> af;
    ll min_ans = 0;
    ll max_ans = A[N-1]*F[0];
    ll border;
    ll tmp_ans;
    ll tmp_n;
    ll iter = 0;
    ll n_each[N];
    ll ans_n_each[N];
    ll s=0;


    while(min_ans+1 != max_ans){
        iter +=1;
        tmp_ans = (max_ans + min_ans)/2;
        tmp_n = 0;
        for(int i=0;i<N;i++){
            n_each[i]=calc(A[i],F[i],tmp_ans);
            tmp_n+=n_each[i];
        }
        if(tmp_n <= K){//可能な場合
            max_ans= tmp_ans;
            memcpy(ans_n_each, n_each, sizeof(n_each));
        }else{//不可能な場合
            min_ans = tmp_ans;
        }
        // cout<<min_ans<<" "<<max_ans<<"\n";
    }
    // for(int i=0;i<N;i++){
    //     cout<<A[i]<<ans_n_each[i]<<F[i]<<"\n";
    // }
    ll ans = max_ans;
    cout<< ans << "\n";
    // cout<< iter<< "\n";
	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ans = true;
    
    rep(i, (a + b + 1)) {
        if (
            ((i < a) && ((s[i] < '0') || (s[i] > '9'))) ||
            ((i == a) && (s[i] != '-')) ||
            ((i > a) && ((s[i] < '0') || (s[i] > '9')))
        ) {
            ans = false;
            break;
        }
    }
    
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x>y?y:x;}
ll llmax(ll x,ll y){return x>y?x:y;}
ll llmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}

int main(){
    static int n,a[200000],b[200000];

    scanf("%d",&n);
    for(int i=0;i<n+1;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
    }

    ll ans=0;
    for(int i=0;i<n;i++){
        if(b[i]>a[i]){
            ans+=a[i];
            b[i]-=a[i];
            a[i]=0;
            if(b[i]>a[i+1]){
                ans+=a[i+1];
                b[i]-=a[i+1];
                a[i+1]=0;
            }else{
                ans+=b[i];
                a[i+1]-=b[i];
                b[i]=0;
            }
        }else{
            ans+=b[i];
            a[i]-=b[i];
            b[i]=0;
        }
    }
    printf("%lld\n",ans);
    return 0;

}


Measured memory_bytes: 896
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

class City {
	private int fP;
	private int fY;
	private int fId;
	private DecimalFormat fDformat;

	public City(int p, int y, DecimalFormat dformat) {
		fP = p;
		fY = y;
		fDformat = dformat;
	}

	public int getY() {
		return fY;
	}

	public String getTextP() {
		return fDformat.format(fP);
	}

	public int getP() {
		return fP;
	}

	public int getId() {
		return fId;
	}

	public String getTextId() {
		return fDformat.format(fId);
	}

	public void setId(int id) {
		fId = id;
	}
}

class compCity implements Comparator<City> {
	public int compare(City city1, City city2) {
		if (city1.getP() < city2.getP() || (city1.getP() == city2.getP() && city1.getY() < city2.getY())) {
			return -1;
		} else if (city1.getP() > city2.getP() || (city1.getP() == city2.getP() && city1.getY() > city2.getY())) {
			return 1;
		} else {
			return 0;
		}
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextInt();// N
		int M = sc.nextInt();
		ArrayList<City> cityList = new ArrayList<City>(M);
		ArrayList<City> cityOriginalList = new ArrayList<City>(M);
		DecimalFormat dformat = new DecimalFormat("000000");
		for (int i = 0; i < M; i++) {
			int p = sc.nextInt();
			int y = sc.nextInt();
			City c = new City(p, y, dformat);
			cityList.add(c);
			cityOriginalList.add(c);
		}
		sc.close();

		Collections.sort(cityList, new compCity());

		int id = 1;
		int nowP = cityList.get(0).getP();
		for (int i = 0; i < M; i++) {
			if (nowP == cityList.get(i).getP()) {
				cityList.get(i).setId(id);
				id++;
			} else {
				nowP = cityList.get(i).getP();
				id = 1;
				cityList.get(i).setId(id);
				id++;
			}
		}

		for (int i = 0; i < M; i++) {
			System.out.println(cityOriginalList.get(i).getTextP() + cityOriginalList.get(i).getTextId());
		}

	}
}

Measured memory_bytes: 108124
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    int N; read(N);

    long double sum = 0;

    rep(i, N) {
        long double x; string t;
        read(x, t);

        if (t == "JPY") {
            sum += x;
        } else {
            sum += x * 380000;
        }
    }

    cout << fixed << setprecision(9);
    print(sum);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main() {

  int num = 0;
  int max_num = 0;
  int n;
  int A[100000];

  int a, b, c, d;

  cin >> a >> b >> c >> d;

  if (abs (a - c) <= d) cout << "Yes" << endl;
  else if (abs (a - b) <= d && abs (b - c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;  
}


Measured memory_bytes: 256
a = input()
if(a[0] == "1")and(a[1] == "1")and(a[2] == "1"):
    print(3)
elif (a[0] == "0")and(a[1] =="0")and(a[2] == "0"):
    print(0) 
elif(a[0] == "1")and(a[1] == "0")and(a[2] == "0"):
    print(1)
elif(a[0] == "0")and(a[1] == "1")and(a[2] == "0"):
    print(1)
elif(a[0] == "0")and(a[1] == "0")and(a[2] == "1"):
    print(1)
else:
    print(2)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll A, B, X;

int main() {
	cin >> A >> B >> X;
	if (X >= A && X <= A + B)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main(void) {
  ll N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  REP(i, 0, N) cin >> w[i] >> v[i];

  const ll INF = 1LL << 60;
  vector<vector<ll>> dp(N + 1, vector<ll>(100001, INF));
  dp[0][0] = 0;

  REP(i, 0, N) {
    REP(j, 0, 100001) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      if (j + v[i] <= 100000) {
        dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
      }
    }
  }

  ll ans = 0;
  REP(i, 0, 100001) {
    if (dp[N][i] <= W) {
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
  int N;
  cin >> N;
  if (N % 1000 == 0) cout << 0 <<endl;
  else cout << 1000 - (N % 1000) << endl;
}

Measured memory_bytes: 3620
#include <functional>
#include <cassert>
#include <cstring>
#include <set>
#include <algorithm>
#include <numeric>
#include <iostream>
using namespace std;

void bruteforce(int x, int y, int z, int *b, int *c, long long ans) {
    const int n = x + y + z;
    function<long long(int, int, int, long long)> dfs = [&](int y, int z, int i, long long acc) {
        // cerr << y << " " << z << " " << i << " " << acc << endl;
        if (y == 0 && z == 0) return acc;
        if (i + y + z > n) return -(1LL<<60);
        long long tmp = -(1LL<<60);
        if (y > 0) tmp = max(tmp, dfs(y - 1, z, i + 1, acc + b[i]));
        if (z > 0) tmp = max(tmp, dfs(y, z - 1, i + 1, acc + c[i]));
        tmp = max(tmp, dfs(y, z, i + 1, acc));
        return tmp;
    };
    long long ans2 = dfs(y, z, 0, 0);
    if (ans != ans2)
        cerr << "solution => " << ans << "\nbruteforce => " << ans2 << endl;
    else
        cerr << "OK\n";
}

int main() {
    int x, y, z; cin >> x >> y >> z;
    const int n = x + y + z;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
        b[i] -= a[i];
        c[i] -= a[i];
    }
    long long sum = accumulate(a, a+n, 0LL);
    int v[n]; iota(v, v+n, 0);
    sort(v, v+n, [&](int i, int j) { return b[i] - c[i] > b[j] - c[j]; });
    int tmp[2][n];
    copy(b, b+n, tmp[0]);
    copy(c, c+n, tmp[1]);
    for (int i = 0; i < n; i++) {
        b[i] = tmp[0][v[i]];
        c[i] = tmp[1][v[i]];
    }

    long long B[n], C[n];
    multiset<int> S;
    for (int i = 0; i < y; i++) S.insert(b[i]);
    B[y] = accumulate(S.begin(), S.end(), 0LL);
    
    for (int i = y; i < x + y; i++) {
        B[i+1] = B[i];
        if (*S.begin() < b[i]) {
            B[i+1] += b[i] - *S.begin();
            S.erase(S.begin());
            S.insert(b[i]);
        }
        // cerr << i << " " << B[i] << " " << B[i+1] << endl;
    }
    S.clear();
    for (int i = x + y; i < n; i++) S.insert(c[i]);
    C[x + y] = accumulate(S.begin(), S.end(), 0LL);
    for (int i = x + y - 1; i >= y; i--) {
        C[i] = C[i+1];
        if (*S.begin() < c[i]) {
            C[i] += c[i] - *S.begin();
            S.erase(S.begin());
            S.insert(c[i]);
        }
        //cerr << i << " " << C[i+1] << " " << C[i] << endl;
    }

    long long ans = 0;
    for (int i = y; i <= x + y; i++)
        ans = max(ans, sum + B[i] + C[i]);
    cout << ans << endl;

    // if (n <= 20) bruteforce(x, y, z, b, c, ans - sum);
}


Measured memory_bytes: 9892
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

//const int MOD = 1e7+9;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int nax = 10000000;
	ll k;cin>>k;
    ll val = 7 ;
    for (int i = 1; i < nax; ++i)
    {
        if(val %  k == 0 ){
             cout<<i ;
             return 0;
         }
        val = ((val*10)%k + 7) % k;

    }
    cout<<"-1";

    return 0;
}



Measured memory_bytes: 3616
import java.util.*;

public class Main {

  static int N; 
  static boolean[][] graph;
  static boolean[] visited;

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    N = sc.nextInt();
    int M = sc.nextInt();
    int[] a = new int[M];
    int[] b = new int[M];
    graph = new boolean[N][N];

    for (int i = 0; i < M; i++) {
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
      graph[a[i]][b[i]] = true;
      graph[b[i]][a[i]] = true;
    }

    sc.close();

    visited = new boolean[N];

    int count = 0;

    for (int i = 0; i < M; i++) {

      // 一旦全ての頂点を未到達にする
      for (int j = 0; j < N; j++) {
        visited[j] = false; 
      }

      // 1本辺を一旦無効にする
      graph[a[i]][b[i]] = false;
      graph[b[i]][a[i]] = false;

      // グラフが連結であるかを調べる
      dfs(0);

      // 1点でもvisited[i]がfalseだったら、無効した辺は橋
      for (int j = 0; j < N; j++) {
        if (visited[j] == false) {
          count++;
          break;
        }
      }

      // 無効にした辺を戻す
      graph[a[i]][b[i]] = true;
      graph[b[i]][a[i]] = true;

    }
    
    System.out.println(count);

  }

  // グラフが連結であるかを調べる
  public static void dfs(int v) {

    // 全て訪問済みなら終わり
    if (visited[v] == true) {
      return;
    }
    
    // 現在の頂点は訪問済み
    visited[v] = true;
 
    for (int i = 0; i < N; i++) {
      
      if (graph[v][i] == false) {
        continue;
      }
      
      dfs(i);
 
    }
  }

}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1000005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/

const int mod = 1e9 + 7;
ll dp[maxn];

int main()
{
	FASTIO
	/*
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
//*/
	int n;
	cin >> n;
	dp[0] = 3;
	ll ans = 1;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		x++;
		ans *= dp[x - 1];
		dp[x]++;
		dp[x - 1]--;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
S = input()

ans = 'AC'
count = 0
for i in range(len(S)):
    if i==0 and S[i] != 'A':
        ans = 'WA'
        break
    if i!=0 and S[i] != 'C' and S[i].isupper():
        ans = 'WA'
        break
    if (2 <= i <= len(S)-2) and S[i] == 'C':
        count += 1

if count != 1:
    ans = 'WA'

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L
const int mxN = 2e2;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    long long ans = t;
    long long sum = x;
    while (sum < n) {
        sum += x;
        ans += t;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
  char X, Y;
  cin >> X >> Y;
  if (X < Y) {
    cout << '<' << endl;
  }
  else if (X == Y) {
    cout << '=' << endl;
  }
  else {
    cout << '>' << endl;
  }
}

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

cnt = 0
for i in range(int(n//r)+1):
    r_num = r * i
    for j in range(int((n - r_num)//g)+1):
        g_num = g * j
        b_num = (n - r_num - g_num)
        if b_num >= 0 and b_num % b == 0:
            cnt += 1

print(cnt)


Measured memory_bytes: 2940
import numpy as np
from copy import deepcopy


N, x = map(int,raw_input().split())
A = map(int,raw_input().split())

def myfunc(N, x, A):
  B = deepcopy(np.array(A))
  m = sum(B)
  def apppop(A):
    A.append(A[0])
    A.pop(0)
  for idx in xrange(1,N):
    apppop(A)
    np.fmin(B, A, out=B)
    m = min(np.sum(B)+idx*x, m)
  print int(m)

myfunc(N, x, A)

Measured memory_bytes: 10536
using System;
using System.Linq;

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      int N=int.Parse(Console.ReadLine());
      string[] str=new string[N];
      for(int i=0;i<N;i++){
        str[i]=Console.ReadLine();
      }
      string[] dis=str.Distinct().ToArray();
      Console.WriteLine(dis.Length);
      
    }
    
  }

}



Measured memory_bytes: 50004