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

template <std::uint_fast64_t mod>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 x;
    ModInt(const int x = 0) : x(x < 0 ? (mod - (-x % mod)) % mod : x % mod) {}

    ModInt operator+(const ModInt r) { return ModInt(*this) += r; }
    ModInt operator*(const ModInt r) { return ModInt(*this) *= r; }
    ModInt operator-(const ModInt r) { return ModInt(*this) -= r; }
    ModInt operator/(const ModInt r) { return ModInt(*this) /= r; }
    ModInt operator-() { return ModInt(mod - x); }

    ModInt &operator+=(const ModInt r) {
        x += r.x;
        if (x >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt r) {
        if (x < r.x) x += mod;
        x -= r.x;
        return *this;
    }
    ModInt &operator*=(const ModInt r) {
        x *= r.x;
        if (x >= mod) x %= mod;
        return *this;
    }
    ModInt &operator/=(ModInt r) {
        if (!(x % r.x)) {
            x /= r.x;
            return *this;
        }
        u64 p = mod - 2;
        *this *= r.pow(p);
        return *this;
    }
    ModInt &operator++(int) { return (*this) += 1; }
    ModInt &operator++() { return (*this) += 1; }
    ModInt &operator--(int) { return (*this) -= 1; }
    ModInt &operator--() { return (*this) -= 1; }

    bool operator<(const ModInt r) { return x < r.x; }
    bool operator>(const ModInt r) { return x > r.x; }
    bool operator<=(const ModInt r) { return x <= r.x; }
    bool operator>=(const ModInt r) { return x >= r.x; }
    bool operator==(const ModInt r) { return x == r.x; }
    bool operator!=(const ModInt r) { return x != r.x; }

    ModInt pow(u64 n) const {
        ModInt res(1), mul(x);
        while (n > 0) {
            if (n & 1) res *= mul;
            mul *= mul;
            n >>= 1;
        }
        return res;
    }
    ModInt inv() { return (ModInt)1 / (*this); }
    int get_mod() { return mod; }

    friend std::istream &operator>>(std::istream &in, ModInt &m) {
        int a;
        in >> a;
        if (a < 0) a = mod - (-a % mod);
        if (a >= mod) a %= mod;
        m.x = a;
        return in;
    }
    friend std::ostream &operator<<(std::ostream &out, const ModInt &m) {
        out << m.x;
        return out;
    }
};
constexpr std::uint_fast64_t mod = 1e9 + 7;
using mint = ModInt<mod>;

int main() {
    mint n;
    cin >> n;
    vector<mint> C;
    for (int i = 0; i < n.x; i++) {
        mint c;
        cin >> c;
        C.push_back(c);
    }
    sort(C.begin(), C.end(), [](mint x, mint y) { return x > y; });
    mint ans = 0;
    for (mint i = 0; i < n; i++) {
        ans += (i + 2) * C[i.x];
    }
    ans *= mint(4).pow(n.x - 1);
    cout << ans << endl;
    return 0;
}

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

int main(void){
  int N;
  string S;
  string diffS = "";
  vector<int> apperNumOfEachChar;
  cin>>N>>S;
  long long ans;
  
  //shori
  for(int i = 0; i<N; i++){
    auto apperChar = find(diffS.begin(),diffS.end(),S[i]);
    if(apperChar == diffS.end()){//*itrがまだ出てない文字のとき
      diffS.push_back(S[i]);
      apperNumOfEachChar.push_back(1);
    }
    else {//*itrが既に出ている文字のとき
      int indx = apperChar-diffS.begin();
      apperNumOfEachChar[indx] += 1;
    }
  }
  ans = 1;
  for(int i = 0; i<diffS.size(); i++){
    ans *= apperNumOfEachChar[i]+1;
    ans = ans%1000000007;
    //cout<<apperNumOfEachChar[i]<<" ";
  }
  ans -= 1;
  //cout<<endl;
  //cout<<diffS<<endl;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int x=tx-sx;
    int y=ty-sy;
    string ans="";
    rep(i,x) ans+='R';
    rep(i,y) ans+='U';
    rep(i,x) ans+='L';
    rep(i,y+1) ans+='D';
    rep(i,x+1) ans+='R';
    rep(i,y+1) ans+='U';
    ans+="LU";
    rep(i,x+1) ans+='L';
    rep(i,y+1) ans+='D';
    ans+='R';
    cout<<ans<<endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    
	    Scanner sc = new Scanner(System.in);  //標準入力の宣言

		String S = sc.next();  //標準入力をSに代入
		
		char[] s = S.toCharArray();  //Sを1文字ずつ配列に入れる
		
		if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
			System.out.println("Bad");
		} else {
			System.out.println("Good");}

  }
}


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

int main(){
  int64_t X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int64_t> P(A), Q(B), R(C);
  vector<pair<int64_t, int64_t>> Z(A+B+C);
  for(int64_t i=0; i<A; i++){
    cin >> P.at(i);
    Z.at(i)=make_pair(-P.at(i), 0);
  }
  for(int64_t i=0; i<B; i++){
    cin >> Q.at(i);
    Z.at(i+A)=make_pair(-Q.at(i), 1);
  }
  for(int64_t i=0; i<C; i++){
    cin >> R.at(i);
    Z.at(i+A+B)=make_pair(-R.at(i), 2);
  }
  sort(Z.begin(), Z.end());
  for(int64_t i=0; i<A+B+C; i++){
    Z.at(i).first=-Z.at(i).first;
  }
  int64_t k=0;
  int64_t Ans=0;
  int64_t Get=0;
  int64_t Getx=0, Gety=0;
  while(Get<X+Y){
    if(Getx<X && Gety<Y){
      Ans+=Z.at(k).first;
      if(Z.at(k).second==0){
        Getx++;
      }
      else if(Z.at(k).second==1){
        Gety++;
      }
      Get++;
    }
    else if(Getx==X && Z.at(k).second!=0){
      Ans+=Z.at(k).first;
      Get++;
      }
    else if(Gety==Y && Z.at(k).second!=1){
      Ans+=Z.at(k).first;
      Get++;
    }
    k++;
  }
  cout << Ans << endl;
}

