akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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 ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,c,k;cin >> r >> c >> k;
    vector<vector<ll>> a(r+1,vector<ll>(c+1,-1));
    REP(i,k){
        int x,y,v;cin >> x >> y >> v;
        x--,y--;
        a[x][y]=v;
    }
    vector<vector<vector<ll>>> dp(r+1,vector<vector<ll>>(c+1,vector<ll>(5,-1)));
    dp[0][0][0]=0;
    if(a[0][0]>0) dp[0][0][1]=a[0][0];
    REP(i,r){
        REP(j,c){
            REP(l,4){
                if(dp[i][j][l]==-1) continue;
                chmax(dp[i+1][j][0],dp[i][j][l]);
                chmax(dp[i][j+1][l],dp[i][j][l]);
                if(a[i+1][j]>0){
                    chmax(dp[i+1][j][1],dp[i][j][l]+a[i+1][j]);
                }
                if(a[i][j+1]>0){
                    chmax(dp[i][j+1][l+1],dp[i][j][l]+a[i][j+1]);
                }
            }
        }
    }
    ll ans=0;
    REP(i,4){
        chmax(ans,dp[r-1][c-1][i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 706544
l,r = map(int, input().split())

if r-l >= 2019:
  print(0)
  exit()

ans = float('inf')
for i in range(l, r):
  for j in range(i+1, r+1):
  	t = i*j%2019
  	ans = min(ans,t)
print(ans)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**6)

int1 = lambda x: int(x) - 1
n, m = map(int, input().split())
if m % 2:
  print(-1); exit(0)

l = [tuple(map(int1, input().split())) for _ in range(m)]
G = [list() for _ in range(n)]

ps = [-1]*n
tot = [0]*n

def find(x):
  if ps[x] < 0:
    return x
  ps[x] = find(ps[x])
  return ps[x]

def unite(u, v):
  u = find(u)
  v = find(v)
  if ps[u] > ps[v]:
    u, v = v, u
  ps[u] += ps[v]
  ps[v] = u
  return

def same(u, v):
  return find(u) == find(v)

for u, v in l:
  if same(u, v):
    print(u+1, v+1)
    tot[u] += 1
  else:
    G[u].append(v)
    G[v].append(u)
    unite(u, v)

def dfs(v, p):
  for u in G[v]:
    if u == p: continue
    dfs(u, v)
  if p >= 0:
    if tot[v] % 2:
      print(v+1, p+1)
      tot[v] += 1
    else:
      print(p+1, v+1)
      tot[p] += 1
  return

dfs(0, -1)

Measured memory_bytes: 105072
#include <iostream>
using namespace std;
int main()
{
    int n, m, c, ans = 0;
    int a, b[20];
    cin >> n >> m >> c;
    for(int j = 0; j < m; j++){
        cin >> b[j];
    }
    for(int i = 0; i < n; i++){
        int sum = c;
        for(int j = 0; j < m; j++){
            cin >> a;
            sum += a * b[j];
        }
        if(sum > 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 1000;

int n;
int c[N];

struct edge{ int to,cost; };
vector<edge> G[N];

int dfs(int v, int par){
    int ret = 0;
    for(const auto &e:G[v])if(e.to != par){
        int add = e.cost;
        if(c[e.to] == 0) add = min(add, dfs(e.to, v));
        ret += add;
    }
    return ret;
}

int main(){
    cin >>n;
    for(int i=1; i<n; ++i) cin >>c[i];

    rep(i,n-1){
        int u,v,p;
        cin >>u >>v >>p;
        G[u].pb({v,p});
        G[v].pb({u,p});
    }

    cout << dfs(0,-1) << endl;
    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
const int maxn = 100 + 10;
char cmd[20];
int d;
int n;
struct Node{
	int key;
	Node* left;
	Node* right;
};

int cnt;
Node *root = NULL;
void in_order(Node *p){
	if (p == NULL) return;
	in_order(p->left);
	printf(" %d", p->key);
	in_order(p->right);
}

void pre_order(Node *p){
	if (p == NULL) return;
	printf(" %d", p->key);
	pre_order(p->left);
	pre_order(p->right);
}

void print(){
	in_order(root);
	printf("\n");
	pre_order(root);
	printf("\n");
}

void post_delete(Node *p){
	if (p == NULL) return;
	post_delete(p->left);
	post_delete(p->right);
	free(p);
}

void insert(int k){
	Node * node = (Node *)malloc(sizeof(Node));
	node->key = k;
	node->left = NULL;
	node->right = NULL;
	Node *p = NULL;
	Node *q = root;
	while (q != NULL){
		p = q;
		if (p->key>k){
			q = q->left;
		}else q = q->right;
	}
	if (p == NULL){
		root = node;
	}else if (p->key>k){
		p->left = node;
	}else p->right = node;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i<n; i++){
		scanf("%s", cmd);
		switch (cmd[0]) {
		case 'i': {
			scanf("%d", &d);
			insert(d);
			break;
		}case 'p': {
			print();
			break;
		}
		}
	}
	post_delete(root);
	return 0;
}

Measured memory_bytes: 18764
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int n;
  	cin >> n;
  	ll ans = 1;
  	ll temp = 2;
  	rep(i,n-1) {
		ans += temp;
      	temp = ans - temp;
    }
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		int N; input_returnner(int N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(int N) { return std::move(input_returnner(N)); }
}

void solve();
/// ---template---

signed main(void) {
	SETUP;
	solve();
	return 0;
}

#define int ll

void solve() {
	int N = in();
	vector<ll> X = in(N);
	int M, K; cin >> M >> K;
	vector<int> A(M); for (auto &a : A) a = in() - 1;

	vector<int> d(N - 1);
	REP(i, N - 1) d[i] = X[i + 1] - X[i];

	vector<int> rep(N - 1);
	REP(i, rep.size()) rep[i] = i;

	for(auto &a:A) {
		swap(rep[a], rep[a - 1]);
	}

	vector<int> res(N - 1);
	REP(i, res.size()) res[i] = i;

	while (K > 0) {
		if (K & 1) {
			REP(i, res.size()) {
				res[i] = rep[res[i]];
			}
		}
		vector<int> a = rep;
		REP(i, rep.size()) {
			rep[i] = a[a[i]];
		}
		K >>= 1;
	}

	vector<double> ans(N);
	ans[0] = X[0];
	cout << ans[0] << endl;
	FOR(i, 1, N) {
		ans[i] = ans[i - 1] + d[res[i - 1]];
		cout << ans[i] << endl;
	}

}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  int x;
  cin >> x;
  
  if (x < 1200) 
    cout << "ABC" << endl;
  else 
    cout << "ARC" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if (a1 + a2 + a3 >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	
	int Alice,Bob;
        
        cin>>Alice>>Bob;
	if(Alice==Bob){
		cout<<"Draw"<<endl;
	}
	if(Alice!=1 && Alice<Bob){
			cout<<"Bob"<<endl;
	}
	if(Bob!=1 && Alice>Bob){
			cout<<"Alice"<<endl;
	}
	if(Bob==1 && Alice!=1){
			cout<<"Bob"<<endl;
	}
	if(Alice==1 && Bob!=1){
			cout<<"Alice"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,j;
  char a[8][8];
  while(scanf("%s",a[0])!=EOF){
    for(i=1;i<8;i++){
      scanf("%s",a[i]);
    }
    for(i=0;i<8;i++){
      for(j=0;j<8;j++){
	if(a[i][j]=='1'&&a[i][j+1]=='1'&&a[i+1][j]=='1'&&a[i+1][j+1]=='1'){
	  printf("A\n");
	  break;
	  break;
	}
	else if(a[i][j]=='1'&&a[i+1][j]=='1'&&a[i+2][j]=='1'&&a[i+3][j]=='1'){
	  printf("B\n");
	  break;
	  break;
	}
	else if(a[i][j]=='1'&&a[i][j+1]=='1'&&a[i][j+2]=='1'&&a[i][j+3]=='1'){
	  printf("C\n");
	  break;
	  break;
	}
	else if(a[i][j]=='1'&&a[i+1][j-1]=='1'&&a[i+1][j]=='1'&&a[i+2][j-1]=='1'){
	  printf("D\n");
	  break;
	  break;
	}
	else if(a[i][j]=='1'&&a[i][j+1]=='1'&&a[i+1][j+1]=='1'&&a[i+1][j+2]=='1'){
	  printf("E\n");
	  break;
	  break;
	}
	else if(a[i][j]=='1'&&a[i+1][j]=='1'&&a[i+1][j+1]=='1'&&a[i+2][j+1]=='1'){
	  printf("F\n");
	  break;
	  break;
	}
	else if(a[i][j]=='1'&&a[i][j+1]=='1'&&a[i+1][j]=='1'&&a[i+1][j-1]=='1'){
	  printf("G\n");
	  break;
	  break;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 524
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val k = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()
    abc000a(k,a,b)
}

fun abc000a(k:Int, a:Int, b:Int) {
    var ans = "NG"
    for(i in a..b){
        if(i % k == 0) ans = "OK"
    }
    if(k == 1) ans = "OK"
    println(ans)
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



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

char F[102][102];

void DFS(int Y, int X, char f)
{
  if(F[Y][X]!=f)
    return;

  F[Y][X] = '.';

  DFS(Y-1, X  , f);
  DFS(Y  , X+1, f);
  DFS(Y+1, X  , f);
  DFS(Y  , X-1, f);
}

int main()
{
  while(true){
    int H, W;
    cin >> H >> W;

    if(H==0 && W==0)
      break;

    for(int y=1; y<=H; y++){
      for(int x=1; x<=W; x++){
	cin >> F[y][x];
      }
    }

    int cnt = 0;
    for(int y=1; y<=H; y++){
      for(int x=1; x<=W; x++){
	if(F[y][x]!='.'){
	  cnt++;
	  DFS(y, x, F[y][x]);
	}
      }
    }

    cout << cnt << endl;
  }

  return 0;
}



Measured memory_bytes: 3388
A,B,C = sorted(list(map(int,input().split())))
cnt = 0
cnt += (C-A)//2
A += ((C-A)//2)*2
cnt += (C-B)//2
B += ((C-B)//2)*2
A,B,C = sorted([A,B,C])
if B==C:
    if A<C:
        cnt += 2
else:
    cnt += 1
print(cnt)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(n&1) {
        cout << "No" << '\n';
        return 0;
    }
    rep(i, n) {
        if(s[i] == "hi"[i&1]);
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 764
import itertools
n, m = map(int, input().split(" "))
d = {}
for i in range(1, n+1):
  d[i] = []

for _ in range(m):
  a, b = map(int, input().split(" "))
  d[a].append(b)
  d[b].append(a)
  

cnt = 0
for iter in itertools.permutations(range(2, n+1)):
  bp = 0
  for i, num in enumerate(iter):
    if i == 0:
      if num in d[1]:
        pass
      else:
        bp = 1
        break
    else:
      if num in d[iter[i-1]]:
        pass
      else:
        bp = 1
        break
  if bp == 0:
    cnt += 1

print(cnt)
      

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

int main() {
  //種類数，粉量の代入
  int N, X;
  cin >> N >> X;
  
  //各ドーナツで必要な粉量の代入
  vector<int> weight(N);
  for (int i = 0; i < N; i++) {
    cin >> weight.at(i);
  }
  
  //ドーナツ必要粉量の最小値を求めて割る
  sort(weight.begin(), weight.end());
  int least = weight.at(0);
  
  //全種類作った上での余剰分をleastで割る
  for (int i = 0; i < N; i++) {
    X -= weight.at(i);
  }
  
  cout << N + (X/least) << endl;
}



Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	N, M := nextInt(), nextInt()
	L := make([]int, M)
	R := make([]int, M)
	D := make([]int, M)

	g := make([][]Edge, N)
	for i := 0; i < N; i++ {
		g[i] = make([]Edge, 0)
	}
	for i := 0; i < M; i++ {
		L[i] = nextInt() - 1
		R[i] = nextInt() - 1
		D[i] = nextInt()
		g[L[i]] = append(g[L[i]], Edge{R[i], D[i]})
		g[R[i]] = append(g[R[i]], Edge{L[i], -D[i]})
	}

	vis := make([]bool, N)
	pos := make([]int, N)

	ok := true
	for i := 0; i < N; i++ {
		if !vis[i] {
			ok = ok && dfs(i, g, vis, pos)
			if !ok {
				break
			}
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func dfs(u int, edges [][]Edge, vis []bool, pos []int) bool {
	// fmt.Println(u, edges, vis, pos)
	vis[u] = true

	res := true
	for _, e := range edges[u] {
		if !vis[e.to] {
			pos[e.to] = pos[u] + e.d
			res = res && dfs(e.to, edges, vis, pos)
		} else {
			if pos[u] + e.d != pos[e.to] {
				res = false
			}
		}
	}
	return res
}

type Edge struct {
	to int
	d int
}

// -------- Library --------
func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func abs(x int) int {
	if x > 0 {
		return x
	} else {
		return -x
	}
}

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	v, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println("Failed to read int", err)
		os.Exit(1)
	}
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}


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




int main(void)
{
	int input[9] = {};
	int num, i, j, temp;
	int count = 0;

	scanf("%d", &num);

	for (i = 0; i < num; i++) {
		scanf("%d", &temp);

		for (j = 0; j < 8; j++) {

			if (temp < 400 * (j + 1)) {
				input[j]++;
				break;
			}
		}
		if (temp >= 3200) {
			input[8]++;
		}
	}

	for (i = 0; i < 8; i++) {
		if (input[i] > 0) {
			count++;
		}
	}

	if (input[8] == 0) {
		printf("%d %d", count, count);
	}
	else {
		if (count == 0) {
			printf("1 %d", input[8]);
		}
		else {
			printf("%d %d", count, count + input[8]);
		}
	}


	return(0);
}

Measured memory_bytes: 128
#include <limits>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ RMQ Class ------ //
template<typename Type> class RMQ {
private:
	int size_; vector<Type> dat;
	Type query_(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return numeric_limits<Type>::max();
		if (a <= l && r <= b) return dat[k];
		int lc = query_(a, b, 2 * k, l, (l + r) / 2);
		int rc = query_(a, b, 2 * k + 1, (l + r) / 2, r);
		return min(lc, rc);
	}
public:
	RMQ(int size__) {
		for (size_ = 1; size_ < size__; size_ <<= 1); dat.resize(size_ * 2, numeric_limits<Type>::max());
	}
	RMQ(vector<Type> v) {
		for (size_ = 1; size_ < dat.size(); size_ <<= 1); dat.resize(size_ * 2, numeric_limits<Type>::max());
		for (int i = 0; i < v.size(); i++) dat[i + size_] = v[i];
		for (int i = size_ - 1; i >= 1; i--) dat[i] = min(dat[2 * i], dat[2 * i + 1]);
	}
	int size() { return size_; }
	int ndat() { return numeric_limits<Type>::max(); }
	void update(int i, int x) {
		i += size_; dat[i] = x;
		while (i > 1) i >>= 1, dat[i] = min(dat[2 * i], dat[2 * i + 1]);
	}
	Type query(int l, int r) {
		return query_(l, r, 1, 0, size_);
	}
};
int n, q, c, x, y;
int main() {
	scanf("%d%d", &n, &q);
	RMQ<int> r(n);
	for(int i = 0; i < q; i++) {
		scanf("%d%d%d", &c, &x, &y);
		if(c == 0) r.update(x, y);
		else printf("%d\n", r.query(x, y + 1));
	}
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    vector<int> a(N + 1);

    rep(i, N) {
        if (S[i] == '<')
            a[i + 1] = max(a[i + 1], a[i] + 1);
    }

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

    ll ans = 0;
    rep(i, N + 1)
        ans += a[i];

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;

int main()
{
  ll n;
  cin>>n;
  
  ll a[n];
  int x[n][n],y[n][n];
  ll ans = 0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    
    for(int j=0;j<a[i];j++)
    {
      cin>>x[i][j]>>y[i][j];
    }
  }
  
  for(int mask = 0; mask<(1<<n);mask++)
  {
    bool flag = 1;
  	for(int i=0;i<n;i++)
    {
      if(mask&(1<<i))
      {
        for(int j=0;j<n;j++)
        {
          if((mask&(1<<j)) == 0)
            continue;
          for(int k=0;k<a[j];k++)
          {
            if(x[j][k] == i+1)
            {
              if(y[j][k] == 1)
              	continue;
              else
                flag=0;
            }
          }
        }
        
        for(int j=0;j<a[i];j++)
        {
          if(y[i][j] == 1)
          {
            if((mask&(1<<(x[i][j]-1))))
            	continue;
            else
              flag=0;
          }
          
          if(y[i][j] == 0)
          {
            if(!(mask&(1<<(x[i][j]-1))))
            	continue;
            else
              flag=0;
          }
        }
      }
    }
    
    if(flag==1)
    {
      //cout<<mask<<endl;
      ans = max(ans,(ll) __builtin_popcount(mask));
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef __int128_t i128;
typedef long long i64;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define FPEN2 freopen("out.txt", "w", stdout);
#else
#define FPEN
#define FPEN2
#endif
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
  FPEN;
  //ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
  i64 a,b,c;
  scanf("%lld %lld.%lld",&a,&b,&c);
  printf("%lld\n",a*(c+b*100)/100);
  
  return 0;
}
//2020.05.31 20:07:21


Measured memory_bytes: 3864
n=gets.to_i
array=gets.split.map(&:to_i)
sum=array.inject(:+)

sumnow=0
sumleft=0
sumright=0
array.map{|value|
    sumnow+=value
    if sumnow*2>=sum
        sumleft=sumnow-value
        sumright=sumnow
        break
    end
}


puts [2*sumright-sum,sum-2*sumleft].min


Measured memory_bytes: 16900
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
#define debug(x) (cout << "#x = " << (x) << endl)
#define lowbit(x) (x & -x)
#define Set(x, i) memset(x, i, sizeof x)
#define R register
#define For( i, j, k ) for(R int i = (j); i <= (k); ++i)
#define Rep( i, j, k ) for(R int i = (j); i >= (k); --i)
#define Cross( i, j, k ) for(R int i = (j); i; i = (k))
typedef long long ll;
using namespace std;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x); putchar (' '); }

	inline void wln ( ll x ) { write(x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x); wln (y); }

}

using namespace IO;

namespace Cesare {
	
	ll n, d[N];
	
	int main() {
		n = read();
		ll Ans = 0;
		For ( i, 1, n ) d[i] = read();
		For ( i, 1, n ) For ( j, i + 1, n ) 
			Ans += d[i] * d[j];
		return wln(Ans), 0;
	}
	
}

int main()
{
	return Cesare :: main();
}

/*

*/



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;


int main() {


	int a, b;

	cin >> a >> b;

	cout << ((500*a>=b) ? "Yes" : "No") << endl;

	return 0;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    ll N;
    cin >> N ;
    for(ll i = 1; i <= N; i++){
        if(i*108/100 == N){
            cout << i << endl;
            return 0;
        }
        
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <map>
using namespace std;
const int maxn = 2000010;
int n = 0, q = 0;

struct Query{
	int id, l, r;
	bool operator< (Query a) const{
		return r < a.r;
	}
}query[maxn];



int v[maxn], sum[maxn], ans[maxn];

int lowbit(int x){
	return x & (-x);
}

void change(int i, int a){
	while(i <= n){
		sum[i] += a;
		i += lowbit(i);
	}
}

int getsum(int i){
	int sum_t = 0;
	while(i > 0){
		sum_t += sum[i];
		i -= lowbit(i);
	}
	return sum_t;
}

int main() {

	while(~scanf("%d%d", &n,&q)){
		memset(v, 0, sizeof(v));
		memset(sum, 0, sizeof(sum));
		memset(ans, 0, sizeof(ans));

		int t = 0;
		for(int i = 1; i <= n; i++){
			scanf("%d", &v[i]);
		}
		//scanf("%d", &q);
		for(int i = 1; i <= q; i++){
			scanf("%d%d", &query[i].l, &query[i].r);
			query[i].id = i;
		}
		sort(query + 1, query + q + 1);

		int pre = 1;
		map<int, int> mymap;
		for(int i = 1; i <= q; i++){
			for(int j = pre; j <= query[i].r; j++){
				//已存在
				if(mymap[v[j]]){
					change(mymap[v[j]], -1);
				}
				mymap[v[j]] = j;
				change(j, 1);
			}
			pre = query[i].r + 1;
			ans[query[i].id] = getsum(query[i].r) - getsum(query[i].l - 1);
		}

		for(int i = 1; i <= q; i++){
			cout << ans[i] << endl;
		}
	}
	return 0;
}


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

using namespace std;

#define For(i , a , b) for (int i = (a) ; i <= (b) ; i++)
#define Rep(i , n) for (int i = 0 ; i < (n) ; i++)
#define Ford(i , a , b) for (int i = (a) ; i >= (b) ; i--)

const int maxn = 1912;
int n , m;
string s[maxn];
string pat[2];

void ReadData() {
	cin >> n >> m;
	For(i , 1 , n) cin >> s[i] , s[i] = ' ' + s[i];
	For(i , 0 , 1) cin >> pat[i];
}

bool inside(const int &x , const int &y) {
	return x >= 1 && x <= n && y >= 1 && y <= m;
}

int check(int i , int j) {
	if (!(i >= 1 && i <= n - 1 && j >= 1 && j <= m - 1)) return 0;
	if (pat[0][0] == s[i][j] && pat[1][0] == s[i + 1][j] 
	 && pat[0][1] == s[i][j + 1] && pat[1][1] == s[i + 1][j + 1]) return 1;
	return 0;
}

void Process() {
	int cnt = 0;
	char choice[] = {'J' , 'O' , 'I'};
	
	For(i , 1 , n - 1) For(j , 1 , m - 1) {
		cnt += check(i , j);
	}
	int res = cnt;
	For(i , 1 , n) For(j , 1 , m) { // try to change cell i , j
		char tmp = s[i][j];
		int last = cnt;
		Rep(k , 3) {
			cnt -= check(i , j) + check(i - 1 , j) + check(i , j - 1) + check(i - 1 , j - 1);
			s[i][j] = choice[k];
			cnt += check(i , j) + check(i - 1 , j) + check(i , j - 1) + check(i - 1 , j - 1);
			res = max(res , cnt);
		}
		cnt = last;
		s[i][j] = tmp;
	}
	
	cout << res << endl;
}

int main() {
   // ios_base::sync_with_stdio(false);
   // cin.tie(NULL);
    
    //freopen("./emblem.inp" , "r" , stdin);	
   	ReadData();
   	Process();

    return 0;	
}

Measured memory_bytes: 2244
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
const LL MOD = 1000000007LL;
const int inf = 1e9;
const LL INF = 1e18;
int main() {
	int N, K;
	cin >> N >> K;
	if (K == 0) {
		cout << (LL)N*N << endl;
		return 0;
	}
	LL ans = 0;
	for (int b = K + 1; b <= N; b++) {
		int n = (N + b - K) / b;
		int m = (N + 1) / b;
		int r1 = (N + b - K) % b;
		int r2 = (N + 1) % b;
		if (n == m) {
			ans += (LL)(r1 - r2 + 1)*n;
		}
		else {
			ans += (LL)(r1 + 1)*n;
			ans += (LL)(b - r2)*m;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const ll inf = 99900100100;
const int MOD = 998244353;
const double EPS = 1e-9;

int dp[1100][1100] = {};
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s1,s2;
    cin >> s1;
    cin >> s2;
    rep(i,s1.size()+1) dp[i][0] = i;
    rep(j,s2.size()+1) dp[0][j] = j;

    REP(i,1,s1.size()+1){
      REP(j,1,s2.size()+1){
        int u = (s1[i-1]==s2[j-1])?0:1;
        dp[i][j] = min({dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+u});
      }
    }
    cout << dp[s1.size()][s2.size()] << endl;
    return 0;
}



Measured memory_bytes: 7512
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

// 逆元 | a と mod は互いに素
int inv_mod(int a, int m = MOD) {
  int b = m, x = 1, y = 0, t;
  while (b > 0) {
    t = a / b;
    swap(a -= t * b, b);
    swap(x -= t * y, y);
  }
  x %= m;
  if (x < 0) x += m;
  return x;
}

// 逆元(配列) | 1...n-1 は mod と互いに素, n <= mod
int fac[1000010], invfac[1000010], inv[1000010];
void init(int n, int mod = MOD) {
  fac[0] = 1;
  for (int i = 1; i < n; i++) fac[i] = fac[i-1]*i%mod;
  invfac[n-1] = inv_mod(fac[n-1]);
  for (int i = n-2; i >= 0; i--) invfac[i] = invfac[i+1]*(i+1)%mod;
  for (int i = 1; i < n; i++) inv[i] = invfac[i]*fac[i-1]%mod;
}

// 二項係数 | n,k < mod, mod は素数
int nCk(int n, int k, int mod = MOD) {
  if (!(0 <= k && k <= n)) return 0;
  return fac[n] * invfac[k] % mod * invfac[n-k] % mod;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  init(400010);
  int N,M,K;
  cin >> N >> M >> K;
  int ans = 0;
  for (int i = 1; N-i >= 1; i++) {
    int tmp = (N-i)*M%MOD*M%MOD;
    (tmp *= nCk(N*M-2,K-2)) %= MOD;
    (ans += tmp*i%MOD) %= MOD;
  }
  for (int i = 1; M-i >= 1; i++) {
    int tmp = (M-i)*N%MOD*N%MOD;
    (tmp *= nCk(N*M-2,K-2)) %= MOD;
    (ans += tmp*i%MOD) %= MOD;
  }
  cout << ans << endl;

  return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

void print(const vi& num) {
    int n = num.size();
    rep(i, 0, n) {
        cout << num[i];
        if (i != n - 1) { cout << " "; }
        else { cout << endl; }
    }
}

int insertion_sort(vi& A, int g) {
    int cnt = 0;
    int n = A.size();

    rep(i, g, n) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            ++cnt;
        }
        A[j + g] = v;
    }
    return cnt;
}

void shell_sort(vi& A) {
    int n = A.size();
    int cnt = 0;

    deque<int> g = {1};
    while (3 * g.front() + 1 < n ) { g.push_front(3 * g.front() + 1); }
    int m = g.size();

    rep(i, 0, m) { cnt += insertion_sort(A, g[i]); }
    
    cout << m << endl;
    rep(i, 0, m) {
        cout << g[i];
        if (i == m - 1) { cout << endl; }
        else {cout << " "; }
    }
    cout << cnt << endl;
    rep(i, 0, n) { cout << A[i] << endl; }
}

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

    vi A(n);
    rep(i, 0, n) { cin >> A[i]; }

    shell_sort(A);

    return 0;
}


Measured memory_bytes: 6688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace d
{
    class Program
    {
        static string[][] c = new string[2][];
        static void Main(string[] args)
        {
            c[0] = new string[] { "#", "#", ".", "." };
            c[1] = new string[] { "#", ".", "#", "." };
            int n = int.Parse(Console.ReadLine());
            string[] s = new string[2];
            for (int i = 0; i < 2; i++)
            {
                s[i] = "";
            }
            bool afterMode = true;
            while (s[0].Length < n)
            {
                if (afterMode)//ato ni ireru
                {
                    afterMode = false;
                    for (int ccnt = 0; ccnt < 4; ccnt++)
                    {
                        for (int scnt = 0; scnt < 2; scnt++)
                        {
                            Console.WriteLine("{0}{1}", s[scnt], c[scnt][ccnt]);
                        }
                        string r = Console.ReadLine();
                        if (r == "T")
                        {
                            for (int scnt = 0; scnt < 2; scnt++)
                            {
                                s[scnt] = s[scnt] + c[scnt][ccnt];
                            }
                            afterMode = true;
                            break;
                        }
                        else if (r == "end") return;
                    }
                }
                else//mae ni ireru
                {
                    for (int ccnt = 0; ccnt < 4; ccnt++)
                    {
                        for (int scnt = 0; scnt < 2; scnt++)
                        {
                            Console.WriteLine("{0}{1}", c[scnt][ccnt], s[scnt]);
                        }
                        string r = Console.ReadLine();
                        if (r == "T")
                        {
                            for (int scnt = 0; scnt < 2; scnt++)
                            {
                                s[scnt] = c[scnt][ccnt] + s[scnt];
                            }
                            break;
                        }
                        else if (r == "end") return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 3500
N = int(input())

A_list = list(int(Ai)-1 for Ai in input().split(' '))
B_list = list(int(Bi) for Bi in input().split(' '))
C_list = list(int(Ci) for Ci in input().split(' '))

num = 0
previous=-10

for i, Ai in enumerate(A_list):
  num += B_list[Ai]
  if previous == Ai-1:
    num += C_list[previous]
  
  previous=Ai
  
print(num)

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
typedef pair<int,pint> ppi;
const int inf   = 510101010;
const int mod=1e9+7;
const ll longinf=1LL<<60;

int main(){
  map<int,int> mp;
  int n;cin>>n;
  int ans=0;
  rep(i,n){
    int a;cin>>a;
    if(a>n)ans++;
    mp[a]+=1;
    }
  rep(i,n+1){
    if(mp[i]<i)ans+=mp[i];
    if(mp[i]>i)ans+=mp[i]-i;
    }
  cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 9216
#include <iostream>

using namespace std;

int main(){
  int res = 700;
  string s;
  cin >> s;
  if(s[0] == 'o') res += 100;
  if(s[1] == 'o') res += 100;
  if(s[2] == 'o') res += 100;
  cout << res << "\n";
  return 0; 
}

Measured memory_bytes: 256
fun main() {
    val s = readLine() ?: return
    val c = s.replace("BC", "D")
    var t = 0L
    var i = 0
    while (i < c.length) {
        val v = c[i]
        if (v == 'A') {
            var d = 1
            var j = i + 1
            while (j < c.length) {
                val n = c[j]
                if (n == 'D') {
                    t += d
                } else if (n == 'A') {
                    d++
                } else {
                    break
                }
                j++
            }
            i = j
        }
        i++
    }
    println(t.toString())
}

Measured memory_bytes: 57564
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

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

    deque<int> d;
    for(int i= 0; i < N; ++i) {
        int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
        if (p == 0){
            d.push_front(a[i]);
        }else {
            d[p-1] = a[i];
        }
    }

    cout << d.size() << endl;
    return 0;
}



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

int main()
{
  vector<bool> A(26, false);
  string S;
  cin >> S;
  if (S.size() < 26)
  {
    for (int i = 0; i < S.size(); i++)
    {
      int int_c = S.at(i) - 97;
      A.at(int_c) = true;
    }
    for (int i = 0; i < 26; i++)
    {
      if (!A.at(i))
      {
        char char_i = i + 97;
        cout << S << char_i << endl;
        return 0;
      }
    }
  }
  else
  {
    int int_c = S.at(25) - 97;
    A.at(int_c) = true;
    for (int i = 24; i >= 0; i--)
    {
      int_c = S.at(i) - 97;
      for (int j = int_c + 1; j < 26; j++)
      {
        if (A.at(j))
        {
          char char_i = j + 97;
          cout << S.substr(0, i) << char_i << endl;
          return 0;
        }
      }
      A.at(int_c) = true;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int q;
	cin >> s >> q;
	string head = "", tail = "";
	bool rev = false;
	rep(i,q){
		int t;
		cin >> t;
		if(t == 1) rev = !rev;
		else{
			int f;
			char c;
			cin >> f >> c;
			if(f == 1){
				if(rev) tail += c;
				else head += c;
			}
			else{
				if(rev) head += c;
				else tail += c;
			}
		}
	}
	if(rev){
		for(int i = tail.size()-1; i >= 0; --i) cout << tail[i];
		for(int i = s.size()-1; i >= 0; --i) cout << s[i];
		for(int i = 0; i < head.size(); ++i) cout << head[i];
	}
	else{
		for(int i = head.size()-1; i >= 0; --i) cout << head[i];
		for(int i = 0; i < s.size(); ++i) cout << s[i];
		for(int i = 0; i < tail.size(); ++i) cout << tail[i];
	}
	cout << endl;
	return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int a[100001];
    int arr[100001] = {};
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        arr[a[i]]++;
        if (a[i] > 0)
            arr[a[i] - 1]++;
        if (a[i] < n)
            arr[a[i] + 1]++;
    }

    int mx = 0;
    for (int x = 0; x <= 100000; x++)
    {
        mx = max(mx, arr[x]);
    }
    cout << mx << endl;
}


Measured memory_bytes: 1792
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A.exe A.cpp 
Execute: ./A
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int n, k;
	cin >> n >> k;
	
	cout << n * k << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;

signed main(){
	string s,t;cin>>s>>t;
	int ans=0;
	rep(i,len(s)){
		if(s[i]!=t[i])ans++;
	}
	cout<<ans<<endl;
}


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

using namespace std;
#define int long long

signed main() {
  int N,L,T;
  cin >> N >> L >> T;

  vector<int> X(N),W(N),X2(N);
  int count = 0;

  for(int i=0; i<N; i++) {
    cin >> X[i] >> W[i];
    if (W[i] == 1) count -= (T + X[i]) / L;
    else           count += (T - (X[i]+1-L)) / L;
    if (W[i] == 1) X2[i] = (X[i] + T) % L;
    else X2[i] = ((X[i] - T) % L + L) % L;
  }
  count = (count % N + N) % N;
  sort(X2.begin(), X2.end());
  for(int i=0; i<N; i++) cout << X2[(i - count + N) % N] << endl;
  return 0;
}


Measured memory_bytes: 3584
my ($N, $A, $B) = split " ", <>;
my $result = 0;
for my $n (1..$N) {
    my @num = split "", $n;
    my $sum;
    for my $num (@num) {
        $sum += $num;
    }
    $result += $n if $A <= $sum && $sum <= $B;
}
print $result;


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a=0,b=0;
    int n,d,x,y,j=0;
    cin>>n>>d;
    for(int i=0;i<n;i++)
    {
        
        cin>>x>>y;
        a=pow(x,2)+pow(y,2);
        b=sqrt(a);
        if(b<=d){
             j++;
        }
    }
    cout<<j;
    


}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
string s,ans;
int cou=0;
 while(getline(cin,s,',')){
 ans+=s;
 ans+=" ";
 cou++;
 if(cou==2)break;
}
cin>>s;
ans+=s;
cout<<ans<<endl;
  return 0;
}


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

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

  int ans = 0, m, mn = 1000;
  for (int i = 0; i < N; i++) {
    cin >> m;
    X -= m;
    ans++;
    if (m < mn) {
      mn = m;
    }
  }
  ans += X / mn;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << char(a[0] + ('A'-'a')) << char(b[0] + ('A' - 'a')) << char(c[0] + ('A' - 'a')) << endl;
}


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

#include <iostream>
using namespace std;
#define LL long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, n) for (int i = 0; i <= (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, n) for (int i = (n)-1; i > 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define newl '\n'

void dfs(int x, vector<vector<int>> &adj, vector<bool> &visited) {
  visited[x] = true;
  for (auto nxt : adj[x])
    if (!visited[nxt]) dfs(nxt, adj, visited);
}

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> adj(n);
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  vector<bool> visited(n);
  int res = 0;
  rep(i, n) {
    if (!visited[i]) ++res, dfs(i, adj, visited);
  }
  cout << res - 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // cout << fixed << setprecision(3);
  // int n;
  // cin >> n;
  // rep(i, n) solve();
  solve();
}


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

int main()
{
    string n;
    cin>>n;
    if((n[0]==n[1]&& n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3]))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define F0R(i, a) for (int i = 0; i < (a); i++)
const int mod = 1e9 + 7;
const char nl = '\n';

vector<int> adj[200001];
bool vis[200001];
int cnt = 0;
 
void dfs(int u, int sum = 1){
    cnt++;
    vis[u] = 1;
     bool ok = 0;
     for(auto v : adj[u]){
         if(!vis[v]){
             dfs(v, sum + 1);
         }
     }
    return;
}
 
int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    F0R(i, m){
        int x, y;
        cin >> x >> y;
        x--, y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int mx = 0;
    F0R(i, n){
        if(!vis[i]){
            cnt = 0;
            dfs(i);
            mx = max(mx, cnt);
        }
    }
    cout << mx << nl;
    return 0;
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

const int MOD = 1e9 + 7;

void MAIN() {
  int n, m;
  cin >> n >> m;
  vector<int> x(n), y(m);
  for (auto &i : x) cin >> i;
  for (auto &i : y) cin >> i;
  int w = 0, h = 0;
  for (int i = 0; i < n; i++) {
    w += x[i] * (2 * i + 1 - n);
    w %= MOD;
  }
  for (int i = 0; i < m; i++) {
    h += y[i] * (2 * i + 1 - m);
    h %= MOD;
  }
  cout << (h * w) % MOD << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 4760