akhauriyash/Code-Regression huggingface dataset:
n = int(input())
arr=[]
for i in range(n):
    a,b,c=map(int,input().split())
    arr.append([a,b,c])
dp=[]
for i in range(n):
    dp.append([0]*3)

dp[0][0]=arr[0][0]
dp[0][1]=arr[0][1]
dp[0][2]=arr[0][2]

for i in range(1,n):
    dp[i][0]=arr[i][0]+max(dp[i-1][2],dp[i-1][1])
    dp[i][1] = arr[i][1] + max(dp[i-1][2], dp[i-1][0])
    dp[i][2] = arr[i][2] + max(dp[i-1][0], dp[i-1][1])

print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))

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

int main() {
	int a, b, c;

	cin >> a >> b >> c;

	if (a == b&&b == c) {
		cout << 1 << endl;
	}
	else if (a == b) {
		cout << 2 << endl;
	}
	else if (b == c) {
		cout << 2 << endl;
	}
	else if (c == a) {
		cout << 2 << endl;
	}
	else {
		cout << 3 << endl;
	}


	

	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter

class UnionFind:

    def __init__(self, n):
        self.p = list(range(n))
        self.rank = [0] * n

    def find_root(self, x):
        if x != self.p[x]:
            self.p[x] = self.find_root(self.p[x])

        return self.p[x]

    def is_same(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def unite(self, x, y):
        u = self.find_root(x)
        v = self.find_root(y)

        if u == v:
            return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
        else:
            self.p[v] = u

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1


N, K, L = map(int, sys.stdin.readline().split())

uf1 = UnionFind(N)
uf2 = UnionFind(N)

for i in range(K):
    p, q = map(int, sys.stdin.readline().split())
    p, q = p - 1, q - 1
    uf1.unite(p, q)

for i in range(L):
    r, s = map(int, sys.stdin.readline().split())
    r, s = r - 1, s - 1
    uf2.unite(r, s)

cntr = Counter()

for i in range(N):
    u = uf1.find_root(i)
    v = uf2.find_root(i)

    cntr[(u, v)] += 1

ans = []

for i in range(N):
    u = uf1.find_root(i)
    v = uf2.find_root(i)

    ans.append(cntr[(u, v)])

print(*ans)

Measured memory_bytes: 110552
#include <iostream>

using namespace std;

int main() {
  int e;
  while (cin >> e, e) {
    int ans = 1000000 + 1000 + 100;
    for(int z = 0; z < 100+1; z++) {
      if (z*z*z > e) continue;
      for(int y = 0; y < 1000+1; y++) {
        if (z*z*z + y*y > e) continue;
        ans = min(ans, e - (z*z*z + y*y) + y + z);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3016
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#define NILL 2000000010
using namespace std;

struct tree{
	int key;
	tree *r,*l,*p;
};

tree *root,*NIL;

void insert(int k){
	tree *x=root,*y=NULL,*z;
	z = (tree *)malloc(sizeof(tree));
	z->key = k;
	z->l=NULL,z->r=NULL;
	while( x != NULL ){
		y = x;
		if(z->key < x->key ){
			x = x->l;
		} else {
			x = x->r;
		}
	}
	z->p = y;
	if( y == NULL ){
		root = z;
	} else {
		if( z->key > y->key ){
			y->r = z;
			z->p = y;
		} else {
			y->l = z;
			z->p = y;
		}
	}
}

void inorder(tree *u){
	if( u == NULL ) return;
	inorder(u->l);
	printf(" %d",u->key);
	inorder(u->r);
}

void preorder(tree *u){
	if( u == NULL ) return;
	printf(" %d",u->key);
	preorder(u->l);
	preorder(u->r);
}

void find(int x){
	tree *u = root;
	while( u != NULL){
		if(u->key == x){
			printf("yes\n");
			return;
		}
		if(u->key > x) u=u->l;
		else u=u->r;
	}
	printf("no\n");
	return;
}

int main(){
	int i,n,j,x;
	string com;
	cin >> n;
	root = NULL;
	while(n--){
		cin >> com;
		if( com == "insert" ){
			cin >> x;
			insert(x);
		}else if( com == "print" ){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		} else if( com == "find" ){
			cin >> x;
			find(x);
		}
	}
}


Measured memory_bytes: 22044
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
int getSum(int x){
  return x*(x+1)/2;
}
main(){
  int X;
  cin>>X;
  int n_jumps;
  for(int i=1;i<1000000;++i){
    int sum=getSum(i);
    if(sum>=X){
      n_jumps=i;
      break;
    }
  }
  cout<<n_jumps<<endl;
}


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

int main() {
	string s;
	cin >> s;
	string ans;
	for (int i = 0; i < s.length(); i++) {
		if (s.at(i) == 'B') {
			if (ans.length() == 0)continue;
			else ans = ans.substr(0, ans.length() - 1);
		}
		else ans += s.at(i);
	}
	cout << ans << endl;
}


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

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

typedef long long LL;

struct suretu{
  int m;
  int z;
};

int main(){
  int n;
  cin >> n;
  vector<struct suretu> a(n+2,{-1,1});
  int now=0,count=1;
  int x;
  for(int i=0;i<n;i++){
    cin >> x;
    if(x==0){
      count++;
    }else{
      a[now]={x,count};
      now++;
      count=1;
    }
  }
  a[now]={0,(count-1)};
  LL ans=0;
  int j;
  for(int i=0;a[i].m!=-1;i++){
    now=a[i].m;
    ans+=(LL)a[i].z*((LL)a[i].z+1)/2;
    for(j=i+1;a[j].m!=-1;j++){
      if((now^a[j].m)!=now+a[j].m){
        ans+=(LL)a[i].z*(LL)(a[j].z-1);
        break;
      }
      ans+=(LL)a[i].z*(LL)a[j].z;
      now^=a[j].m;
    }
  }
  if(a[0].m==-1){
    cout << (LL)n*((LL)n+1)/2 << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

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


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

int main(){

  int a,b=0;
  cin>>a>>b;

  if(2*b>=a)cout<<0<<endl;
  else cout<<a-2*b<<endl;

}


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

namespace DiceInLine
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int diceAmount = int.Parse(input[0]);
            int chosenDice = int.Parse(input[1]);

            List<string> data = (Console.ReadLine().Split(' ').ToList());
            List<int> dicesValue = new List<int>();
            
            for(int i = 0; i < diceAmount; i++)
            {
                dicesValue.Add(int.Parse(data[i]));
            }

            double exceptedValue = 0.0;
            double[] output = new double[diceAmount];
            for (int i = 0; i < diceAmount; i++)
            {
                exceptedValue += (1.0 + dicesValue[i]) / 2;
                output[i] = exceptedValue;
            }

            double maxValue = output[chosenDice - 1];
            double printOutput = 0.0;
            for (int i = 0; i + chosenDice < diceAmount; i++)
            {
                maxValue = Math.Max(maxValue, output[i + chosenDice] - output[i]);
            }
            printOutput = maxValue;
            Console.WriteLine(printOutput);
        }     

}
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n, m, nx, ny;
  cin >> n >> m >> nx >> ny;
  vector<int> x(n), y(m);
  for(int i = 0; i < n; ++i) cin >> x[i];
  for(int i = 0; i < m; ++i) cin >> y[i];

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

  bool ans = true;
  int z = x.back() + 1;
  if (z == nx) z++;

  ans &= (z <= y[0]);
  ans &= (z <= ny);

  cout << (ans ? "No War" : "War");
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

using namespace std;

#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define mod 1000000007 //998244353
#define mii map<int, int>
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>

//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word



const long long N = 200005, INF = 2000000000000000000;
//lld pi = 3.1415926535897932;
int lcm(int a, int b)
{
  int g = __gcd(a, b);
  return a / g * b;
}
int power(int a, int b, int p)
{
  if (a == 0)
    return 0;
  int res = 1;
  a %= p;
  while (b > 0)
  { if (b & 1)
      res = (res * a) % p;
    b >>= 1;
    a = (a * a) % p;
  }
  return res;
}

int testcaseva;

int sq(int x) { return 1ll * x * x; }


int32_t main() {
int n;
cin >> n;
  string ar[n] ;
  for(int i=0;i<n;i++)
    cin >> ar[i];
  int a=0,b=0,c=0,d=0;
  for(int i=0;i<n;i++){
  if(ar[i]=="AC")
    a++;
   if(ar[i]=="TLE")
    b++;
   if(ar[i]=="WA")
    c++;
   if(ar[i]=="RE")
    d++;
  }
  cout << "AC x " << a<< endl;
  cout << "WA x " << c << endl;
  cout << "TLE x "<< b<< endl;
  cout << "RE x " << d << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

#define READ freopen("input.txt", "r", stdin)
#define ROUT freopen("output.txt", "w", stdout)
#define pb push_back
#define endl '\n'

void fileIO()
{
    READ;
    ROUT;
}

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    ///fileIO();
    fasterIO();

    int r;
    cin>>r;
    cout<<3*r*r<<endl;

    return 0;
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  string result = "No";
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == n) {
        result = "Yes";
        goto out;
      }
    }
  }

out:
  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	dList := make([][]int, N)
	for i := 0; i < N; i++ {
		var D1, D2 int
		fmt.Scanf("%d %d", &D1, &D2)
		dList[i] = []int{D1, D2}
	}
	var count = 0
	for _, d := range dList {
		if d[0] == d[1] {
			count += 1
		} else {
			count = 0
		}
		if count >= 3 {
			break
		}
	}
	if count >= 3 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w,h,n;
  cin >> w >> h >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> a(n);
  bool t[w][h] = {0};
  for(int i=0; i<n; i++){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
    switch(a.at(i)){
      case 1:
        for(int jx=0; jx<x.at(i); jx++){
          for(int jy=0; jy<h; jy++){
            t[jx][jy] = 1;
          }
        }
        break;
      case 2:
        for(int jx=x.at(i); jx<w; jx++){
          for(int jy=0; jy<h; jy++){
            t[jx][jy] = 1;
          }
        }
        break;
      case 3:
        for(int jx=0; jx<w; jx++){
          for(int jy=0; jy<y.at(i); jy++){
            t[jx][jy] = 1;
          }
        }
        break;
      case 4:
        for(int jx=0; jx<w; jx++){
          for(int jy=y.at(i); jy<h; jy++){
            t[jx][jy] = 1;
          }
        }
        break;
    }
  }
  int cnt = 0;
  for(int i=0; i<w; i++){
    for(int j=0; j<h; j++){
      if(t[i][j] == 0){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;

int main() {

	long n, a[51], b[51], c[51],sum=0,k;

	cin >> n;

	

	cout << n*n*n << endl;

	return 0;
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,N) for(int i=0;i<(int)(N);i++)
#define rep1(i,N) for(int i=1;i<=(int)(N);i++)
#define fs first
#define sc second
#define eb emplace_back
#define pb eb
#define all(x) x.begin(),x.end()
template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int n;
ll A, B;

V<int> v;

const int MN = 5050;
bool used[MN][MN];
ll dp[MN][MN];
ll solve(int p, int b) {
    if (p == n) return 0;
    if (used[p][b + 1]) return dp[p][b + 1];
    used[p][b + 1] = true;

    ll& ans = dp[p][b + 1]; ans = TEN(18);
    if (b == -1 || v[b] < v[p]) ans = min(ans, solve(p + 1, p));

    if (b != -1 && v[b] > v[p]) ans = min(ans, B + solve(p + 1, b));
    else ans = min(ans, A + solve(p + 1, b));

    return ans;
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> n >> A >> B;
    v = V<int>(n);
    for (int i = 0; i < n; i++) cin >> v[i];

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


Measured memory_bytes: 222720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	int x,y; cin>>x>>y;
	cout<<x+y/2<<endl;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {
	def main(args: Array[String]) = {
		var a = readLine.split(" ").map(_.toInt)
		
		while(a(0) != 0 || a(1) != 0) {
			val s1 = "#." * a(1)
			val s2 = ".#" * a(1)
			
			for(i <- 0 to a(0)-1) {
			if(i % 2 == 0)
				println(s1.take(a(1)))
			else
				println(s2.take(a(1)))
			}
			println()
			a = readLine.split(" ").map(_.toInt)
		}
	}
}

Measured memory_bytes: 44060
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int ANS[10];

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int H, W, N;
	cin >> H >> W >> N;
	int A, B;
	map<pii, int> pmap;
	ANS[0] = (H - 2) * (W - 2);
	rep(i, 0, N)
	{
		cin >> A >> B;
		A--, B--;
		static const int dx[] = { 0,1,1,0,-1,-1,-1,0,1 };
		static const int dy[] = { 0,0,-1,-1,-1,0,1,1,1 };
		rep(j, 0, 9)
		{
			int nx = B + dx[j];
			int ny = A + dy[j];
			if (1 <= nx && nx < W-1 && 1 <= ny && ny < H-1)
			{
				ANS[pmap[mp(nx, ny)]]--;
				pmap[mp(nx, ny)]++;
				ANS[pmap[mp(nx, ny)]]++;
			}
		}
	}

	rep(i, 0, 10)
	{
		cout << ANS[i] << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007


int main(void){

    int N;
    cin >> N;
    int A, B;
    cin >> A >> B;

    string s;
    cin >> s;
    int C_cnt = 0;
    int clear = 0;
    int clear_B = 0;

    rep(i,N){
        //部外者の受験
        if(s.at(i)=='c'){
            cout << "No" << endl;
            C_cnt++;
            continue;
        }

        //合格条件
        if(clear < A+B ){
            if ((s.at(i) == 'b' && clear_B < B))
                clear_B++;
            else if ((s.at(i) == 'b' && clear_B >= B)){
                cout << "No" << endl;
                continue;
            }
            clear++;
            cout << "Yes" << endl;
        }
        else
            cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main(){
	int n,a,b,c=0,max=0,x;
	cin >> n;
	if(n==2)cin >> a >> b ;
	else if(n==3)cin >> a >> b >> c ;
	if(n==2){
		if(a<b){
			x=a;a=b;b=x;
		}
	}
	if(n==3){
		if(a<b){
			x=a;a=b;b=x;
		}
		if(b<c){
			x=b;b=c;c=x;
		}
		if(a<b){
			x=a;a=b;b=x;
		}
	}
	for(int i=0;i<a;i++){
		if(a%(i+1)==0&&b%(i+1)==0&&c%(i+1)==0){
			cout << i+1 <<endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

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

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

using namespace std;

typedef long long ll;

int main()
{
  int N; cin >> N;
  int a[100010];
  int ans = 0;
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    if(i+1 > a[i] && a[a[i]-1] == i+1) ans++;
  }
  cout << ans << endl;

  return 0;
} 


Measured memory_bytes: 640
def main():
    s = input()
    n = int(input())
    pre = ''
    suf = ''
    r = 1
    for _ in range(n):
        q = input().split()
        if len(q) == 1:
            r *= -1
            continue
        if r * int(q[1]) in (1, -2):
            pre = q[2] + pre
        else:
            suf += q[2]
    ans = pre + s + suf
    if r == -1:
        ans = ans[::-1]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4480
k,a,b = map(int, input().split())

if a > b-2:
    print(k+1)
else:
    if k < a-1:
        print(k+1)
    else:
        rem = k-(a-1)
        if rem%2 == 0:
            cnt = rem//2
            ans = a+(b-a)*cnt
            print(ans)
        else:
            cnt = rem//2
            ans = a+(b-a)*cnt
            ans += 1
            print(ans)

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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}
int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}

int main() {
    int N = loadint();
    vector<int> A(N); loadvec(A, N);
    vector<ll> ac(N+1);
    ac[0] = 0;
    rep(i, N) ac[1+i] = ac[i] + A[i];

    map<ll, int> st;
    for (ll x: ac) st[x]++;

    ll ans = 0LL;
    for (auto p: st) {
        ll sum = p.first, cnt = p.second - 1;
        ans += cnt * (cnt+1) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17152
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll H, W;
    cin >> H >> W;
    vector<vector<string>> S(H, vector<string>(W));
    Rep (i, H) Rep (j, W) {
        cin >> S[i][j];
        if (S[i][j] == "snuke") cout << char(j+'A') << i+1 <<"\n";
    }

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int A;
        cin >> A;

        cout << A * 800 - (A / 15) * 200 << endl;

        return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<long double> u(N);
	rep(i, N) {
		cin >> u.at(i);
	}
	sort(u.begin(), u.end());
	reverse(u.begin(), u.end());
	long double a;
	while (u.size() > 1) {
		a = (u.at(u.size() - 1) + u.at(u.size() - 2));
		u.at(u.size() - 2) = a / 2;
		u.pop_back();
	}
	cout << u.at(0) << endl;
}


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

int main(int argc, char const *argv[])
{
    /* code */
    int H, A;
    scanf("%d %d", &H, &A);
    int dummy = 0;
    if(H % A != 0)
    {
        dummy = 1;
    }
    printf("%d\n", H / A + dummy);
    return (0);
}



Measured memory_bytes: 128
s = input()[::-1]
d = 1
num = 0
ans = 0
mod_list = [0] * 2019
mod_list[0] = 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d %= 2019
    mod_list[num % 2019] += 1

for i in range(2019):
    ans += mod_list[i] * (mod_list[i] - 1) //2

print(ans)


Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int n,k,cnt;
long long ans,ans1,ans2,sum,ss1,ss2;
bool flag[2];

long long ksm(long long a,long long b)
{
	long long res=1,sum=a;
	while(b)
	{
		if(b&1) (res*=sum)%=mod;
		(sum*=sum)%=mod;
		b>>=1;
	}
	return res;
}

struct node{
	int sum,fh;
	bool operator <(const node &T)const{
		return sum>T.sum;
	}
}s[200010];

int main()
{
	int x;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&x);
		s[i].sum=abs(x);
		s[i].fh=(x<0);
	}
	sort(s+1,s+1+n);
	ans=1;
	for(int i=1;i<=k;i++)
	{
		(ans*=s[i].sum)%=mod;
		cnt+=s[i].fh;
	}
	if(cnt%2==0)
	{
		printf("%lld\n",ans);
		return 0;
	}
	sum=ans;
	ans=-ans;
	ss1=ss2=1;
	for(int i=k+1;i<=n;i++) if(!s[i].fh)
	{
		x=k;
		while(!s[x].fh) x--;
		ans1=ksm(s[x].sum,mod-2)%mod*s[i].sum%mod;
		ss1=s[i].sum;
		ss2=s[x].sum;
		flag[0]=1;
		break;
	}
	for(int i=k;i;i--) if(!s[i].fh)
	{
		x=k+1;
		while(x<=n&&!s[x].fh) x++;
		if(x<=n)
		{
			ans2=ksm(s[i].sum,mod-2)%mod*s[x].sum%mod;
			ss1*=s[i].sum;
			ss2*=s[x].sum;
			flag[1]=1;
		}
		break;
	}
	if(flag[0]&&flag[1])
	{
		if(ss1>ss2) ans=sum*ans1%mod;
		else ans=sum*ans2%mod;
	}
	else if(flag[0]) ans=sum*ans1%mod;
	else if(flag[1]) ans=sum*ans2%mod;
	else if(s[n].sum==0) ans=0ll;
	else
	{
		ans=1;
		for(int i=n;i>=n-k+1;i--) (ans*=s[i].sum)%=mod;
		ans=(mod-ans)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001;
int N;

map<tuple<int,int,int,int>,int>memo;

char fld[222][222];

int dfs(int y1,int x1,int y2,int x2){
    auto hoge=make_tuple(y1,x1,y2,x2);
    if(memo.find(hoge)!=memo.end())return memo[hoge];

    int cntX[128]={},cntY[128]={};
    bool ok=true;
    for(int y=y1;y<y2;y++)for(int x=x1;x<x2;x++)if(fld[y][x]=='x')cntX[x]++,cntY[y]++,ok=false;
    if(ok){
        return memo[hoge]=0;
    }

    vint lisx,lisy;
    rep(i,128){
        if(cntX[i]==y2-y1)lisx.pb(i);
        if(cntY[i]==x2-x1)lisy.pb(i);
    }

    int ret=INF;
    for(auto y:lisy){
        for(auto x:lisx){
            int tmp=0;
            tmp+=dfs(y1,x1,y,x);
            tmp+=dfs(y1,x+1,y,x2);
            tmp+=dfs(y+1,x1,y2,x);
            tmp+=dfs(y+1,x+1,y2,x2);
            tmp++;
            chmin(ret,tmp);
        }
    }
    return memo[hoge]=ret;
}

signed main(){
    cin>>N;
    rep(i,N)cin>>fld[i];

    cout<<dfs(0,0,N,N)<<endl;
    return 0;
}

Measured memory_bytes: 3412
#include <stdio.h>
#include <math.h>
#include <iostream>

using namespace std;

long long p = 1000000007L;

long long fast(long long a, long long n) {
    long long result = 1L;
    while (n != 0L) {
        if ((n & 1) != 0) {
            result = (result * a) % p;
        }
        a = (a * a) % p;
        n >>= 1;
    }
    return result;
}

long long c(long long n, long long a) {
    if (n - a < a)a = n - a;
    long long i, a_a = 1L, n_n = 1L;
    for (i = 2; i <= a; i++) {
        a_a = (a_a * i) % p;
    }
    for (i = 0; i < a; i++) {
        n_n = (n_n * n) % p;
        n--;
    }
    return (n_n * fast(a_a, p - 2)) % p;
}

int main() {
    long long n, a, b;
    while (~scanf("%lld%lld%lld", &n, &a, &b)) {
        long long result = fast(2L, n) - 1L;
        result -= c(n, a);
        result -= c(n, b);
        while (result < 0)result += p;
        result %= p;
        printf("%lld\n", result);
    }
    return 0;
}

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

int main(){
  int k;
  char s[100];
  scanf("%d",&k);
  scanf("%s",s);
  if(strlen(s) <= k) printf("%s",s);
  else {
    for(int i=0;i<k;i++) {
      printf("%c",s[i]);
    }
    printf("...");
  }
}

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

typedef unsigned long long ll;
const ll maxi = 1e18;

// kill as many as possible
void kill_max(const ll num, ll ar[3]){
  ll can_move = num;
  // attack 1
  ll tmp = 0;
  tmp = min(ar[1], can_move);
  can_move -= tmp;
  ar[1] -= tmp;
  ar[0] += tmp;

  // attack 2
  tmp = min(ar[2], can_move/2);
  can_move -= 2*tmp;
  ar[2] -= tmp;
  ar[0] += tmp;

  // attack1 again
  tmp = min(ar[2], can_move);
  ar[2] -= tmp;
  ar[1] += tmp;
}

void kill_min(const ll num,  ll ar[3]){
  // attack 2
  ll can_move = num;
  ll tmp = 0;
  tmp = min(ar[2], can_move);
  can_move -= tmp;
  ar[2] -= tmp;
  ar[1] += tmp;

  // attack 1
  tmp = min(ar[1], can_move);
  can_move -= tmp;
  ar[1] -= tmp;
  ar[0] += tmp;
}


int solve(const ll a, const ll b, bool fg){
  ll ta[3] = {0, 0, a};
  ll tb[3] = {0, 0, b};
  int cnt = 0;

  while(true){
    if (cnt %2 == 0){
      if (fg){
	kill_max(ta[1] + ta[2], tb);
      } else {
	kill_min(ta[1] + ta[2], tb);
      }
    } else {
      if (fg){
	kill_min(tb[1] + tb[2], ta);
      } else {
	kill_max(tb[1] + tb[2], ta);
      }
    }
    if (ta[0] == a || tb[0] == b){
      break;
    }
    cnt++;
  }
  return cnt;
}

int solve2(const ll a, const ll b, bool fg1, bool fg2){
  ll ta[3] = {0, 0, a};
  ll tb[3] = {0, 0, b};
  int cnt = 0;

  while(true){
    if (cnt %2 == 0){
      if (fg1){
	kill_max(ta[1] + ta[2], tb);
      } else {
	kill_min(ta[1] + ta[2], tb);
      }
    } else {
      if (fg2){
	kill_max(tb[1] + tb[2], ta);
      } else {
	kill_min(tb[1] + tb[2], ta);
      }
    }
    if (ta[0] == a || tb[0] == b){
      break;
    }
    cnt++;
  }
  return cnt;
}

int main(){
  ll n, m;
  cin >> n >> m;

  if (n >= m){
    if (n >= 2 * m){
      cout << 0 << endl;
    } else {
      cout << 2 << endl;
    }
  } else {
    if ( n * 2 <= m ){
      cout << 1 << endl;
    } else {
      //int mini = solve(n, m, false);
      //mini = min(mini, solve(n, m, true));
      //cout << mini << endl;


      int a = solve2(n, m, false, true);
      int b = solve2(n, m, true, false);
      int c = solve2(n, m, false, false);
      int d = solve2(n, m, true, true);
      
      ///cout << mini <<" " << min(c, d) << endl;
      cout << min(min(a, b), min(c, d)) << endl;



    }
  }

  return 0;
}



Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		for(int h = 1 ; h <= 3500 ; h++) {
			for(int n = 1 ; n <= 3500 ; n++) {
				if(4 * h * n > N * (n + h)) {
					if(N * h * n % (4 * h * n - N * (n + h)) == 0) {
						System.out.println(h + " " + n + " " + N * h * n / (4 * h * n - N * (n + h)));
						return;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n;
 	cin >> n;
 	vector <ll> vec1(n);   
 	vector <ll> vec2(n);
 	for (ll i = 0; i < n; i++) cin >> vec1[i];   
 	for (ll i = 0; i < n; i++) cin >> vec2[i];
 	reverse(all(vec2));
 	ll val = 0;
 	ll ind = 0;
 	for (ll i = 0; i < n; i++) {
 		if (vec1[i] == vec2[i]) {
 			ind = vec2[i];
 			val++;
 		} 
 	}
 	if (val == 0) {
 		cout << "Yes" << endl;
 		for (ll i = 0; i < n; i++) cout << vec2[i] << ' ';
		cout << endl;
		return 0;
 	}
 	ll c = 0;
 	for (ll i = 0; i < n; i++) {
 		if (vec1[i] != ind && vec2[i] != ind) c++;
 	}
 	if (c < val) {
 		cout << "No" << endl;
 		return 0;
 	}
 	cout << "Yes" << endl;
 	multiset <ll> as;
 	for (ll i = 0; i < n; i++) {
 		if (vec1[i] != ind && vec2[i] != ind) {
 			as.insert(vec2[i]);
 		}
 		if (val == sz(as)) break;
 	}
 	ll t = 0;
 	for (ll i = 0; i < n; i++) {
 		if (vec1[i] == vec2[i]) {
 			cout << *as.begin() << ' ';
 			as.erase(as.begin());
 		}
 		else if (t < val && vec1[i] != ind && vec2[i] != ind) {
 			cout << ind << ' ';
 			t++;
 		}
 		else {
 			cout << vec2[i] << ' ';
 		}
 	}
 	cout << endl;
	return 0; 
}

Measured memory_bytes: 9568
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/
//----------------------------------------------
#define rep(i, n) for(int  i = 0; i < (n); i++)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)
//----------------------------------------------
//問題：https://atcoder.jp/contests/DP/tasks/DP_d
//参考：https://qiita.com/drken/items/dc53c683d6de8aeacf5a
//----------------------------------------------

//2数の最大値を返す関数
LL max(LL a, LL b)
{
  if (a < b) {
    a = b;
  }
  return a;
}

int main(void)
{
  LL n;                     //品物の総数を格納する変数
  LL W;                     //重さの最大値を格納する変数
  LL weight[110];           //i番目の品物の重さを格納する配列
  LL value[110];            //i番目の品物の重さを価値を格納する配列
  LL DP[110][100010] = {0}; //DP[i+1][w]:=i番目までの品物の中から重さがwを超えないように選んだ時の、価値の総和の最大値

  /*
  漸化式
  DP[i+1][w] = max(DP[i][w-weight[i]] + valie[i] , DP[i][w])  (w>= weight[i])
             = DP[i][w]                                       (w < weight[i])
  初期条件
  DP[0][w] = 0(w = 0...w)

  DP[i][w]の値が求まっていることを前提にDP[i+1][w]を考える
  */

  //入力
  scanf("%d %d", &n, &W);
  for (LL i = 0; i < n; i++) {
    scanf("%lld %lld ", &weight[i], &value[i]);
  }

  //初期化
  for (LL i = 0; i <= W; i++) {
    DP[0][i] = 0;
  }

  //処理部
  for (LL i = 0; i < n; i++) {
    for (LL j = 0; j <= W; j++) {
      if (j >= weight[i]) {
        DP[i+1][j] = max(DP[i][j-weight[i]] + value[i], DP[i][j]);
      }else{
        DP[i+1][j] = DP[i][j];
      }
    }
  }

  //出力
  printf("%lld\n", DP[n][W]);
  return 0;
}


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

vector<int> union_tree;

int root(int leave)
{
	int tmp = leave;
	if (leave == union_tree[leave])
	{
		return leave;
	}
	union_tree[tmp] = root(union_tree[tmp]);
	return union_tree[tmp];
}

int is_same_set(int a, int b)
{
	return root(a) == root(b) ? 1 : 0;
}

void unite(int a, int b)
{
	union_tree[root(a)] = root(b);
}

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

	for (int i = 0; i < n; i++)
	{
		union_tree.push_back(i);
	}
	for (int i = 0; i < q; i++)
	{
		int command, opr1, opr2;
		cin >> command >> opr1 >> opr2;
		switch (command)
		{
		case 0:
			unite(opr1, opr2);
			continue;
		case 1:
			cout << is_same_set(opr1, opr2) << endl;
			continue;
		}
	}
	return 0;
}


Measured memory_bytes: 3492
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

bool need(string a, char c, string b, char d, int e, int maxCan) {
  for(int i = 0; i < a.size(); i++) {
    if(a[i] == c) {
      if(--e == 0) return true;
    }
    e += b[i] == d;
    e = min(e, maxCan);
  }
  return false;
}

void solve() {
  int h, w, n;
  cin >> h >> w >> n;
  int sr, sc;
  cin >> sr >> sc;
  string s, t;
  cin >> s >> t;
  bool ret = false;
  ret |= need(s, 'U', t, 'D', sr, h);
  ret |= need(s, 'D', t, 'U', h-sr+1, h);
  ret |= need(s, 'L', t, 'R', sc, w);
  ret |= need(s, 'R', t, 'L', w-sc+1, w);
  if(ret) cout << "NO\n";
  else cout << "YES\n";
}

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


Measured memory_bytes: 1176
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        vector<Int> A(N);
        vector<Int> B(N + 1);
        for (int i = 0; i < N; ++i) cin >> A[i];
        for (int i = 0; i < N; ++i) B[A[i]]++;

        Int sum = 0;
        auto tapu = [](Int n) {
            return n * (n - 1) / 2;
        };

        for (Int i = 0; i <= N; ++i) {
            sum += tapu(B[i]);
        }

        for (int i = 0; i < N; ++i) {
            Int sub = tapu(B[A[i]]);
            Int add = tapu(B[A[i]] - 1);
            Int val = sum - sub + add;
            cout << val << endl;
        }


    }

};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll match[222];
bool used[222];
vll edge[222];

bool dfs(ll v) {
  used[v] = true;
  FOR(i, 0, edge[v].size()) {
	ll u = edge[v][i];
	ll w = match[u];
	if (w < 0 || !used[w] && dfs(w)) {
	  match[v] = u;
	  match[u] = v;
	  return true;
	}
  }
  return false;
}

int main(void) {
  ll a[111], b[111], c[111], d[111];
  cin >> n;
  FOR(i, 0, n) cin >> a[i] >> b[i];
  FOR(i, 0, n) cin >> c[i] >> d[i];
  FOR(i, 0, n) {
	FOR(j, 0, n) {
	  if (a[i] < c[j] && b[i] < d[j]) {
		edge[i].pb(j + n);
		edge[j + n].pb(i);
	  }
	}
  }

  FOR(i, 0, 2*n) match[i] = -1;
  FOR(i, 0, 2*n) {
	if (match[i] < 0) {
	  FOR(j, 0, 2*n) used[j] = 0;
	  if (dfs(i)) ans++;
	}
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

using ll = long long int;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

const int MA = 6000;

ll solve(int n, int p, vl a) {
	vl dp(MA);
	dp[0] = 1;

	for (int i = 0; i < n; i++) {
		for (int j = MA - 1 - a[i]; j >= 0; j--) {
			dp[a[i] + j] += dp[j];
		}
	}

	ll res = 0;
	for (int i = 0; i < MA; i++) {
		if (i % 2 == p) {
			res += dp[i];
		}
	}

	return res;
}

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

	int n, p;
	cin >> n >> p;
	vl a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	cout << solve(n, p, a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size() <= k) cout<<s<<'\n';
    else cout<<s.substr(0,k)+"..."<<'\n';
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>

using namespace std;
int main(){
    int N;
    cin >> N;
    
    int keta = (int)to_string(N).length();
    
    int wa1 = 0;
    int wa2 = 0;
    for(int i=0;i<keta;i++){
        wa1= N / pow(10,i);
        wa2 =wa2 + (wa1 % 10);
    }

    if(N%wa2==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool fo=true,fe=true;
    for(int i=0;i<s.size();i++){
        if(i%2==1){
            if(s[i]=='R') fo=false;
        }else{
            if(s[i]=='L') fe=false;
        }
    }
    if(fo==true && fe==true){
        cout <<"Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

void dfs(vector< vs32 >& g, int from, vector< bool >& reached)
{
    reached[from] = true;
    for (auto to : g[from])
    {
        if (!reached[to]) dfs(g, to, reached);
    }
}

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

    int n, m, s;
    cin >> n >> m >> s;

    vector< pair<int, P> > e;
    vector< vs32 > g(n);

    rep (i, m)
    {
        int u, v, c;
        cin >> u >> v >> c;
        e.emplace_back(c, P{u, v});
        g[u].push_back(v);
    }

    vector<bool> reached(n, false);
    dfs(g, s, reached);

    static const int inf = 1e9;
    vs32 d(n, inf);
    d[s] = 0;
    rep (i, n)
    {
        bool update = false;
        rep (j, m)
        {
            int c = e[j].first;
            int from = e[j].second.first;
            int to = e[j].second.second;
            if (reached[to] && d[to] > d[from] + c)
            {
                d[to] = d[from] + c;
                update = true;
            }
        }
        if (i == n - 1 && update)
        {
            cout << "NEGATIVE CYCLE\n";
            return 0;
        }
    }

    rep (i, n)
    {
        if (!reached[i]) cout << "INF\n";
        else cout << d[i] << "\n";
    }

    return 0;
}




Measured memory_bytes: 3288
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, A[2][CMax], B[2][CMax], ats;

int main() {
    scanf("%d", &n);

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &A[i][j]);
        }
    }

    for (int i = 0; i < n; i++) {
        B[0][i] += A[0][i];
        if (i > 0) B[0][i] += B[0][i-1];
    }

    for (int i = n-1; i >= 0; i--) {
        B[1][i] += A[1][i];
        if (i < n-1) B[1][i] += B[1][i+1];
        if (B[0][i] + B[1][i] > ats) ats = B[0][i] + B[1][i];
    }

    printf("%d\n", ats);
}


Measured memory_bytes: 256