akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};



int main(){
	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(m+1);
	rep(i,n){
		int x,y;
		cin >> x >> y;
        if(x>m) continue;
		a[x].push_back(y);
	}
	priority_queue<int> q;
	ll ans = 0;
	srepn(i,1,m){
		for(auto e:a[i]){
			q.push(e);
		}
		if(!q.size()) continue;
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
}

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

int main(void)
{
    long long H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    for (long long i = 0; i < H; i++)
    {
        cin >> S[i];
    }
    long long ans = 1000000000;
    for (long long bit = 0; bit < (1<<H-1); bit++)
    {
        long long gok = 0;
        long long N = 0;
        vector<long long> ord(H,0);
        for (long long i = 0; i < H-1; i++)
        {
            if (!(bit & (1<<i)))
            {
                ord[i+1] = ord[i];
            }
            else
            {
                ord[i+1] = ord[i] + 1;
                N++;
            }
        }

        long long add = 0;
        vector<long long> nums(N+1, 0);
        for (long long w = 0; w < W; w++)
        {
            long long ok = 0;
            vector<long long> one(N+1, 0);
            for (long long h = 0; h < H; h++)
            {
                one[ord[h]] += S[h][w] - '0';
                nums[ord[h]] += S[h][w] - '0';
                if (one[ord[h]] > K)
                {
                    gok = 1;
                }
                if (nums[ord[h]] > K)
                {
                    ok = 1;
                }
            }
            if (ok == 1)
            {
                add++;
                nums = one;
            }
        }
        if (gok == 0)
        {
            ans = min(ans, N+add);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3548
#include <iostream>
#include <cstdlib>

int main()
{
    long a, b;
    if (a > b) std::swap(a, b);
    std::cin >> a >> b;
    if (a == b) {
        std::cout << 0;
    }
    else if (a % 2 == 0 && b % 2 == 0 ||
             a % 2 == 1 && b % 2 == 1) {
                std::cout << (a + (b - a)/2);
             }
             else {
                std::cout << "IMPOSSIBLE";
             }

    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, Sum[2][2005][2005], alph[30], result;

int main()
{
    alph['B' - 'A'] = 0;
    alph['W' - 'A'] = 1;
    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; i++)
    {
        int x, y;
        char c;
        scanf("%d %d %c", &x, &y, &c);
        x = x % (2 * K) + 1;
        y = y % (2 * K) + 1;
        Sum[alph[c - 'A']][y][x]++;
    }
    for(int i = 1; i <= 2 * K; i++)
    {
        for(int j = 1; j <= 2 * K; j++)
        {
            for(int k = 0; k < 2; k++)
            {
                Sum[k][i][j] += Sum[k][i - 1][j] + Sum[k][i][j - 1] - Sum[k][i - 1][j - 1];
            }
        }
    }
    for(int i = 0; i < K; i++)
    {
        for(int j = 0; j < K; j++)
        {
            int blackHap = 0, whiteHap = 0, blackHap2 = 0, whiteHap2 = 0;
            blackHap = Sum[0][2 * K - i][2 * K - j] + Sum[0][K - i][K - j] * 2;
            blackHap = blackHap - Sum[0][K - i][2 * K - j] - Sum[0][2 * K - i][K - j];
            blackHap += Sum[0][K - i][2 * K] - Sum[0][K - i][2 * K - j];
            blackHap += Sum[0][2 * K][K - j] - Sum[0][2 * K - i][K - j];
            whiteHap = Sum[1][K - i][2 * K - j] + Sum[1][2 * K - i][K - j];
            whiteHap = whiteHap - Sum[1][K - i][K - j] * 2;
            whiteHap += Sum[1][2 * K - i][2 * K] - Sum[1][K - i][2 * K] - Sum[1][2 * K - i][2 * K - j] + Sum[1][K - i][2 * K - j];
            whiteHap += Sum[1][2 * K][2 * K - j] - Sum[1][2 * K][K - j] - Sum[1][2 * K - i][2 * K - j] + Sum[1][2 * K - i][K - j];
            if(i != 0 && j != 0)
            {
                blackHap = blackHap + Sum[0][2 * K][2 * K] - Sum[0][2 * K - i][2 * K] - Sum[0][2 * K][2 * K - j] + Sum[0][2 * K - i][2 * K - j];
            }

            whiteHap2 = Sum[1][2 * K - i][2 * K - j] + Sum[1][K - i][K - j] * 2;
            whiteHap2 = whiteHap2 - Sum[1][K - i][2 * K - j] - Sum[1][2 * K - i][K - j];
            whiteHap2 += Sum[1][K - i][2 * K] - Sum[1][K - i][2 * K - j];
            whiteHap2 += Sum[1][2 * K][K - j] - Sum[1][2 * K - i][K - j];
            blackHap2 = Sum[0][K - i][2 * K - j] + Sum[0][2 * K - i][K - j];
            blackHap2 = blackHap2 - Sum[0][K - i][K - j] * 2;
            blackHap2 += Sum[0][2 * K - i][2 * K] - Sum[0][K - i][2 * K] - Sum[0][2 * K - i][2 * K - j] + Sum[0][K - i][2 * K - j];
            blackHap2 += Sum[0][2 * K][2 * K - j] - Sum[0][2 * K][K - j] - Sum[0][2 * K - i][2 * K - j] + Sum[0][2 * K - i][K - j];
            if(i != 0 && j != 0)
            {
                whiteHap2 = whiteHap2 + Sum[1][2 * K][2 * K] - Sum[1][2 * K - i][2 * K] - Sum[1][2 * K][2 * K - j] + Sum[1][2 * K - i][2 * K - j];
            }
            result = max(result, max(blackHap + whiteHap, blackHap2 + whiteHap2));
        }
    }
    printf("%d", result);
}

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

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  for ( int i = 0; i < s.size(); i++ ) {
    char c = 'A' + (s[i]-'A'+n)%26;
    cout << c;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 1000000000
int x,y,ans;
int main(void){
	cin>>x>>y;
	if(x<=3)ans+=(4-x)*100000;
	if(y<=3)ans+=(4-y)*100000;
	if(x==1&&y==1)ans+=400000;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
a = list(map(int,input().split()))
b = deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n%2==1:
    b.reverse()

print(*b)

Measured memory_bytes: 25416
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    int g_a;
    int n;
    vector<int> v_i;
    scanf("%d", &n);
    for(int i = 1; i <=n; i++){
        scanf("%d", &g_a);
        v_i.push_back(g_a);
    }
    if(n == 0){printf("%d", 0); return 0;}
    if(v_i[0] != 0){printf("%d", 0); return 0;}
    if(n == 1 ){printf("%d", 1); return 0;}
    sort(v_i.begin(), v_i.end());
    if(v_i[1] == 0){printf("%d", 0); return 0;}
    if(v_i[1] != 1){printf("%d", 0); return 0;}
    long long to = 1;
    int p_count = 1;
    int c = 1;
    int c_count = 0;
    for(int i = 1; i < v_i.size(); i++){
        if (v_i[i] == c){
            to = (to*p_count)%998244353;
            c_count += 1;
            continue;
        }
        if(v_i[i] - c > 1){
        printf("%d", 0); return 0;
        }
        c = v_i[i];
        p_count = c_count;
        c_count = 1;
        to = (to*p_count)%998244353;
    }
    printf("%lld", to);
    return 0;

}



Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main()
{
	char c;
	cin >> c;
	
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
	{
		cout << "vowel" << endl;
	}
	else
	{
		cout << "consonant" << endl;
	}
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  for(int i = 0; i < S.size(); i++) {
    if(S.at(i) == '9') {
      S.at(i) = '1';
    }
    else {
      S.at(i) = '9';
    }
  }
  cout << S << endl;
  
}


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

using namespace std;

int main(){
    uint N,a[3000], sum=0;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        sum += a[i]-1;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,f,i;
	double b[110],c=101,d,e,x=0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%lf",&b[i]);
		x=x+b[i];
	}
	e=x/a;
	for(i=0;i<a;i++){
		if(e-b[i]<0){
			d=b[i]-e;
		}else{
			d=e-b[i];
		}
		if(c>d){
			f=i;
			c=d;
		}
	}
	printf("%d",f);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;
int32_t main() {
	int i,n,a=1,b=1,c=1,d=1,ans;
	cin>>n;
	for(i=1;i<=n;i++){
	    a*=10;
	    b*=9;
	    d*=8;
	    a%=mod;
	    b%=mod;
	    d%=mod;
	}
	c=b;
	ans=a-b-c+d;
	ans=(ans%mod+mod)%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3632
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0008
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.toInt)
      .map {
        case n if n > 9 * 4 => 0
        case n =>
          (for (a <- 0 to 9; b <- 0 to 9; c <- 0 to 9; d <- 0 to 9) yield a + b + c + d)
            .count(_ == n)
      }
      .foreach(println)
  }
}

Measured memory_bytes: 73212
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <stdio.h>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull a, ull b){return b? gcd(b, a%b):a;}
using namespace std;

const int h_mv[4] = {-1, +1, 0, 0};
const int w_mv[4] = {0, 0, -1, +1};
 
#define INF (100000000);
int maze[22][22];
 
 
void clear_maze()
{
	for (int h = 1; h <= 20; h++) {
		for (int w = 1; w <= 20; w++) {
			if (maze[h][w]!=-1) maze[h][w]=INF;
		}
	}
}
 
 
int main(void) {
	int H, W;
	cin >> H >> W;
	for (int h = 0; h <= H+1; h++) {
		maze[h][0] = maze[h][W+1] = -1;
	}
	for (int w = 0; w <= W+1; w++) {
		maze[0][w] = maze[H+1][w] = -1;
	}
	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			char c;
			cin >> c;
			if (c=='#') {
				maze[h][w] = -1;
			} else {
				maze[h][w] = INF;
			}
		}
	}
 
	int ans = 0;
	// スタート地点を決める
	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			if (maze[h][w]!=-1) {
				// 計算
				clear_maze();
				maze[h][w] = 0;
				queue <pair<int, int>> pos;
				pos.push(make_pair(h, w));
				while (pos.size() > 0) {
					pair <int, int> check = pos.front();
					pos.pop();
					int th = check.first;
					int tw = check.second;
					int steps = maze[th][tw];
					for (int i = 0; i < 4; i++) {
						int nh = th+h_mv[i];
						int nw = tw+w_mv[i];
						if ((maze[nh][nw]!=-1) && (maze[nh][nw] > steps+1)) {
							maze[nh][nw] = steps+1;
							pos.push(make_pair(nh, nw));
							ans = max(ans, steps+1);
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi pair<ll,ll>
#define fr freopen("in.txt","r",stdin)
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define frep(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define f first
#define s second
#define maxn 200011
ll gp[31][100011];
ll gm[31][100011];
ll cur[100];
int main() {
    int N,C,s,t,c;
    cin >> N >> C;
    rep(i,N) {
        cin >> s >> t >> c;
        gp[c][s]++;
        gm[c][t]--;
    }
    ll ans = 0;
    for(int t=1;t<=100000;t++) {
        ll sum =0;
        ll s = 0;
        for(int c=1;c<=C;c++) {
            cur[c]+=gp[c][t];
            sum += cur[c];
            sum += max(gm[c][t],-gp[c][t]);
        }

        ans = max(ans,sum+s);
        for(int c=1;c<=C;c++) {
            cur[c]+=gm[c][t];
        }
    }
    cout << ans;
    assert(ans!=0);
}

Measured memory_bytes: 47872
import heapq

def main():
    n, m = map(int, input().split())
    ab = [None] * m
    for i in range(m):
        ab[i] = list(map(int, input().split()))

    ab.sort()

    que = []
    cut_front = 0
    for x in ab:
        if que:
            if que[0] <= x[0]:
                cut_front += 1
                que.clear()
        heapq.heappush(que, x[1])
    if que:
        cut_front += 1
        que.clear()

    ab.sort(reverse=True, key=lambda x: x[1])

    cut_back = 0
    for x in ab:
        if que:
            if x[1] <= -que[0]:
                cut_back += 1
                que.clear()
        heapq.heappush(que, -x[0])
    if que:
        cut_back += 1
        que.clear()

    print(min(cut_front, cut_back))

if __name__ == '__main__':
    main()


Measured memory_bytes: 29376
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	pay := 0
	mx := 0
	for i := 0; i < n; i++ {
		var p int
		fmt.Scan(&p)

		pay += p
		if p > mx {
			mx = p
		}
	}
	pay -= mx / 2
	fmt.Println(pay)
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static int[][] map;
    public static int W;
    public static int H;
    public static int[] iAdj = {-1,-1,-1,0,0,1,1,1};
    public static int[] jAdj = {-1,0,1,-1,1,-1,0,1};
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            W = sc.nextInt();
            H = sc.nextInt();
            if (W == 0 && H == 0) break;
            
            int count = 0;
            map = new int[H][W];
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    map[i][j] = sc.nextInt();
                }
            }
            
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (map[i][j] > 0) {
                        count++;
                        floodFill(i,j);
                    }
                }
            }
            
            System.out.println(count);
        }
    }
    
    public static void floodFill(int i, int j) {
        if (i < 0 || i >= H || j < 0 || j >= W) return;
        if (map[i][j] == 0) return;
        map[i][j] = 0;
        for (int x = 0; x < 8; x++) {
            floodFill(i + iAdj[x], j + jAdj[x]);
        }
    }
}




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

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