Measured memory_bytes: 7296
'use strict'

function Main(input) {
    let temp = input.trim().split('\n');
    let n=parseInt(temp[0]);
    let s=temp[1];
    let k=parseInt(temp[2]);

    let c='[^' +s[k-1]+']';
    let ans = s.replace(new RegExp(c,'g'),'*');

    console.log(ans);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;
int r, b, g, k;
bool can(int x, int y, int c){
    if(c > x && y > c){
        return 1;
    }
    return 0;
}
bool mag(int x, int y, int c, int pos){
    if(pos == k && can(x, y, c)){
        return 1;
    }
    if(pos == k) return 0;
    if(mag(x * 2, y, c, pos + 1)){
        return 1;
    }
    if(mag(x, y * 2, c, pos + 1)){
        return 1;
    }
    if(mag(x, y, c * 2, pos + 1)){
        return 1;
    }
    return 0;
}
int main(){
    cin >> r >> g >> b >> k;
    if(mag(r, b, g, 0)){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}


Measured memory_bytes: 3620
n,k,q=list(map(int, input().split()))
a=[int(input()) for i in range(q)] 
if k-q>0:
	[print('Yes') for i in range(n)]
else:
	p=[0]*n
	for i in range(q):
		p[a[i]-1]+=1
	for i in range(n):
		if p[i]>q-k:
			print('Yes')
		else:
			print('No')

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		ans+=abs(a[i]);
	}
	if (a[0]<0)
	{
		ans-=2*abs(a[0]);
	}
	else if (a[n-1]>0)
	{
		ans-=2*abs(a[n-1]);
	}
	cout<<ans<<endl;
	int now=1;
	while (a[now]>0)
	{
		cout<<a[n-1]<<" "<<a[now]<<endl;
		a[n-1]-=a[now];
		++now;
	}
	while (now<n)
	{
		cout<<a[0]<<" "<<a[now]<<endl;;
		a[0]-=a[now];
		++now;
	}
	return 0;
}


Measured memory_bytes: 2304
n, l = gets.split(" ").map(&:to_i)
array = []
(1..n).each do |i|
  array << i + l - 1
end
(0..(n + l - 1).abs).each do |i|
  index1 = array.find_index(i)
  index2 = array.find_index(-i)
  if index1
    array.delete_at(index1)
    break
  elsif index2
    array.delete_at(index2)
    break
  end
end

puts array.inject(&:+)

Measured memory_bytes: 1916
N = int(input())
A = list(map(int, input().split()))
M = int(input())
B = list(map(int, input().split()))
d = {}
for a in A:
  d[a] = d.get(a, 0) + 1
f = 0
for b in B:
  d[b] = d.get(b, 0) - 1
  if d[b] < 0:
    print("NO")
    f = 1
    break
if f == 0:
  print("YES")

Measured memory_bytes: 130752
#include <stdio.h>
 
int main()
{
    while (1) {
        int a, b, sol;
        char op;
        scanf("%d %c %d", &a, &op, &b);
        switch (op) {
        case '?' :
            return 0;
        case '*' :
            sol = a * b;
            break;
        case '/' :
            sol = a / b;
            break;
        case '+' :
            sol = a + b;
            break;
        case '-' :
            sol = a - b;
            break;
        }
        printf("%d\n", sol);
    }
}

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

#define N 100

int main() {
  int i, j, k, l, n, p[N+1], cost[N+1][N+1], min_cost;

  cin >> n;
  for (i = 1; i <= n; i++) cin >> p[i-1] >> p[i];

  // 初期値
  for (i = 1; i <= n; i++) cost[i][i] = 0;

  for (l = 2; l <= n; l++) {  // 行列の個数
    for (i = 1; i <= n - l + 1; i++) {
      j = i + l - 1;
      for (k = i; k < j; k++) {
        if (k == i) min_cost = cost[i][k] + cost[k+1][j] + p[i-1] * p[k] * p[j];
        else min_cost = min(min_cost, cost[i][k] + cost[k+1][j] + p[i-1] * p[k] * p[j]);
      }
      cost[i][j] = min_cost;
    }
  }

  cout << cost[1][n] << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int>d(N);
  rep(i,N) cin >> d.at(i);
  set<int> s;
  rep(i,N) s.insert(d.at(i));
  cout << s.size();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string T;
  cin >> T;
  if (T[0] == '?')
    T[0] = 'D';
  for (int i = 1; i < T.size(); i++)
  {
    if (T[i - 1] == 'P' && T[i] == '?')
      T[i] = 'D';
    else if (T[i] == '?')
      T[i] = 'D';
  }
  cerr << T << endl;
  cout << T << endl;
  return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int pref[200005], suf[200005], a[200005], chet[200005];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];

    ll sum = 0;
    for (int i = 1; i <= n; i++)
    {
        sum += (ll) a[i];
        pref[i] = pref[i - 1];
        if (a[i] == 0) pref[i] += 2;
        if (a[i] % 2 == 1) pref[i]++;
        pref[i] = min((ll) pref[i], sum);
    }

    sum = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        sum += (ll) a[i + 1];
        suf[i] = suf[i + 1];
        if (a[i + 1] == 0) suf[i] += 2;
        if (a[i + 1] % 2 == 1) suf[i]++;
        suf[i] = min((ll) suf[i], sum);
    }
    for (int i = 1; i <= n; i++)
        chet[i] = chet[i - 1] + (a[i] % 2 == 0);

    int ans = 2 * n, mn = pref[0] - chet[0];
    for (int i = 0; i <= n; i++)
    {
        ans = min(ans, pref[i] + suf[i]);
        ans = min(ans, suf[i] + chet[i] + mn);
        mn = min(mn, pref[i] - chet[i]);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,n;
    scanf("%d%d%d",&a,&b,&c);
    n=a*b;
    if(n<c)
    printf("%d",n);
    else
    printf("%d",c);
    return 0;
}


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

int main()
{
    int M, N, C;
    std::cin >> N >> M >> C;
    std::vector<std::vector<int>> A(N, std::vector<int> (M));
    std::vector<int> B(M);

    for(int i=0; i<M; i++)  std::cin >> B[i];
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<M; j++)
        {
            std::cin >> A[i][j];
        }
    }

    int ans = 0;
    for(int i=0; i<N; i++)
    {
        long long sum = 0;
        for(int j=0; j<M; j++)
        {
            sum += A[i][j] * B[j];
        }

//        printf("***%d\n", sum);
        if( sum+C > 0 )
        {
            ans++;
        }
    }

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

    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		@SuppressWarnings("unchecked")
		ArrayList<Edge> edges[] = new ArrayList[n];

		for(int i = 0; i < n; i++){
			if(edges[i] == null){
				edges[i] = new ArrayList<Edge>();
			}
		}

		String[] tmpArray;
		for(int i = 0; i < n - 1; i++){
			tmpArray = br.readLine().split(" ");
			int from = Integer.parseInt(tmpArray[0]) - 1;
			int to = Integer.parseInt(tmpArray[1]) - 1;
			int cost = Integer.parseInt(tmpArray[2]);

			edges[from].add( new Edge(to, cost));
			edges[to].add( new Edge(from, cost));
		}

		tmpArray = br.readLine().split(" ");
		int q = Integer.parseInt(tmpArray[0]);
		int k = Integer.parseInt(tmpArray[1]) - 1;

		long fromK[] = dijkstra(edges, k, n);

		for(int i = 0; i < q; i++){
			tmpArray = br.readLine().split(" ");
			int x = Integer.parseInt(tmpArray[0]) - 1;
			int y = Integer.parseInt(tmpArray[1]) - 1;

			System.out.println(fromK[x] + fromK[y]);
		}
	}

//	static void solve(ArrayList<Edge>[] edges,  int n, int x){
//		int[] dist = dijkstra(edges, x, n);
//
//		for(int i = 0; i < n; i++){
//			if(dist[i] == INF){
//				System.out.println("INF");
//			}
//			else {
//				System.out.println(dist[i]);
//			}
//		}
//
//	}

	static final long INF = 1_000_000_000_000_000_0L;

	//ダイクストラ法
	static long[] dijkstra(ArrayList<Edge>[] edges, int s, int n){

		PriorityQueue<Distance> que = new PriorityQueue<Distance>();
		long[] dist = new long[n];

		Arrays.fill(dist, INF);
		dist[s] = 0;
		que.add(new Distance(0, s));

		while(!que.isEmpty()){
			Distance tmpDist = que.poll();
			int tmpV = tmpDist.id;

			if(dist[tmpV] < tmpDist.dist){
				continue;
			}
			for(int i = 0; i < edges[tmpV].size() ; i++){
				Edge e = (Edge) edges[tmpV].get(i);
				if(dist[e.to] > dist[tmpV] + e.cost){
					dist[e.to] = dist[tmpV] + e.cost;
					que.add(new Distance(dist[e.to], e.to));
				}
			}
		}

		return dist;
	}
}

class Distance implements Comparable<Distance>{
	long dist;
	int id;

	Distance(long dist, int id){
		this.dist = dist;
		this.id = id;
	}

	@Override
	public int compareTo(Distance d) {
//		return this.dist - d.dist;

		if(this.dist > d.dist){
			return 1;
		}
		else if(this.dist < d.dist){
			return -1;
		}
		else {
			return 0;
		}
	}
}

class Edge {
	int to;
	int cost;