template <typename T> void add(T& a, T b, int mod) {
	a = a + b;
	if (a >= mod)
		a -= mod;
}

class TaskH {
	const int mod = 1e9 + 7;
public:
	void solve(std::istream& in, std::ostream& out) {
		int H, W;
		in >> H >> W;
		vector<vector<char>> a(H, vector<char> (W));
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				in >> a[i][j];
			}
		}
		vector<vector<ll>> dp(H, vector<ll> (W, 0));
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i == 0 && j == 0) {
					dp[i][j] = 1;
					continue;
				}
				if (a[i][j] == '#') continue;
				if (i - 1 >= 0) add(dp[i][j], dp[i - 1][j], mod);
				if (j - 1 >= 0) add(dp[i][j], dp[i][j - 1], mod);
			}
		}
		out << dp[H - 1][W - 1];
	}
};


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	TaskH solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 12160
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    S = input().strip()

    cnt = 0
    for i in range(1, n):
        if S[i - 1] == S[i]:
            cnt += 1

    res = min(cnt + k * 2, n - 1)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3316
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
from numba import njit
def main():
    n = int(input())
    s = np.array(list(read().rstrip()))

    r = np.sum(s == 'R')
    g = np.sum(s == 'G')
    b = np.sum(s == 'B')
    @njit
    def f(s):
        ret = 0
        for i1 in range(n):
            for i2 in range(i1 + 1, n):
                i3 = i2 * 2 - i1
                if i3 <= n - 1:
                    if s[i1] != s[i2] and s[i1] != s[i3] and s[i2] != s[i3]:
                        ret += 1
        return ret

    res = r * g * b - f(s)
    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 113452
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N + 1];
    int[] B = new int[N];
    for (int i = 0; i < A.length; i++) {
      A[i] = sc.nextInt();
    }
    for (int i = 0; i < B.length; i++) {
      B[i] = sc.nextInt();
    }

    long ans = 0;