	Edge(int to, int cost){
		this.to = to;
		this.cost = cost;
	}
}


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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<bool> ok(m, true);
    rep(i, 0, n) {
        ll k;
        cin >> k;
        vector<bool> tmp(m, false);
        rep(j, 0, k) {
            ll a;
            cin >> a;
            a--;
            tmp[a] = true;
        }
        rep(j, 0, m) {
            if(!tmp[j]) ok[j] = false;
        }
    }
    ll ans = 0;
    rep(i, 0, m) {
        if(ok[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int dp[1000005][2];

int main(){
  string s;
  cin >> s;
  s += '0';
  int n = s.size();
  reverse(s.begin(),s.end());
  rep(i,n+3)rep(j,2)dp[i][j]=INF;
  dp[0][0]=0;
  for(int i=0;i<n;i++)rep(j,2){
    int nd = s[i]-'0';
    if(j==1)nd++;
    rep(d,10){
      if(d>=nd){
        dp[i+1][0]=min(dp[i+1][0],dp[i][j]+d+d-nd);
      }else{
        dp[i+1][1]=min(dp[i+1][1],dp[i][j]+d+d+10-nd);
      }
    }
  }
  cout << min(dp[n][0],dp[n][1]+1) << endl;
}

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    ll D;
    cin>>D;
    if(D==25)cout<<"Christmas"; 
    if(D==24)cout<<"Christmas Eve";
    if(D==23)cout<<"Christmas Eve Eve";
    if(D==22)cout<<"Christmas Eve Eve Eve";

}

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

using namespace std;

const int mod = 1e9 + 7;

#define rep(i, a, b) for (int i = (a); i < (b); i++)

const int maxn = 3e3 + 5;

int n, q;
int a[maxn];
int xl[maxn], xr[maxn];
long long dp[maxn][maxn];

long long power_mod(long long a, long long b) {
    long long res = 1;
    while (b) {
        if (b % 2) res = res * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return res;
}

void trans() {
    cin >> n >> q;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, q) {
        cin >> xl[i] >> xr[i];
        xl[i]--; xr[i]--;
    }
    long long re2 = power_mod(2, mod - 2);
    rep(i, 0, n) {
        rep(j, 0, n) {
            if (i != j && a[i] > a[j]) {
                dp[i][j] = 1;
            }
        }
    }
    rep(t, 0, q) {
        rep(i, 0, n) {
            if (i == xl[t] || i == xr[t]) continue;
            dp[i][xl[t]] = dp[i][xr[t]] = (dp[i][xl[t]] + dp[i][xr[t]]) * re2 % mod;
            dp[xl[t]][i] = dp[xr[t]][i] = (dp[xl[t]][i] + dp[xr[t]][i]) * re2 % mod;
        }
        dp[xl[t]][xr[t]] = dp[xr[t]][xl[t]] = (dp[xl[t]][xr[t]] + dp[xr[t]][xl[t]]) * re2 % mod;
    }
    long long ans = 0;
    rep(i, 0, n) {
        rep(j, i + 1, n) {
            (ans += dp[i][j]) %= mod;
        }
    }
    ans = ans * power_mod(2, q) % mod;
    cout << ans;
}

int main() {
    trans();
    return 0;
}


Measured memory_bytes: 70656
// https://atcoder.jp/contests/abc162/tasks/abc162_d

#include <iostream>
using namespace std;

int main(){
	int n, i, j, k;
	long long int t = 0;
	char x, y, z, w = 'R' + 'G' + 'B';
	string s;
	cin >> n;
	cin >> s;
	int r[n], g[n], b[n];
	for(i=0, k=0; i<n; ++i){
		if(s[i]=='R') ++k;
		r[i] = k;
	}
	for(i=0, k=0; i<n; ++i){
		if(s[i]=='G') ++k;
		g[i] = k;
	}
	for(i=0, k=0; i<n; ++i){
		if(s[i]=='B') ++k;
		b[i] = k;
	}
	t = 0;
	for(i=0; i<n-2; ++i){
		x = s[i];
		for(j=i+1; j<n-1; ++j){
			if(s[j]==x) continue;
			y = s[j];
			z = w-x-y;
			k = (j<<1) - i;
			if(z=='R'){
				t += r[n-1] - r[j] - (k<n)*(s[k]=='R');
			}else if(z=='G'){
				t += g[n-1] - g[j] - (k<n)*(s[k]=='G');
			}else {
				t += b[n-1] - b[j] - (k<n)*(s[k]=='B');
			}
		}
	}
	cout << t << endl;
	return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};

int hoge[1000][1000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;cin>>h>>w;
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>hoge[i][j];
  vector<pair<ll,ll>>from;
  vector<pair<ll,ll>>to;
  for(int i=0;i<h;i++){
    if(i%2){
      for(int j=w-1;j>=0;j--){
	if(hoge[i][j]%2){
	  if(i==h-1&&j==0)continue;
	  if(j>0){from.pb(mp(i,j));to.pb(mp(i,j-1));hoge[i][j-1]++;}
	  else {from.pb(mp(i,j));to.pb(mp(i+1,j));hoge[i+1][j]++;}
	}
      }
    }else{
      for(int j=0;j<w;j++){
	if(i==h-1&&j==w-1)continue;
	if(hoge[i][j]%2){
	  if(j!=w-1){
	    hoge[i][j+1]++;
	    from.pb(mp(i,j));
	    to.pb(mp(i,j+1));
	  }else{
	    hoge[i+1][j]++;
	    from.pb(mp(i,j));
	    to.pb(mp(i+1,j));
	  }
	}
      }
    }
  }
  cout<<from.size()<<endl;
  for(int i=0;i<from.size();i++){
    cout<<from[i].F+1<<" "<<from[i].S+1<<" "
	<<to[i].F+1<<" "<<to[i].S+1<<endl;
  }
  return 0;
}


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


int main(){
	int n, tmp, diff = 0;
	cin >> n;
	priority_queue<int> que;
	rep(i,n){
	    cin >> tmp;
	    que.push(tmp);
	}
	rep(i,n){
	    if(i%2 == 0) diff += que.top();
	    else diff -= que.top();
	    que.pop();
	}
	cout << diff << endl;
}


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

using namespace std;

int main()
{
    int n , m , i ,j=0,count = 0;
    cin >> n >> m;
    float ara[n];
    for(i=0;i<n;i++)
    {
        cin >> ara[i];
        count = count + ara[i];

    }
    sort(ara,ara+n);
    reverse(ara,ara+n);
    for(i=0;i<m;i++)
        {
            j=0;
            if((float)(ara[i]/count) < (float)(.25/m))
            {
                cout <<"No" ;
                break;
            }else
            {
                j=1;
            }
        }
    if(j==1)
    {
        cout << "Yes";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        // 入力(a b)
        int a = sc.nextInt();
        int b = sc.nextInt();

        String result = "Draw";
        int strengthA = calcStrength(a);
        int strengthB = calcStrength(b);
        if (strengthA > strengthB) {
            result = "Alice";
        } else if (strengthA < strengthB) {
            result = "Bob";
        }
        System.out.println(result);
        sc.close();
    }

    /**
     * 2->1, 3->2, ..., 13->12, 1->13
     * @param value card value
     * @return strength
     */
    private static int calcStrength(int value) {
        int strength = value - 1;
        return (strength > 0) ? strength : strength + 13;
    }
}

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

  int N  ;
  cin >> N ;
  rep(i,50002){
    int B = i * 1.08 ;
    //cout << B << endl;
   if (B  == N ) {
     cout <<  i << endl;
     return 0 ;
   }
  }
  cout << ":(" <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>

using namespace std;

#define MOD 1000000007
#define INF 1050000000

int main() {
	int a[5];

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


	int m = 10;

	int ans = 0;

	bool x = false;

	for (int i = 0; i < 5; i++) {
		if (a[i] % 10 == 0) {
			ans += a[i];
		}
		else {
			x = true;
			int tmp = a[i] % 10;
			m = min(m, tmp);
			ans += a[i] - a[i] % 10 + 10;
		}
	}

	if (x) {
		cout << ans - 10 + m << endl;
	}
	else {
		cout << ans << endl;
	}



	






}

Measured memory_bytes: 256
# include <stdio.h>
# define abs(x) ((x >0)? x:( -(x )))
int H,W,D,A;
int Q,L,R;
int px [90001] , py [90001];
int d [90001];
int main ()
{
    scanf ("%d%d%d",&H ,&W ,&D);
    for (int i=0;i<H;i++)
    {
        for (int j=0;j<W;j++)
        {
            scanf ("%d",&A);
            px[A]=i,py[A]=j;
        }
    }
    for (int i=D+1;i <=H*W;i++)
        d[i]=d[i-D]+ abs(px[i]-px[i-D ])+ abs(py[i]-py[i-D ]);
    scanf ("%d",&Q);
    while (Q--)
    {
        scanf ("%d%d",&L ,&R);
        printf ("%d\n",d[R]-d[L]);
    }
}

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

int c[100001], d[100001];
signed main() {
	string a, b; cin >> a >> b;
	int e = 0;
	for (int f = 0; f < a.length(); f++) {
		if (a[f] == 'A')e++;
		else e--;
		c[f + 1] = e;
	}
	e = 0;
	for (int f = 0; f < b.length(); f++) {
		if (b[f] == 'A')e++;
		else e--;
		d[f + 1] = e;
	}
	int K; cin >> K;
	for (int i = 0; i < K; i++) {
		int n, m, x, y;
		scanf("%d%d%d%d", &n, &m, &x, &y);
		int p = c[m] - c[n - 1];
		p += 300000;
		int q = d[y] - d[x - 1];
		q += 300000;
		int O = max(p, q) - min(p, q);
		if (O % 3) {
			puts("NO");
		}
		else {
			puts("YES");
		}
	}
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  cout << 2018 << s.substr(4) << endl;
}



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

int main(){
	string s;
    cin >> s;
	int len = s.size();
	cout << s[0] << len - 2 << s[len-1] << endl;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N;
    cin >> N;
    Vl A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    Vl csum(N + 1);
    for (int i = 0; i < N; i++) {
        csum[i + 1] = csum[i] + A[i];
    }
    unordered_map<ll, ll> mp;
    ll ans = 0;
    ++mp[csum[0]];
    for (int i = 1; i <= N; i++) {
        ans += mp[csum[i]];
        ++mp[csum[i]];
    }

    cout << ans << endl;

    return 0;
}

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

int const N = 1000;
char g[N][N + 1];
int k;
vector<string> f4 = {
	"aabd",
	"ccbd",
	"bdaa",
	"bdcc"
}, f3 = {
	"xww",
	"x.z",
	"yyz"
}, f5 = {
	"aabbc",
	"hk..c",
	"hk..d",
	"g.zzd",
	"gffee"
}, f6 = {
	"xwwa..",
	"x.za..",
	"yyz.bb",
	"a..xww",
	"a..x.z",
	".bbyyz"
}, f7 = {
	"aabb..a",
	".x..xxa",
	".xa...b",
	"b.a...b",
	"b..bbx.",
	"axx..x.",
	"a..bbaa"
};

void fl(vector<string> const &v){
	f(i, 0, v.size())f(j, 0, v.size())g[i + k][j + k] = v[i][j];
	k += v.size();
}

void out(vector<string> const &g){
	f(i, 0, g.size())printf("%s\n", g[i].c_str());
	exit(0);
}

int main(){
	int n;
	scanf("%d", &n);
	if (n == 2){
		printf("-1\n");
		return 0;
	}
	if (n == 3)out(f3);
	if (n == 4)out(f4);
	if (n == 5)out(f5);
	if (n == 6)out(f6);
	if (n == 7)out(f7);
	f(i, 0, n)f(j, 0, n)g[i][j] = '.';
	int t = n;
	while (t >= 12)fl(f4), t -= 4;
	if (t == 11)fl(f5), fl(f6);
	else if (t == 10)fl(f5), fl(f5);
	else if (t == 9)fl(f5), fl(f4);
	else if (t == 8)fl(f4), fl(f4);
	f(i, 0, n)printf("%s\n", g[i]);
}

Measured memory_bytes: 2176
/*****Enigma_27*****/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pll         pair<ll,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define endl		'\n'
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,i,j,l=2,t=0,k=1,x,ans=0,s,f,m;
int main()
{   ios
    string p;
    cin>>p;
    sort(all(p));
    for(char c='a';c<='z';c++)
    {
        if(!bs(all(p),c)) {cout<<c<<endl;return 0;}
    }
    cout<<"None";

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    string S;
    cin >> S;
    string A = "";
    string B = "";
    bool isReversed = false;

    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int t;
        cin >> t;
        if(t == 1){
            if(isReversed){
                isReversed = false;
            }
            else{
                isReversed = true;
            }
            swap(A, B);
        }
        else{   // t == 2
            int f;
            cin >> f;
            char c;
            cin >> c;
            if(f == 1){
                A += c;
            }
            else{   // f == 2
                B += c;
            }
        }
    }

    if(isReversed){
        reverse(A.begin(), A.end());
        cout << A;
        reverse(S.begin(), S.end());
        cout << S;
        cout << B;
    }
    else{
        reverse(A.begin(), A.end());
        cout << A;
        cout << S;
        cout << B;
    }
    
    return 0;
}

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

int main() {
	int i,n;
	cin>>n;
	vector<int>a(n);
	for(i=0;i<n;i++) cin>>a[i];
	// int ma=-1;
	long long s=0;
	for(i=0;i<n-1;i++)
	{
		if(a[i]>a[i+1])
		{
			s=s+1LL*(a[i]-a[i+1]);
			a[i+1]=a[i];
		}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;string s;
	int q;
	cin>>n;
	cin>>s;
	cin>>q;
	while(q--)
	{
		ll d=0,m=0,dm=0,dmc=0;
		int k;
		scanf("%d",&k);
		for(int i=0;i<k;i++)
		{
			if(s[i]=='D')
			{
				d++;
			}
			else if(s[i]=='M')
			{
				dm+=d;m++;
			}
			else if(s[i]=='C')
			{
				dmc+=dm;
			}
		}
		for(int i=k;i<n;i++)
		{
			if(s[i-k]=='D')
			{
				d--;dm-=m;
			}
			else if(s[i-k]=='M')
			{
				m--;
			}
			if(s[i]=='D')
			{
				d++;
			}
			else if(s[i]=='M')
			{
				dm+=d;m++;
			}
			else if(s[i]=='C')
			{
				dmc+=dm;
			}
		}
		printf("%lld\n",dmc);
	}
 } 


Measured memory_bytes: 1412
n = gets.chomp.to_i
i = 0
zoro_count = 0
flag = false
while i < n
  a = gets.chomp.split(' ').uniq.size
  if a == 1
    zoro_count += 1
    if zoro_count == 3
      flag = true
    end
  else
    zoro_count = 0
  end
  i += 1
end

if flag
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14364
#include<algorithm>
#include<cstdio>
#include<cmath>
#define mxn 1000010
#define ldb long double
using namespace std;
const ldb PI=(ldb)acos(-1.0);
int n,L,sl,fh,t[mxn];
ldb ansx,ansy;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	n=rd();L=rd();ldb d;
	for(int i=1;i<=n;++i) t[i]=rd();
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
		{
			d=(ldb)(t[i]+t[j])/L/2;
			ansx+=(ldb)cos(2*PI*d)*(i-1+n-j)+(ldb)cos(2*PI*d+PI)*(j-i-1);
			ansy+=(ldb)sin(2*PI*d)*(i-1+n-j)+(ldb)sin(2*PI*d+PI)*(j-i-1);
		}
	printf("%.20Lf %.20Lf\n",ansx*6/n/(n-1)/(n-2),ansy*6/n/(n-1)/(n-2));
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define All(x) (x).begin(),(x).end()
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
const double PI=acos(-1.0);
const double eps=1e-6;
const long long mod=1e9+7;
const int inf=0x7fffffff;
const int maxn=200005;
ll qpow(ll x,ll y,ll Mod) {ll ans=1,base=x%Mod; while(y){if(y&1)ans=(ans*base)%Mod;base=(base*base)%Mod;y>>=1;} return ans;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// fast read
template<class T> void read(T &x) {
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9'){f|=(ch=='-');ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	x=f?-x:x;
	return;
}

int n;

ll a[maxn],b[maxn],zuo,you,sum[maxn];

int main(){
	//freopen("test.in","r",stdin);
	read(n);
	rep(i,1,n){
		read(a[i]),read(b[i]);
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if(n&1)
		printf("%lld\n",b[n/2+1]-a[n/2+1]+1);
	else printf("%lld\n",(b[n/2]+b[n/2+1])-(a[n/2]+a[n/2+1])+1);
	return 0;
}

Measured memory_bytes: 6860
#include <cstdio>
#include <set>
#include <climits>
#include <algorithm>

using namespace std;

typedef long long ll;
int n;
int a[222222];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a+i);
  ll s = 0;
  for (int i = 0; i < n; i++) {
    s += a[i];
  }
  ll res = LLONG_MAX;
  ll t = 0;
  for (int i = 0; i < n-1; i++) {
    t += a[i];
    s -= a[i];
    res = min(res, abs(t-s));
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	ll X;
	cin >> X;
	ll sum = 0;
	int T = 0;
	while (sum < X) {
		T++;
		sum += T;
	}
	cout << T << endl;
}


Measured memory_bytes: 384
s = input()
K = int(input())
subs = set()
for l in range(1,min(5,len(s))+1):
    for i in range(len(s)-l+1):
        subs.add(s[i:i+l])
subs = list(subs)
subs.sort()
print(subs[min(len(subs),K)-1])

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

vector<int> g[10000];
int c[10000];
int d[10000];
int idx_c = 0;

void dfs(int cur, int p) {
  d[cur] = c[idx_c];
  ++idx_c;
  for (int to: g[cur]) {
    if (to == p) {
      continue;
    }
    dfs(to, cur);
  }
}
int main() {
  int n;
  cin>>n;
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i=0; i<n; i++) cin>>c[i];
  sort(c, c + n);
  reverse(c, c + n);

  dfs(0, -1);
  long long m = 0;
  for (int i=1; i<n; i++) m += c[i];
  cout<<m<<endl;
  for (int i=0; i<n; i++) {
    cout<<d[i];
    if (i != n - 1) {
      cout<<" ";
    }
  }
  cout<<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define lli unsigned long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
    map<int,pair<int,int> > m; int n;
    int a[4][4];
    NA(i,1,4) NA(j,1,4) cin>>a[i][j], m[a[i][j]] = {i,j};
    cin>>n; vector<int> b(n);
    if(n<3) {cout<<"No"; return;}
    NA(i,0,n) cin>>b[i];
    NA(i,0,n){
        if(m[b[i]]==make_pair(0,0)) continue;
        a[m[b[i]].fi][m[b[i]].se] = -1;
    }
    NA(i,0,3) if(a[1][1+i]==-1) {if(i==2) {cout<<"Yes"; return;}} else break;
    NA(i,0,3) if(a[2][1+i]==-1) {if(i==2) {cout<<"Yes"; return;}} else break;
    NA(i,0,3) if(a[3][1+i]==-1) {if(i==2) {cout<<"Yes"; return;}} else break;
    NA(i,0,3) if(a[1+i][1]==-1) {if(i==2) {cout<<"Yes"; return;}} else break;
    NA(i,0,3) if(a[1+i][1]==-1) {if(i==2) {cout<<"Yes"; return;}} else break;
    NA(i,0,3) if(a[1+i][3]==-1) {if(i==2) {cout<<"Yes"; return;}} else break;
    NA(i,0,3) if(a[i+1][i+1]==-1) {if(i==2) {cout<<"Yes"; return;}} else break;
    if(a[1][3]==-1 && a[2][2]==-1 && a[3][1]==-1) {cout<<"Yes"; return;}
    cout<<"No";  
    return;
}
int main(){
    fastIO;
    solve();
    return 0;
}


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

int main()
{
    int n, m; cin >> n >> m;
    vector<vector<bool>> isneighbor(n, vector<bool>(n, false));
    for (int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;
        isneighbor[a-1][b-1] = true;
        isneighbor[b-1][a-1] = true;
    }
    vector<int> vertex(n);
    iota(all(vertex), 0);
    int count = 0;
    do
    {
        if (vertex[0] != 0) continue;
        bool isonestroke = true;
        for (int i = 0; i < n - 1; i++)
        {
            if (isneighbor[vertex[i]][vertex[i+1]] == false)
            {
                isonestroke = false;
                break;
            }
        }
        if (isonestroke == true) count++;
    } while(next_permutation(all(vertex)));
    cout << count << endl;
}

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

int main(){

    int n;
    cin >> n;
    vector<int> a(n),b(n);

    rep(i,n){
        cin >> a[i] >> b[i];
    }

    ll s=a[0],t=b[0];

    for(int i=1;i<n;i++){
        ll su=a[i]+b[i];
        ll ta=s/a[i];
        ll tb=t/b[i];
        if(s%a[i]!=0) ta++;
        if(t%b[i]!=0) tb++;
        ll m=max(ta,tb);
        s=a[i]*m;
        t=b[i]*m;
    }

    cout << s+t << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  long long prev = 2; // i == 0
  long long cur = 1;  // i == 1
  long long next = 0; // i == 2
  
  for(int i=2;i<=N;i++){
    next = cur + prev;
    prev = cur;
    cur = next;
  }
  if(N == 0){
    cout << 2 << endl;
  }else if(N == 1){
    cout << 1 << endl;
  }else{
    cout << cur << endl;
  }
}

Measured memory_bytes: 256
N = int(raw_input())
a = map(int, raw_input().strip().split(" "))

if len(a) != N:
    raise Exception()

ans = 0

for i, u in enumerate(a):
    i = i + 1
    if i == a[u-1]:
        ans = ans + 1

ans = ans // 2
print(ans)

Measured memory_bytes: 11328
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())
#S = input()
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

answer = 0
for i in range(1, N + 1):
    answer += (N // i) * ((N // i) + 1) * i // 2

print(answer)

Measured memory_bytes: 67696
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 100000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	m, _ := strconv.Atoi(Scanner())
	a := make([]int, n)
	s := 0
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(Scanner())
		s += a[i]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	d := s / (4 * m)
	if s%(4*m) != 0 {
		d += 1
	}
	j := true
	for i := 0; i < m; i++ {
		if a[i] < d {
			j = false
		}
	}
	if j {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import sys
N=int(input())
b=list(map(int,input().split()))

ans=[]
for i in range(N):
    for j in range(N-1-i,-1,-1):
        if b[j]==j+1:
            ans.append(b.pop(j))
            break
        elif j==0:
            print('-1')
            sys.exit()
        else:
            continue

for i in range(N-1,-1,-1):
    print(ans[i])

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

using   namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define  all(v)       (v).begin(),(v).end()
#define  rall(v)      (v).rbegin(),(v).rend()
#define  pb           push_back  
#define  eb           emplace_back
#define  mp           make_pair
#define  ff           first
#define  ss           second
#define  pf           push_front
#define  bs           binary_search
#define  lb           lower_bound
#define  ub           upper_bound
#define  umap         unordered_map
#define  uset         unordered_set
#define  dec(x)       fixed<<setprecision(x)
#define  lcm(a,b)    (a*b/__gcd(a,b))

typedef  priority_queue<ll>  pq;
typedef  priority_queue<ll,vector<ll>,greater<ll>> pqmn;
typedef  pair<ll,ll> pll;

const    ll inf=LLONG_MAX;
const    ll mod=1e9+7;
const    ld pi=acos(-1);
                    
void solution(){
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<n;i++){
        for(int j=1;j*j<=i;j++){
            if(i%j==0){
                if((j==(i/j))) ans++;
                else ans+=2;
            }
        }
    }
    cout<<ans;


}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t;
    t=1;
   // cin>>t;
    while(t--){
        solution();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3648
import itertools
import math
ans = 0
for a,b,c in itertools.combinations_with_replacement(range(1,int(input())+1),3):
    G = math.gcd(a,math.gcd(b,c))
    if a==b==c:
        ans += G
    elif a==b or b==c:
        ans += 3*G
    else:
        ans += 6*G
    
print(ans)

Measured memory_bytes: 67912
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
using namespace std;
using ll = long long;


int main() {

	vector<ll> a(3);
	for (int i = 0; i < 3; ++i)
		cin >> a[i];

	sort(a.begin(), a.end());
	cout << a[2] * 10 + a[1] + a[0] << endl;

}

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

int main(){
	int a, b;
	cin >> a >> b;
    if(a*500 >= b){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double ret = 1;
		for(int i = 2; i <= n; i++) {
			ret *= i;
		}
		System.out.printf("%.0f\n", ret);
	}
}

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

using namespace std;

int n;
int a[100];

void printarr(int a[], int n) {
    for (int i=0;i<n;i++) {
        printf("%d", a[i]);
        if (i<n-1) printf(" ");
    }
    printf("\n");
}

int sort() {
    int j, i, v;
    for (i=0;i<n;i++) {
        v = a[i];
        j = i - 1;
        while (j >= 0 && v < a[j]) {
            a[j+1] = a[j]; 
            j--;
        }
        a[j+1] = v;
        printarr(a, n);
    }
    return 0;
}

int main() {
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    sort();
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    ll a[n+1];
    for(int i=1;i<=n;i++) cin >> a[i];
    ll sum[n+1];
    sum[0] = 0;
    for(int i=1;i<=n;i++){
        sum[i] = sum[i-1] + a[i];
    }
    vector<ll> v;
    for(int i=0;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            v.push_back(sum[j] - sum[i]);
        }
    }
    ll res = 0;
    for(ll i=40;i>=0;i--){
        // cout << i << endl;
        // for(int i=0;i<v.size();i++) cout << v[i] << " ";
        // cout << endl;
        ll cnt = 0;
        vector<ll> tmp;
        for(int j=0;j<v.size();j++){
            if(v[j] & (1LL << i)){
                cnt++;
                tmp.push_back(v[j]);
            }
        }
        if(cnt >= k){
            res += (1LL << i);
            v = tmp;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 6512
import java.util.*;

public class Main {

  private static void solve(int k) {
    Set<Long> set = new HashSet<>();
    long num = 7;
    long cnt = 1;
    while (set.add(num % k)) {
      if (num % k == 0) {
        System.out.println(cnt);
        return;
      }
      num = (num % k) * 10 + 7;
      cnt++;
    }
    System.out.println(-1);
  }

  public static void main(String[] args) {
    int k = scanner.nextInt();
    solve(k);
  }

  private static final Scanner scanner = new Scanner(System.in);
}


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

long gcd(long x,long y){
  long temp,tmp,temped,r;

  if(x<=y){
    temp = x;
    x = y;
    y = temp;
  }

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

  while(y != 0){
    tmp = y;
    y = x%y;
    //x = tmp;
    x = tmp;
  }

  return x;
}

long lcm(long x,long y){
  return y/gcd(x,y)*x;
}

int main(){
  long N,a,b,ans;
  cin>>N;
  cin>>a;
  ans = a;
  for(int i=1;i<N;i++){
    cin>>b;
    ans = lcm(ans,b);
    }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

pub fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let a: Vec<u64> = iter.take(n).map(|x| x.parse().unwrap()).collect();

    let mut left: Vec<u64> = vec![0;n+1];
    let mut right: Vec<u64> = vec![0;n+1];
    left[1] = a[0];
    right[n-1] = a[n-1];
    for i in 0..n {
        let j = n-1-i;
        if i>=1 {
            left[i+1] =  gcd(left[i], a[i]);
        }
        if j>=1 {
            right[j-1] = gcd(right[j], a[j-1]);
        }
    }
    let mut ret = 0u64;
    for i in 0..n {
        let k = if i == 0 {
            right[1]
        } else if i <= n-2 {
            gcd(left[i],right[i+1])
        } else {
            left[n-1]
        };
        ret = std::cmp::max(ret, k);
    }
    println!("{}", ret);
}


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

int main(){
  int N;
  cin >> N;
  vector<int> s(N);
  for(int i=0;i<N;i++){
    cin >> s.at(i);
  }
  int count=0;
  int tmp=1;
  for(int i=0;i<N;i++){
      if(s.at(i)!=tmp){
        count++;
      }else{
        tmp++;
      }
  }
  if(count==N)count=-1;
  cout << count << endl;  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

const int N = 2e6 + 100, mod = 1e9 + 7;
int fact[N];
void pre() {
	fact[0] = 1;
	for (int i = 1; i < N; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
	}
}

int mpow(int a, int b) {
	if (b == 0) return 1;
	int nesf = mpow(a, b / 2);
	if (b % 2 == 0) return nesf * nesf % mod;
	return nesf * a % mod * nesf % mod;
}

int get_ans(int a, int b) {
	return fact[a + b] * mpow(fact[a], mod - 2) % mod * mpow(fact[b], mod - 2) % mod;
}
signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	pre();
	int c, d;
	cin >> c >> d;
	if ((2 * c - d) % 3 != 0 || (2 * d - c) % 3 != 0 || 2 * d - c < 0 || 2 * c - d < 0) {
		cout << "0\n";
		return 0;
	}
	int a = (2 * c - d) / 3, b = (2 * d - c) / 3;
	cout << get_ans(a, b) << "\n";
}



Measured memory_bytes: 15872