//    for (int i = 0; i < N; i++) {
//      int life = B[i] - A[i];
//      if (life >= 0) {
//        ans += A[i];
//        if (A[i + 1] >= life) {
//          ans += life;
//          A[i + 1] -= life;
//        } else {
//          ans += A[i + 1];
//          A[i + 1] = 0;
//        }
//      } else {
//        ans += B[i];
//      }
//    }

    for (int i = 0; i < N; i++) {
      if (B[i] > A[i]) {
        B[i] -= A[i];
        ans += A[i];
        ans += Math.min(A[i+1], B[i]);
        A[i+1] -= Math.min(A[i+1], B[i]);
      } else {
        ans += B[i];
      }
    }
    System.out.println(ans);
  }
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if (min(max(abs(a-b),abs(b-c)),abs(a-c))<=d){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 1e5+5;

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

template <class T> bool isPrime(T x) {
	for (T d = 2; d * d <= x; d++) { if (x % d == 0) return false; }
	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		
	long long n, m, p, q, w;
	cin >> n >> m;
	p = max(n, m);
	q = min(n, m);
	for (int i = 1; true; ++i) {
		w = p * i;
		if (w % q == 0) {
			cout << w << '\n';
			return 0;
		}
	}
}
		

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


int main(){
  

  int n,k;
  cin>>n>>k;
  
  int answer=0;
  
  int tmp=0;
  
  while (n-1>tmp){
    tmp+=k-1;
    answer++;
  }
  
  cout<<answer<<endl;
  
  

  
  

  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a[200005];
const int mod=1e9+7;
int fastpow(int a,int n)
{
    int res=1;
    int temp=a;
    while(n)
    {
        if(n&1)
            res=(1LL*res*temp)%mod;
        temp=(1LL*temp*temp)%mod;
        n>>=1;
    }
    return res%mod;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if(n==1)
        cout<<(1LL*2*a[0])%mod;
    else
    {
        sort(a,a+n);
        int res=0;
        int ans=fastpow(2,n-2);
        int ens=(1LL*ans*2)%mod;
        int rns=(1LL*ens*2)%mod;
        for(int i=n-1;i>=0;i--)
        {
            res=(1LL*res+(1LL*a[i]*ens)%mod)%mod;
            ens=(1LL*ens+ans)%mod;
        }
        res=(1LL*res*rns)%mod;
        cout<<res;
    }
    return 0;
}


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

int main(){
    string s; cin >> s;
    string f5, f6, f7;
    string ans = "YES";
    
    while(true){
        int n = s.size();
        if(s.substr(n - 5, 5) == "dream" || s.substr(n-5, 5) == "erase"){
            s.erase(n - 5, 5);
            
        }else if(s.substr(n-6, 6) == "eraser"){
            s.erase(n - 6, 6);
            
        }else if(s.substr(n-7, 7) == "dreamer"){
            s.erase(n - 7, 7);
            
        }else{
            ans = "NO";
            break;
        }
        if(s.size() == 0){
            break;
        }
    }
    
    cout << ans << endl;
}




Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;

const int maxn = 2010;
int n, m, q;
int es[maxn][maxn], et[maxn][maxn], poi[maxn][maxn];
char str[maxn][maxn];

int main(){
	//freopen("in.txt", "r", stdin);
	scanf("%d%d%d", &n, &m, &q);
	//cerr<<"nd "<<n<<' '<<m<<' '<<q<<endl;
	for(int i =1;i <= n;++i){
		scanf("%s", str[i] + 1);
		for(int j = 1;j <= m;++j){
			if(j > 1)es[i][j] = es[i][j - 1] + (str[i][j - 1] == '1' && str[i][j] == '1');
			if(i > 1)et[i][j] = et[i - 1][j] + (str[i - 1][j] == '1' && str[i][j] == '1');
			poi[i][j] = poi[i][j - 1] + poi[i - 1][j] + (str[i][j] == '1') - poi[i - 1][j - 1];
		}	
	}
	//cerr<<"reaad "<<endl;
	int lx, ly, rx, ry;
	while(q--){
		scanf("%d%d%d%d", &lx, &ly, &rx, &ry);
	//	cerr<<"res "<<lx<<' '<<ly<<' '<<rx<<' '<<ry<<endl;
		int point = poi[rx][ry] + poi[lx - 1][ly - 1] - poi[lx - 1][ry] - poi[rx][ly - 1], edge = 0;
		for(int i = lx;i <= rx;++i)edge += es[i][ry] - es[i][ly];
		for(int i = ly;i <= ry;++i)edge += et[rx][i] - et[lx][i];
		printf("%d\n", point - edge);
	}
	//while(1);
	return 0;
}


Measured memory_bytes: 52992
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n, m;
    cin >> n;
    map<string, int> b;
    REP(i, n) {
        string s;
        cin >> s;
        b[s]++;
    }
    cin >> m;
    map<string, int> r;
    REP(i, m) {
        string s;
        cin >> s;
        r[s]++;
    }
    map<string, int> x;
    FOR(i, b) {
        x[i->first] = i->second - r[i->first];
    }

    int res = 0;
    FOR(i, x) {
        res = max(res, i->second);
    }

    cout << res << endl;
}


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

using namespace std;

int main(void){
  string n;
  cin >> n;
  
  for(int i = 0 ; i < 3 ; i++){
    if(n[i] == '1') n[i] = '9';
    else if(n[i] == '9') n[i] = '1';
  }
  
  cout << n << endl;
  
  return 0;
}

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

template<class T, class E, class Compare = less<T>>
struct skew_heap {
	using F = function<T(T, E)>;
	using G = function<E(E, E)>;
	using value_type = T;
	using operator_type = E;
private : 
	const Compare c;
	const F f;
	const G g;
	const operator_type ie;
	size_t sz;

	struct node_data {
	public : 
		value_type val;
		operator_type add;
		unique_ptr<node_data> left_node, right_node;
		node_data (const value_type &x, const operator_type &e) :
			val(x), add(e), left_node(nullptr), right_node(nullptr) { }
	};

	using node = unique_ptr<node_data>;

	node root;

	node propagate (node x) {
		if (not x) return (move(x));
		if ((x->add) == ie) return (move(x));
		if (x->left_node) {
			(x->left_node->add) = g(x->left_node->add, x->add);
		}
		if (x->right_node) {
			(x->right_node->add) = g(x->right_node->add, x->add);
		}
		(x->val) = f(x->val, x->add);
		(x->add) = ie;
		return (move(x));
	}

public : 

	skew_heap (const F &f, const G &g, const operator_type &ie) : 
		f(f), g(g), c(), ie(ie), sz(0), root(nullptr) { }

	skew_heap (skew_heap&& rhs) noexcept :
		f(rhs.f), g(rhs.g), c(rhs.c), ie(rhs.ie), sz(rhs.sz), root(move(rhs.root)) { }

	node meld (node a, node b) {
		if (not a) return (move(b));
		if (not b) return (move(a));
		if (not c((a->val), (b->val))) a.swap(b);
		a = propagate(move(a));
		(a->right_node) = meld(move(a->right_node), move(b));
		(a->right_node).swap(a->left_node);
		return (move(a));
	}

	constexpr size_t size () const noexcept {
		return (sz);
	}

	constexpr bool empty () const noexcept {
		return (not sz);
	}

	const value_type& top () {
		assert(not empty());
		root = propagate(move(root));
		return (root->val);
	}

	void pop () {
		assert(not empty());
		root = propagate(move(root)); sz--;
		root = meld(move(root->left_node), move(root->right_node));
	}

	void push (const value_type &x) {
		root = propagate(move(root)); sz++;
		root = meld(move(root), make_unique<node_data>(node_data(x, ie)));
	}

	void add (const operator_type &x) {
		if (root) (root->add) = g(root->add, x);
	}

	void meld (skew_heap &s) {
		(this->sz) += (s.sz); s.sz = 0;
		(this->root) = meld(move(this->root), move(s.root));
	}

};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	auto f = [](int a, int b) { return (a + b); };
	skew_heap<int, int, greater<int>> skew(f, f, 0);
	
	string query;
	while (true) {
		cin >> query;
		if (query == "insert") {
			int e;
			cin >> e;
			skew.push(e);
		} else if (query == "extract") {
			cout << skew.top() << '\n';
			skew.pop();
		} else {
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 34500
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#define pow2(a) ((a)*(a))
#define inf (1<<29)
using namespace std;

const double r = 6378.1;

struct Point3
{
  double x,y,z;
  Point3(double x=inf,double y=inf,double z=inf):x(x),y(y),z(z){}
};

Point3 getPoint3(double a,double b)
{//see P.133
  return Point3(r*sin(a)*cos(b),r*sin(a)*sin(b),r*cos(a));
}

double getArg(double a,double b,double c)
{
  return acos((b*b+c*c-a*a)/(2.0*b*c));
}

int main()
{
 
  double a,b,c,d;
  while(true)
    {
      cin >> a >> b >> c >> d;
      if(a == -1 && b == -1 && c == -1 && d == -1)break;
      a = 90 - a;
      a = a*M_PI/180.0;
      b = b*M_PI/180.0;
      c = 90 - c;
      c = c*M_PI/180.0;
      d = d*M_PI/180.0;
      Point3 p1,p2;
      p1 = getPoint3(a,b);
      p2 = getPoint3(c,d);

      double dist = sqrt(pow2(p1.x-p2.x)+pow2(p1.y-p2.y)+pow2(p1.z-p2.z));
      double arg = getArg(dist,r,r);

      cout << (int)round(r * arg) << endl;

    }
  return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define pb  push_back
#define mb  make_pair
#define fi  first
#define se  second

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1000000007;

void solve()
{
    int n;
    cin >> n;
    ll s[n], d[n];
    ll t;
    for(int i = 1; i <= n; i++)
    {
        cin >>  t;
        s[i-1]  = i + t;
        d[i-1]  = i - t;
    }
    sort(s,s+n);
    sort(d,d+n);
    ll res = 0;
    for(int i = 0; i < n; i++)
    {
        auto l = lower_bound(d,d+n,s[i]) - s;
        auto u = upper_bound(d,d+n,s[i]) - s;
        res += u - l;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
	return 0;
}


Measured memory_bytes: 6792
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=100+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
}
















































int n,m;
int a[N];
void input()
{
	n=read<int>(),m=read<int>();
	Fordown(i,m,1)a[i]=read<int>();
}
const int mo=1e9+7;
int dp[18][1<<16];
int mc[1<<16],inv[1<<16];
ll power(ll x,int y)
{
	ll res=1;
	for(;y;x=x*x%mo,y>>=1)if(y&1)res=res*x%mo;
	return res;
}
void init()
{
	mc[0]=inv[0]=1;
	int Max=(1<<n)-1;
	For(i,1,Max)mc[i]=1ll*mc[i-1]*i%mo;
	inv[Max]=power(mc[Max],mo-2);
	Fordown(i,Max-1,1)inv[i]=1ll*inv[i+1]*(i+1)%mo;
}
void add(int &x,int y)
{
	x+=y;x-=(x>=mo?mo:0);
}
ll C(int x,int y){return 1ll*mc[x]*inv[y]%mo*inv[x-y]%mo;}
int popcnt[1<<16];
void work()
{
	dp[0][0]=1;
	int Max=(1<<n)-1;
	int tot=1<<n;
	int res;
	For(i,1,m)For(j,0,Max)if(dp[i-1][j])
	{
		add(dp[i][j],dp[i-1][j]);
		res=tot-a[i]-j;
		for(int k=0;k<n;k++)if(!((j>>k)&1))
		{
			if(res>=((1<<k)-1))add(dp[i][j|(1<<k)],1ll*dp[i-1][j]*C(tot-a[i]-j,(1<<k)-1)%mo*mc[1<<k]%mo);
		}
	}
	For(i,1,Max)popcnt[i]=popcnt[i>>1]+(i&1);
	int ans=0;
	//cerr<<mc[Max]<<endl;
	For(i,0,Max)
	{
	//	cerr<<i<<' '<<dp[m][i]<<endl;
		res=1ll*dp[m][i]*mc[tot-i-1]%mo;
		if(popcnt[i]&1)add(ans,mo-res);//,cerr<<i<<' '<<dp[m][i]<<endl;
		else add(ans,res);
	}
	write(1ll*ans*(1<<n)%mo,'\n');
}
int main()
{
//	file();
	input();
	init();
	work();
	return 0;
}

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

int main(){
    int A,B,C;
    int K;

    cin >> A >> B >> C >> K;

    for(int i=1;i<=K;i++){
        if(A>=B){
            B = B*2;
        }else if(B>=C){
            C = C*2;
        }
    }
    if(A<B && B<C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<bitset>

const int N=101,MOD=998244353;
typedef long long ll;
typedef unsigned long long ull;
typedef std::bitset<N> bits;

std::map<ull,int> f;

ull calc(bits &A,int len)
{
	ull ret=817;
	for(int i=0;i<len;i++)
		ret=ret*2333+(int)A[i];
	return ret;
}

int n;

int dfs(bits A,int len)
{
	if(!len)return 1;

	ull h=calc(A,len);
	if(f.count(h))return f[h];

	int ret;
	ret=(ll)(1+A[0])*dfs(A>>1,len-1)%MOD;

	bits B;

	for(int i=1;i<=len;i++)
	{
		B=A;
		for(int j=2;i*j<=len;j++)
		{
			B&=(A>>(i*(j-1)));
			ret=(ret+(ll)dfs(B,i)*dfs(A>>(i*j),len-i*j))%MOD;
		}
	}

	f[h]=ret;
	return ret;
}

void solve()
{
	static char tmp[N];
	bits A;A.reset();
	scanf("%s",tmp);
	n=strlen(tmp);
	for(int i=0;i<n;i++)
		A[i]=tmp[i]-'0';
	f.clear();
	printf("%d\n",dfs(A,n));
}

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


Measured memory_bytes: 3072
import java.util.Scanner;

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

		for(int i = 0; i < n; i++) {
			String str = sc.next();
			if(str.equals("Y")) {
				System.out.println("Four");
				return;
			}
		}
		System.out.println("Three");
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL)
#define CASES  ll t; cin>>t; while(t--)

int main() {
    FASTER;
    ll x,p,i,j,k;
    bool flag;


    cin>>x;
    flag=false;
    for(i=1; i<=x; i++) {
        if(pow(i,5)>=x) {
            for(j=i; j>-i+1; j--) {
                for(k=j-1; k>-i; k--) {
                    if(pow(j,5)-pow(k,5)==x) {
                        flag=true;
                        cout<<j<<" "<<k<<endl;
                        break;
                    }
                }
                if(flag)
                    break;
            }
            if(flag)
                break;
        }
    }
}


Measured memory_bytes: 3988
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    String color = cin.next();

    int mark = 0;
    int count = 0;
    for (int i=0;i<color.length();i++) {
      char item = color.charAt(i);
      if (mark == item - '0') {
        count++;
      }

      mark = mark == 0? 1:0;

    }

    int res = count <= color.length() - count? count:color.length()-count;
    System.out.println(res);

  }

}

Measured memory_bytes: 24916
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>

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

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;

    string c = a + b;
    int v = stoi(c);

    cout << ((v == (int)sqrt(v) * (int)sqrt(v)) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
# print(n,m)

V = [set() for _ in range(n)]
for a, b in [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]:
    V[a].add(b)
    V[b].add(a)
# print(V)

from collections import deque
G = [-1] * n
for s in range(n):
    dq = deque([s])
    while dq:
        p = dq.popleft()
        if G[p] >= 0: continue
        G[p] = s
        for c in V[p]:
            if G[c] >= 0: continue
            dq.append(c)
# print(G)

C = dict()
for g in G:
    if not g in C: C[g] = 0
    C[g] += 1
# print(C)

print(max(C.values()))


Measured memory_bytes: 93884
N=input()
if len(N)==1:
    print(int(N))
elif len(N)==2:
    print(9)
elif len(N)==3:
    print(9+int(N)-99)
elif len(N)==4:
    print(9+900)
elif len(N)==5:
    print(9+900+int(N)-9999)
else:
    print(9+900+90000)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 62;
constexpr double eps = (1e-9);


constexpr int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return x ? mod - x : 0;}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}

  friend ostream& operator << (ostream& os, const mint& m) noexcept {
    return os << m.x;
  }

  friend istream& operator<< (istream& is, mint& m) noexcept {
    return is >> m.x;
  }
};


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

  ll n;
  cin >> n;

  vector<ll> num0(61, 0);
  vector<ll> num1(61, 0);

  for (ll i = 0; i < n; i++) {
    ll a;
    cin >> a;
    for (ll j = 0; j < num0.size() - 1; j++) {
      if ((a >> j) & 1) num1[j]++;
      else num0[j]++;
    }
  }

  mint ans = 0;

  for (int i = 0; i < num0.size(); i++) {
    mint tmp = 1LL << i;
    tmp *= num0[i];
    tmp *= num1[i];
    ans += tmp;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3668
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

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

int main(){
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	ll ans = n * m / gcd(n, m);
	ll u, v;
	u = ans / n;
	v = ans / m;
	ll w = u * v / gcd(u, v);
	ll p = w / u;
	ll q = w / v;
	ll cnt1 = 0, cnt2 = 0;
	REP(i, 1, SIZE(s) / p) {
		if(s[cnt1] != t[cnt2]){
			cout << -1 << endl;
			return 0;
		}
		else {
			cnt1 += p;
			cnt2 += q;
		}
	}

	cout << ans << endl;

}



Measured memory_bytes: 512
import sys
A,B,C = map(int,input().split())

if A < 0 or A > 100 or B < 0 or B > 100:
    sys.exit()
if not ( C >= 0 or C < B ):
    sys.exit()

tmp = 0
result = "NO"
for I in range(B):
    tmp = A * I % B
    if tmp % B == C:
        result = "YES"

print(result)

Measured memory_bytes: 9176
import pprint
from collections import deque
N=int(input())
l2=[]
bit2=50
bit5=22
#table=[[0 for _ in range(20)] for _ in range(15)]
#table=[[0 for _ in range(45)] for _ in range(20)]
table=[[0 for _ in range(bit2)] for _ in range(bit5)]
for i in range(N):
    n=list(input())
    #print(n)
    cnt=9
    d=deque()
    flag=1
    for i in range(len(n)):
        if n[i]==".":
            flag=0
        else:
            d.append(n[i])
            if flag==0:
                cnt=cnt-1
    for i in range(cnt):
        d.append("0")
    n=int("".join(d))
    #print(n)
    count2=0
    count5=0
    #print(n,kake)
    while n%2==0:
        n=n//2
        count2=count2+1
    while n%5==0:
        n=n//5
        count5=count5+1
    table[count5][count2]=table[count5][count2]+1
    l2.append([count2,count5])
#pprint.pprint(table)
#print(l2)
ans=0
for i in range(bit5):
    for j in range(bit2):
        num=table[i][j]
        min2=max(0,18-j)
        min5=max(0,18-i)
        cnt=0
        if num>0:
            #print(min2,min5,i,j,num)
            for k in range(min5,bit5):
                for l in range(min2,bit2):
                    cnt=cnt+table[k][l]
            if (min2<=j)and(min5<=i):
                cnt=cnt-1
            ans=ans+num*cnt
            #print(ans)
print(ans//2)



Measured memory_bytes: 101988
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  ll a[LIMIT2][2];
  char s[LIMIT1];
  ll dp[LIMIT1][2];
  
  scanf("%lld",&n);
  rep(j,2){
    rep(i,n) scanf("%lld",&a[i][j]);
  }
  per(j,2){
    per(i,n){
      if(j==1&&i==n-1){
        dp[i][j] = 0;
      }else if(j==1){
        dp[i][j] = dp[i+1][j];
      }else if(i==n-1){
        dp[i][j] = dp[i][j+1];
      }else{
        dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
      }
      dp[i][j] += a[i][j];
    }
  }
  printf("%lld",dp[0][0]);
  return 0;
}



Measured memory_bytes: 2176
h,w=map(int,input().split())
b=[list(input()) for _ in range(h)]
for i in range(h-1,-1,-1):
  if b[i].count('.')==w:
    del b[i]
    h-=1
for i in range(w-1,-1,-1):
  count=0
  for j in range(h):
    if b[j][i]=='.':
      count+=1
  if count==h:
    for j in range(h):
      tmp=b[j][:i]+b[j][i+1:]
      b[j]=tmp
for i in range(h):
  print(''.join(b[i]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ui unsigned int



void build_tree(vector<ui>& tree, vector<ui>& v,
		ui node, ui i, ui j) {

  	if (i == j) {

		tree[node] = v[i];
		return;
	}
	
	build_tree(tree, v, node*2, i, (i+j)/2); 
	build_tree(tree, v, node*2+1, 1+(i+j)/2, j);
	
	tree[node] = min(tree[node*2], tree[node*2+1]);
}



void update(vector<ui>& tree, ui node,
		ui index, ui val, ui i, ui j) {

	if (index<i || index>j) return;
	if (i==j){ tree[node]=val; return; }

	update(tree, 2*node, index, val, i, (i+j)/2);
	update(tree, 2*node+1, index, val, (i+j)/2+1, j);
	tree[node] = min(tree[2*node], tree[2*node+1]);
}



ui query_tree(vector<ui>& tree, ui node,
	   	ui i, ui j, ui start, ui end) {
	
	if (i > end || j < start) return -1;
	if (i >= start && j <= end) return tree[node];

	return  min(
				query_tree(tree, 2*node, i, (i+j)/2, start, end),
				query_tree(tree, 2*node+1, (i+j)/2+1, j, start, end));
}


int main(){

	ui n, q, in, val, b;
	scanf("%u %u", &n, &q);
	vector<ui> v(n+1,pow(2,31)-1), tree(pow(2,ceil(1+log2(n))));
	build_tree(tree, v, 1, 1, n);



	for (int i=0; i<q; i++){
		
		scanf("%u %u %u", &b, &in, &val);

		if (b == 0) update(tree, 1, in+1, val, 1, n);
		else cout << query_tree(tree, 1, 1, n, in+1, val+1) << endl;
	}

	return 0;
}

Measured memory_bytes: 4412
#include <iostream>
#include <stdio.h>
#include <cstring>
#define ll long long
using namespace std;

const int MAXN = 100100;
pair<char, int> query[MAXN];

int par[MAXN], cnt[MAXN];

int getPar(int v) {
    if (cnt[v]) return v;
    else return par[v] = getPar(par[v]);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    while (cin >> N >> Q) {
        if (N==0 && Q==0) break;
        memset(par, -1, sizeof(par));
        memset(cnt, 0, sizeof(cnt));
        for (int i = 1; i < N; i++) {
            int p;
            cin >> p; p--;
            par[i] = p;
        }
        cnt[0] = 1;
        for (int i = 0; i < Q; i++) {
            cin >> query[i].first >> query[i].second;
            query[i].second--;
            if (query[i].first == 'M') {
                cnt[query[i].second]++;
            }
        }
        ll ans = 0;
        for (int i = Q-1; i >= 0; i--) {
            char c = query[i].first;
            int v = query[i].second;
            if (c == 'M') cnt[v]--;
            else ans += getPar(v)+1;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 4844
/*
power code taken from geeks for geeks
*/

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 200001
using namespace std;
typedef long long ll;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}


bool comp(pair<ll,ll>& a, pair<ll,ll>& b){
    return a.first<b.first;
}

void swap(ll& s1, ll &s2){
    ll temp=s1;
    s1=s2;
    s2=temp;
}
ll gcd(ll a, ll b){
    if(b==0){
        return a;
    }
    return gcd(b, a%b);
}


void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll cnt[3][n];
    unordered_map<char, int>map_col;
    map_col['R']=0;
    map_col['G']=1;
    map_col['B']=2;
    memset(cnt, 0, sizeof(cnt));
    for(ll i=n-1;i>=0;i--){
        cnt[map_col[s[i]]][i]=1;
    }
    for(ll i=0;i<3;i++){
        for(ll j=n-2;j>=0;j--){
            cnt[i][j]+=cnt[i][j+1];
        }
    }
    unordered_map<string, char>map_str;
    map_str["GR"]='B';
    map_str["BR"]='G';
    map_str["BG"]='R';
    ll ans=0;
    for(ll i=0;i<n;i++){
        char ch=s[i];
        for(ll j=i+1;j<n;j++){
            if(s[j]==ch){
                continue;
            }
            string temp=string(1, ch);
            temp+=string(1, s[j]);
            sort(temp.begin(), temp.end());
            // cout<<temp<<endl;
            char c2=map_str[temp];
            if(j+1>=n){
                continue;
            }
            ll t2=cnt[map_col[c2]][j+1];
            if(j+j-i<n && s[j+j-i]==c2){
                t2--;
            }
            ans+=t2;
        }
    }
    cout<<ans<<endl;
}


int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t=1;
    
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define pb push_back

#define f(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define int long long
using namespace std;
#define mod 1000000007
signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int h, w, m, x, y, ans, maxi = 0, maxi1 = 0, res = 0, k, k1;
    cin >> h >> w >> m;
    map<int, int>map1, map2;
    map<pair<int, int>, int>visit;
    while(m--)
    {
        cin >> x >> y;
        map1[x]++;
        map2[y]++;
        visit[ {x, y}] = 1;
        if(map1[x] > maxi)
        {
            maxi = map1[x];
            k = x;
        }
        if(map2[y] > maxi1)
        {
            maxi1 = map2[y];
            k1 = y;
        }
    }

    for(int i = 0; i <= h; i++)
    {
        ans = maxi1 + map1[i];
        if(visit[ {i, k1}])
        {
            ans--;
        }
        res = max(res, ans);
    }
    for(int i = 0; i <= w; i++)
    {
        ans = maxi + map2[i];
        if(visit[ {k, i}])
        {
            ans--;
        }
        res = max(res, ans);
    }
    cout << res << endl;
    return 0;
}




Measured memory_bytes: 97376
b = input()
ans = ''
for i in range(len(b)):
    if b[i] == 'A':
        ans = ans + 'T' 
    elif b[i] == 'T':
        ans = ans + 'A'
    elif b[i] == 'G':
        ans = ans + 'C'
    elif b[i] == 'C':
        ans = ans + 'G'
        
print(ans)

Measured memory_bytes: 2940