akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			string s = cin.Next();
			string t = cin.Next();
			int a = cin.Int();
			int b = cin.Int();
			string u = cin.Next();
			if (u == s) {
				Console.WriteLine($"{a - 1} {b}");
			} else {
				Console.WriteLine($"{a} {b - 1}");
			}
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

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

    vector<int> prime;
    for(int i = 2; i <= 100; i++){
        bool is_prime = true;
        for(auto p : prime){
            if(i % p == 0) {
                is_prime = false;
                break;
            }
        }
        if(is_prime) prime.emplace_back(i);
    }
    

    vector<int> factor(101, 0);
    for(int n = N; n > 0; n--){
        int k = n;
        for(auto p : prime){
            while(k % p == 0 && k > 0){
                factor[p]++;
                k /= p;
            }
        }
    }

    int ans = 0;
    for(int i = 2; i <= 100; i++){
        if(factor[i] >= 74) ans++;
        for(int j = i+1; j <= 100; j++){
            if(factor[i] >= 2 && factor[j] >= 24) ans++;
            if(factor[i] >= 24 && factor[j] >= 2) ans++;
            if(factor[i] >= 4 && factor[j] >= 14) ans++;
            if(factor[i] >= 14 && factor[j] >= 4) ans++;
            for(int k = j+1; k <= 100; k++){
                if(factor[i] >= 2 && factor[j] >= 4 && factor[k] >= 4) ans++;
                if(factor[i] >= 4 && factor[j] >= 2 && factor[k] >= 4) ans++;
                if(factor[i] >= 4 && factor[j] >= 4 && factor[k] >= 2) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
w = [input() for i in range(n)]
cnt = 0
for j in range(n-1):
    if (w[j][-1] == w[j+1][0])&(w.count(w[j])==1):
        pass
    else:
        cnt += 1
print("No") if cnt else print("Yes")

Measured memory_bytes: 9152
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 100001
#define NIL -1

struct Node { int p, l, r; };
Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int p) {
    D[u] = p;
    if (T[u].r != NIL) setDepth(T[u].r, p+1);
    if (T[u].l != NIL) setDepth(T[u].l, p+1);
}

int setHeight(int u) {
    int h1, h2;
    h1 = h2 = 0;
    if (T[u].r != NIL) h1 = setHeight(T[u].r) +1;
    if (T[u].l != NIL) h2 = setHeight(T[u].l) +1;
    //return ???????????????
    return H[u] = max(h1, h2);
}

void print(int u, int r) {
    int i, c, x;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    if (u == T[T[u].p].l) x = T[T[u].p].r;
    if (u == T[T[u].p].r) x = T[T[u].p].l;
    if (u == r) x = -1;
    cout << "sibling = " << x << ", ";
    int deg = 0;
    if (T[u].r != NIL) deg++;
    if (T[u].l != NIL) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";

    if (T[u].p == NIL) cout << "root";
    else if (T[u].l == NIL && T[u].r == NIL) cout << "leaf";
    else cout << "internal node";
    cout << endl;
}

int main() {
    int i, n, v, a, b, r, h;
    cin >> n;
    for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;
    
    for (i = 0; i < n; i++) {
	cin >> v >> a >> b;
	T[v].l = a;
	T[v].r = b;
	if (a != NIL) T[a].p = v;
	if (b != NIL) T[b].p = v;
    }

    for (i = 0; i < n; i++) {
	if (T[i].p == NIL) r = i;
    }
    setDepth(r,0);
    setHeight(r);

    for (i = 0; i < n; i++) print(i, r);
    
    return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#define size(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
int main(void){
  int a,b,c;
  cin >> a;
  if(a / 10 == 9 || a % 10 == 9){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
from itertools import groupby
s=input()
t=[0]*(len(s)+1)

gr=groupby(s)
now=0

for key,group in gr:
    if key=="<":
        for i in range(now,now+len(list(group))):
            t[i+1]=t[i]+1
            now+=1
    else:
        for i in range(now,now+len(list(group)))[::-1]:
            t[i]=max(t[i+1]+1,t[i])
            now+=1
print(sum(t))

Measured memory_bytes: 82760
#include <cstdio>
#include <utility>

constexpr int MAX_N = 100000;

int partition(int* A, int p, int r){
  int x = A[r];
  int i = p - 1;
  for(int j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      std::swap(A[i], A[j]);
    }
  }
  std::swap(A[i+1], A[r]);
  return i+1;
}
int main(){
  int n;
  int result;
  int A[MAX_N];
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  result = partition(A, 0, n-1);







  for(int i = 0; i < n; i++){
    if(i == result){
      printf("[%d]", A[i]);
    } else {
      printf("%d", A[i]);
    }
    if(i+1 != n){
      printf(" ");
    } else {
      printf("\n");
    }
  }
}

Measured memory_bytes: 1404
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		Arrays.sort(A);

		System.out.println(Math.abs(A[0] - A[N - 1]));
	}
}

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

int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int right, left;
    left = a + b;
    right = c + d;
    if (right > left)
    {
        printf("Right\n");
    }
    else if (right < left)
    {
        printf("Left\n");
    }
    else
    {
        printf("Balanced\n");
    }
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <list>
#include <climits>
#include <bitset>
#include <fstream>
#include <algorithm>
#include <functional>
#include <stack>
#include <string>
#include <cmath>
#define fi first
#define se second
#define re register
#define ls i << 1
#define rs i << 1 | 1
#define pb push_back
#define pii pair<int,int>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

#define int long long

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);

inline int rd(){
  int x = 0, f = 1; char ch = getchar();
  while (ch < '0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
  while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}

void out(int a) {
  if (a < 0) putchar('-'), a = -a;
  if (a >= 10) out(a / 10);
  putchar(a % 10 + '0');
}
int h, w;
const int maxn = 1010;
char s[maxn][maxn];
int step[maxn][maxn];
struct node{
  int x, y;
  node(){
  }
  node(int X, int Y) {
    x = X, y = Y;
  }
};
bool check(int x, int y) {
  return x >= 1 && x <= h && y >= 1 && y <= w;
}
void bfs(node st) {
  queue<node> q;
  q.push(st);
  while (!q.empty()) {
    node now = q.front();
    q.pop();
    int x = now.x, y = now.y;
    for (int i = x-2; i <= x+2; i++) {
      for (int j = y-2; j <= y+2; j++) {
        if (check(i,j) && s[i][j] == '.') {
          if (step[x][y] + 1 < step[i][j]) {
            step[i][j] = step[x][y] + 1;
            q.push(node(i,j));
          }
        }
      }
    }
    int pos;
    pos = x;
    while (s[pos][y] == '.' && pos >= 1) {
      if (step[x][y] < step[pos][y]) {
        step[pos][y] = step[x][y];
        q.push(node(pos,y));
      }
      pos--; 
    }
    pos = x;
    while (s[pos][y] == '.' && pos <= h) {
      if (step[x][y] < step[pos][y]) {
        step[pos][y] = step[x][y];
        q.push(node(pos,y));
      }
      pos++; 
    }
    pos = y;
    while (s[x][pos] == '.' && pos >= 1) {
      if (step[x][y] < step[x][pos]) {
        step[x][pos] = step[x][y];
        q.push(node(x,pos));
      }
      pos--;
    }
    pos = y;
    while (s[x][pos] == '.' && pos <= w) {
      if (step[x][y] < step[x][pos]) {
        step[x][pos] = step[x][y];
        q.push(node(x,pos));
      }
      pos++;
    }
  }
}
signed main(){
//int main() {
  h = rd(), w = rd();
  int ch = rd(), dh = rd();
  int cw = rd(), dw = rd();
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      scanf(" %c",&s[i][j]);
      step[i][j] = inf;
    }
  }
  step[ch][dh] = 0;
  bfs(node(ch,dh));
  cout << (step[cw][dw] == inf ? -1 : step[cw][dw]) << '\n';
  return 0;
}

Measured memory_bytes: 12944
w = input()
datalist = [x for x in w]
dataset = set(datalist)
list_set = list(dataset)
count = 0
answers = []
for i in list_set:
    count = datalist.count(i)
    if count % 2 == 0:
        answers.append("Yes")
    else:
        answers.append("NO")
# print(answers)

if "NO" in answers:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9056
#include<map>
#include<queue>
#include<cstdio>
#include<vector>

#define	pb	push_back

using namespace std;

typedef	vector<int>	vi;

vi mv[13];
long long pow12[13];

void findEmptyPos(long long stat,int *z){
	for(int i=0,j=0;i<13;i++){
		if(stat%12==0)	z[j++]=12-i;
		stat/=12;
	}
}

long long sw(long long stat,int i,int j){
	long long powi=pow12[12-i],powj=pow12[12-j];
	int pi=(stat/powi)%12,pj=(stat/powj)%12;
	return stat+(pj-pi)*powi+(pi-pj)*powj;
}

void bfs(map<long long,int> &f,long long inistat,int stop){
	f[inistat]=0;
	queue<long long> qu;	qu.push(inistat);
	while(!qu.empty()){
		long long stat=qu.front();	qu.pop();
		int cnt=f[stat];
		if(cnt==stop)	break;

		int z[2];	findEmptyPos(stat,z);
		for(int i=0;i<2;i++){
			for(int j=0;j<mv[z[i]].size();j++){
				long long nextstat=sw(stat,z[i],mv[z[i]][j]);
				if(f.count(nextstat)==0){
					qu.push(nextstat);
					f[nextstat]=cnt+1;
				}
			}
		}
	}
}

int main(){
	long long a=1;
	for(int i=0;i<13;i++)	pow12[i]=a,a*=12;

	mv[0].pb(2);
	mv[1].pb(2);	mv[1].pb(5);
	mv[2].pb(0);	mv[2].pb(1);	mv[2].pb(3);	mv[2].pb(6);
	mv[3].pb(2);	mv[3].pb(7);
	mv[4].pb(5);
	mv[5].pb(1);	mv[5].pb(4);	mv[5].pb(6);	mv[5].pb(9);
	mv[6].pb(2);	mv[6].pb(5);	mv[6].pb(7);	mv[6].pb(10);
	mv[7].pb(3);	mv[7].pb(6);	mv[7].pb(8);	mv[7].pb(11);
	mv[8].pb(7);
	mv[9].pb(5);	mv[9].pb(10);
	mv[10].pb(6);	mv[10].pb(9);	mv[10].pb(11);	mv[10].pb(12);
	mv[11].pb(7);	mv[11].pb(10);
	mv[12].pb(10);

	int ans[]={0,1,2,3,4,5,6,7,8,9,10,11,0};
	long long ansstat=0;
	for(int i=0;i<13;i++)	ansstat=ansstat*12+ans[i];

	map<long long,int> f;
	bfs(f,ansstat,12);

	for(long long inistat;scanf("%lld",&inistat),~inistat;){
		for(int i=1,p;i<13;i++)	scanf("%d",&p),inistat=inistat*12+p;
		map<long long,int> g;
		bfs(g,inistat,8);

		int cmin=21;
		map<long long,int>::iterator it;
		for(it=g.begin();it!=g.end();it++){
			long long stat=it->first;
			int cnt=it->second;
			if(f.count(stat))	cmin=min(cmin,cnt+f[stat]);
		}
		if(cmin<=20)	printf("%d\n",cmin);
		else	puts("NA");
	}

	return 0;
}

Measured memory_bytes: 2168
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


A, B, C = list(map(int, sys.stdin.readline().split()))
a = A
ok = False
for _ in range(1000):
    ok |= a % B == C
    a += A
if ok:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 13560
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <vector>
using namespace std;

int N;

long long calc(long long x, long long A[]) {
	long long ans =0;
	for(int i=0; i<N; i++) 
		ans += (x - A[i])*(x - A[i]) ;
	return ans;
}

int main() {
	cin >> N;
	
	long long A[N];
	long long mmax = 0;
	long long mmin = 1000000000000;
	
	for(int i=0; i<N; i++) {
		cin >>A[i];
		mmax = max(mmax, A[i]);
		mmin = min(mmin, A[i]);
	}	
	long long cost = 1000000000000;
	for(int i=mmin; i <=mmax; i++) {
		cost = min( cost, calc(i,A) );
	}	
	cout << cost << endl;	
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
struct pair_hash {
    template <class T1, class T2>
    size_t operator () (const pair<T1,T2> &p) const {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using Vote = pair<ll,ll>;
using Unordered_map = unordered_map<Vote, int, pair_hash>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define showvec(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" ";
#define read_input(arr,a,b) for(ll i=a;i<b;i++) cin>>arr[i];
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define SmooothOperatorrrrr()                 \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                    \
    cout.tie(0);                   
#define deci(n) cout<<fixed<<setprecision(n)
const int mod=998244353;
const int mod2=1000000007;
#define M_PI 3.14159265358979323846
#define LL_MAX 9223372036854775807
#define MAXN 2000001
/**************************************************************************************************/
int main()
{
    SmooothOperatorrrrr();
    string s,t;cin>>s>>t;
    int n=s.size();
    int m=t.size();
    int minm=1e9;
    FOR(i,0,n-m+1)
    {
        string temp=s.substr(i,m);
        int count=0;
        FOR(j,0,m)
            if(temp[j]!=t[j])
                count++;
        minm=min(minm,count);
    }
    cout<<minm<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N;
  cin >> N;
  vector<int> vec(N+1);
  REP(i, N) {
    int x;
    cin >> x;
    vec[i+1] = vec[i] + x;
  }
  int ans = INF;  
  REP(i, N) {
    ans = min(ans, abs(vec[i]*2 - vec[N]));
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
const int maxn = 1e7+10;
int a[maxn];
int main()
{
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<=x+k-1;i++)
	{
		if(i!=x+k-1)
		{
			printf("%d ",i);
		}
		else
		{
			printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
ll int primeFactors(int n) 
{ 
	ll int cnt=0,ans=1;
	while (n % 2 == 0) 
	{ 
		cnt++; 
		n = n/2; 
	} 
	ans*=(cnt+1);
	for (ll int i = 3; i <= sqrt(n); i = i + 2) 
	{
		cnt=0; 
		while (n % i == 0) 
		{ 
			cnt++; 
			n = n/i; 
		}
		if(cnt!=0)
		ans*=(cnt+1); 
	} 
	if (n > 2) 
	ans*=2;
	return ans; 
} 
void solve()
{
	ll int n,i;
	double s=0;
	cin>>n;
	for(i=1;i<=n;i++)
	s+=(((double)(i/2.0))*floor((double)n/i)*floor((double)(1+(n/i))));
	ll int ans=(ll int)(s);
	cout<<ans<<"\n";
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}

Measured memory_bytes: 3656
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
GC027 C
"""

n,m = map(int,input().split())
s = list(input())
ali = [0 for i in range(n)]
bli = [0 for i in range(n)]
from collections import defaultdict
graphAB = defaultdict(list)

for i in range(m):
    u,v=map(int,input().split())
    graphAB[u].append(v)
    graphAB[v].append(u)



def incrementAB(node,adj):
    if s[adj-1] == 'A':
        ali[node-1]+=1
    if s[adj-1] == 'B':
        bli[node-1]+=1

def decrementAB(node,adj):
    if s[adj-1] == 'A':
        ali[node-1]-=1
    if s[adj-1] == 'B':
        bli[node-1]-=1


def adjAB(node):
    if ali[node-1]!=0 and bli[node-1]!=0:
        return(True)
    else:
        return(False)

graphvers = set(graphAB.keys())
visitset = set()
for i in range(1,n+1):
    if not i in graphvers:
        s[i-1] = 'C'
    else:
        for j in graphAB[i]:
            incrementAB(i,j)
        if not adjAB(i):
            visitset.add(i)

while bool(visitset):
    #print(graphAB)
    #print(graphABopp)
    #print(abli)
    i = visitset.pop()
    for j in filter(lambda x: s[x-1]!='C',graphAB[i]):
        decrementAB(j,i)
        if not adjAB(j):
            visitset.add(j)
    s[i-1] = 'C'

#print(graphAB)
#print(graphABopp)

sset= set(s)
sset.add('C')
sset.remove('C')
if bool(sset):
    print('Yes')
else:
    print('No')





Measured memory_bytes: 58080
def getdata_input():
    while True:
        yield input()
def callFunc2(it):
    #A1,A2,A3=map(int, next(it).split())
    S=[""]*2
    S[1],S[0]=next(it).split()
    return("".join(S))
it=getdata_input()
print(callFunc2(it))

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int memo[510][510];

signed main() {
	int N, M, Q;
	cin >> N >> M >> Q;

	vector<pair<int, int>> v;
	rep(i, M) {
		int L, R;
		scanf("%lld %lld", &L, &R);
		memo[L][R]++;
	}

	REP(i, 1, N) REP(j, 1, N) {
		memo[i][j] += memo[i - 1][j];
	}
	REP(i, 1, N) REP(j, 1, N) {
		memo[i][j] += memo[i][j - 1];
	}

	rep(i, Q) {
		int L, R;
		scanf("%lld %lld", &L, &R);
		cout << memo[R][R] - memo[L - 1][R] << endl;
	}

    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define PI	3.1415926535897932384626433832795028841971
#define INF 100000000
#define EPS 1e-15
#define MOD 1000000007
using namespace std;

int n;
double x[51], y[51];
double ax = 0.0, ay = 0.0;

int main(){
	cin >> n;
	if(n%2 == 1){
		puts("NA");
		return 0;
	}
	rep(i,n){
		cin >> x[i] >> y[i];
		ax += x[i]; ay += y[i];
	}
	ax /= n; ay /= n;
	rep(i,n){
		x[i] -= ax; y[i] -= ay;
	}
	rep(i,n){
		int j = i+n/2;
		if(j >= n) j -= n;
		if(fabs(x[i])+EPS < fabs(x[j]) || fabs(x[i]) > fabs(x[j])+EPS){
			puts("NA");
			return 0;
		}
		if(fabs(y[i])+EPS < fabs(y[j]) || fabs(y[i]) > fabs(y[j])+EPS){
			puts("NA");
			return 0;
		}
	}
	printf("%.9f %.9f\n", ax, ay);
}

Measured memory_bytes: 1252
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

ll A[200010], F[200010];
ll N, K;

bool isOK(ll time) {//条件
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		sum += max(0ll, (A[i] * F[i] - time + F[i] - 1) / F[i]);
	}
	//cout << sum << endl;
	if (sum <= K) return true;
	else return false;
}

ll binary_search() {
	ll ng = -1; //満たすことのない最小値
	ll ok = 1000000000000; // 満たす最大値

	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;
		//cout << ng << " " << mid << " " << ok << " ";
		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	return ok;
}
int main()
{
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> F[i];
	}
	sort(A, A + N,greater<ll>());
	sort(F, F + N);
	cout << binary_search() << endl;
}

Measured memory_bytes: 3328
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int n,m;
int main(){
	cin>>n>>m;
	int R=0;
	R=(n-1)*(m-1);





	cout<<R<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)2e5+5;

ll closest(vector<ll>& s, ll& x) {
    int ret = lower_bound(s.begin(),s.end(),x) - s.begin();
    if(ret == s.size()) ret--;
    else if(ret>0) {
       if(abs(s[ret-1]-x)<abs(s[ret]-x)) {
        ret--;
       }
    }
    return s[ret];
}
ll solve(vector<ll>& s, vector<ll>& t, ll& x) {
    ll ret = 1e18;
    for(int i=lower_bound(s.begin(),s.end(),x)-s.begin(),j=i-10;j<i+10;j++) {
        if(j<0 || j>=s.size()) continue;
        ll p1 = s[j];
        ll p2 = closest(t,p1);
        ret = min(ret,abs(x-p1) + abs(p1-p2));
    }
    for(int i=lower_bound(t.begin(),t.end(),x)-t.begin(),j=i-10;j<i+10;j++) {
        if(j<0 || j>=t.size()) continue;
        ll p1 = t[j];
        ll p2 = closest(s,p1);
        ret = min(ret,abs(x-p1) + abs(p1-p2));
    }
    return ret;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a,b,q;
    cin>>a>>b>>q;
    vector<ll> s(a), t(b);
    for(int i=0;i<a;i++) {
        cin>>s[i];
    }
    for(int i=0;i<b;i++) {
        cin>>t[i];
    }
    while(q--) {
        ll x;
        cin>>x;
        cout<<solve(s,t,x)<<"\n";
    }
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N], B[MAX_N], S[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) cin >> B[i];
	rer(i, N, 0) S[i] = S[i + 1] + B[i];
	int ans = 0, sum = 0;
	rep(i, 0, N) {
		sum += A[i];
		MAX(ans, sum + S[i]);
	}
	cout << ans << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}



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

    int N;
    cin >> N;
    vector<int>A(N);
    cin >> A;

    REP(i, N)A[i]--;
    cout << accumulate(ALL(A), 0) << endl;
    return 0;

}

Measured memory_bytes: 256
// atcoder/abc137/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    map<string, lli> m;
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      sort(s.begin(), s.end());
      ++m[s];
    }
    lli sum = 0;
    each (i, m) {
      sum += i.second * (i.second - 1) / 2;
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
using namespace std;
bool isStraight(int* a)
{
    if(a[0]==1&&a[1]==10&&a[2]==11&&a[3]==12&&a[4]==13) return true;
    for(int i=1;i<5;i++) if(a[i]!=a[i-1]+1) return false;
    return true;
}
int main()
{
    int a[5]; char ch;
    while(cin >> a[0] >> ch >> a[1] >> ch >> a[2] >> ch >> a[3] >> ch >> a[4])
    {
        int sum=1; int pair=0;
        sort(a,a+5);
        for(int i=1;i<5;i++)
        {
            int tmp=1;
            while(i<5 && a[i-1]==a[i]) {tmp++; i++;}
            sum=max(tmp,sum);
        }
        bool flag=true;
        for(int i=1;i<5;i++)
        {
            if(flag && a[i-1]==a[i]) {pair++; flag=false;}
            else flag=true;
        }
        if(sum==4) cout << "four card" << endl;
        else if(sum==3 && pair==2) cout << "full house" << endl;
        else if(isStraight(a)) cout << "straight" << endl;
        else if(sum==3) cout << "three card" << endl;
        else if(pair==2) cout<< "two pair" << endl;
        else if(pair==1) cout << "one pair" << endl;
        else cout << "null" << endl;
    }
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        for (int i = 0; i < a; i++) {
            cout << b;
        }
    }
    else {
        for (int i = 0; i < b; i++) {
            cout << a;
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map {it.toInt()}
    val A = readLine()!!.split(" ").map{it.toLong()}

    val T = LongArray(N) { 0L }

    val MOD = 1e9.toLong() + 7
    var res = ModInt(0L, MOD)

    for (i in A.indices) {
        for (j in 0 until i) {
            if (A[j] > A[i]) {
                T[i]++
            }
        }
        res += ModInt(K.toLong(), MOD) * T[i]
    }

    val S = LongArray(N) { i ->
        A.count { it > A[i] }.toLong()
    }

    for (i in S) {
        res += ModInt(i, MOD) * K.toLong() * (K - 1).toLong() / 2L
    }

    println(res.value)
}

class ModInt (value: Long, val mod: Long) {
    init {
        if (mod <= 0) {
            throw IllegalArgumentException("ModInt cannot be created for non-positive modulus: $mod")
        }
    }

    val value = (value % mod + mod) % mod

    private fun assertSameMod(other: ModInt) {
        if (mod != other.mod) {
            throw IllegalArgumentException(
                "You cannot operate summation, subtraction and multiplication for ModInts with different moduli: $mod, ${other.mod}"
            )
        }
    }

    operator fun unaryMinus() = ModInt(mod - value, mod)

    operator fun plus(other: ModInt): ModInt {
        assertSameMod(other)

        return ModInt((value + other.value) % mod, mod)
    }

    operator fun plus(other: Long) = plus(ModInt(other, mod))

    operator fun minus(other: ModInt): ModInt {
        assertSameMod(other)

        return plus(-other)
    }

    operator fun minus(other: Long) = minus(ModInt(other, mod))

    operator fun times(other: ModInt): ModInt {
        assertSameMod(other)

        return ModInt((value * other.value) % mod, mod)
    }

    operator fun times(other: Long) = times(ModInt(other, mod))

    fun pow(k: Long): ModInt {
        var res = 1L
        var a = value
        var l = k

        while (l > 0) {
            if ((l and 1L) == 1L) {
                res = (res * a) % mod
            }

            a = a * a % mod
            l /= 2L
        }

        return ModInt(res, mod)
    }

    /**
     * Returns an inverse element of the value.
     * To ensure `m * m.inv() = 1`, the modulus should be prime, since it uses Fermat's little theorem.
     */
    fun inv() = pow(mod - 2)

    operator fun div(other: ModInt): ModInt {
        assertSameMod(other)
        if (other.value == 0L) {
            throw ArithmeticException()
        }

        return times(other.inv())
    }

    operator fun div(other: Long) = div(ModInt(other, mod))
}

class ModCombination(val n: Long, val mod: Long) {
    private val fact = Array(n.toInt() + 1) { ModInt(1, mod) }
    private val invfact = Array(n.toInt() + 1) { ModInt(1, mod) }

    init {
        for (i in 2..n.toInt()) {
            fact[i] = fact[i - 1] * i.toLong()
            invfact[i] = fact[i].inv()
        }
    }

    operator fun get(n: Long, m: Long): ModInt {
        if (m > n || n < 0 || m < 0) {
            return ModInt(0, mod)
        }

        return fact[n.toInt()] * invfact[m.toInt()] * invfact[(n - m).toInt()]
    }
}


Measured memory_bytes: 38792
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int inf=1e9;
struct edge{
	int k,w,next;
}e[1000005];
int n,m,home[205],cnt=-1,T;
char a[105][105];
void add(int x,int y,int w){
	cnt++;
	e[cnt].k=y;
	e[cnt].w=w;
	e[cnt].next=home[x];
	home[x]=cnt;
}
void insert(int x,int y,int w){
	add(x,y,w);add(y,x,0);
}
int q[205],d[205];
void bfs(){
	memset(d,-1,sizeof(d));
	d[0]=0;
	int tou=0,wei=1,k;
	q[0]=0;
	while(tou<wei){
		k=q[tou++];
		for(int i=home[k];~i;i=e[i].next) if(e[i].w&&d[e[i].k]==-1){
			d[e[i].k]=d[k]+1;
			q[wei++]=e[i].k;
		}
	}
}
int h[205];
int dfs(int k,int flow){
	if(k==T||!flow) return flow;
	int used=0,w;
	for(int i=home[k];~i;i=e[i].next)if(d[e[i].k]==d[k]+1){
		w=flow-used;
		w=dfs(e[i].k,min(w,e[i].w));
		used+=w;
		e[i].w-=w;
		e[i^1].w+=w;
	}
	if(used<flow) d[k]=-1;
	return used;
}
int dinic(){
	int flow=0;
	for(int i=0;i<=T;i++) h[i]=home[i];
	while(1){
		for(int i=0;i<=T;i++) home[i]=h[i];
		bfs();
		if(d[T]==-1) return flow>n*m?-1:flow;
		flow+=dfs(0,inf);
	}
}
int main(){
	memset(home,-1,sizeof(home));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
	T=n+m+1;
	for(int i=1;i<=n;i++){
		for(int p=1;p<=m;p++){
			if(a[i][p]=='o'){
				add(i,p+n,1);
				add(p+n,i,1);
			}
			if(a[i][p]=='S'){
				insert(0,i,inf);
				insert(0,p+n,inf);
			}
			if(a[i][p]=='T'){
				insert(i,T,inf);
				insert(p+n,T,inf);
			}
		}
	}
	printf("%d",dinic());
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int n, res = 0, res1 = 0, tmp;
    for (int i = 0; i < s.size(); i++) {
        n = s[i] - '0';
        if (i == 0) {
            res += n;
            res1 += 10 - n;
        } else {
            tmp = min(res + n, res1 + n + 1);
            res1 = min(res + 10 - n, res1 + 10 - (n + 1));
            res = tmp;
        }
    }
    cout << min(res, res1 + 1) << "\n";
    return 0;
}


Measured memory_bytes: 1948
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    ll x, y; cin >> x >> y;
    ll n = x * y - x;
    if(n % x == 0 and n % y != 0);
    else n = -1;
    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int A,B;
int main() {
	cin>>A>>B;

	for(int i=B-A+1;i<B+A;i++){
		cout<<i<<" ";
	}

	cout<<endl;


	return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
A = [0]*N
b = "R"
R = 0
cnt = 0
for i in range(N):
    cnt+=1
    if S[i]=="R":
        if b=="R":
            continue
        else:
            cnt=1
            b = "R"
    elif S[i]=="L":
        if b=="L":
            if cnt%2==1:
                A[R]+=1
            else:
                A[R+1]+=1
        else:
            R = i-1
            b="L"
            n = cnt//2
            A[i-1]+=n
            A[i]+=(cnt-n)
            cnt=0
print(*A)

Measured memory_bytes: 6400
n = int(input())
A = list(map(int,input().split()))
smallest = A[0]
ans = 0
for x in range(len(A)-1):
	if A[x] > A[x+1]:
		ans += A[x] - A[x+1] 
		A[x+1] = A[x]

print(ans)

		



Measured memory_bytes: 32220
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  rep(i,N-1) cin >> C[i];
  int ans = 0;
  rep(i,N) {
    ans += B[A[i]-1];
    if (i >= 1 && A[i]-A[i-1] == 1) ans += C[A[i-1]-1]; 
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <queue>

int main(int argc, char *argv[])
{
	int n,k;
	cin>>n>>k;

	int s=0,m;

	queue<int> p;
	for (int i=0;i<k;i++)
	{
		int t;
		cin>>t;
		p.push(t);
		s+=t;
	}
	m=s;

	for (int i=k;i<n;i++)
	{
		int t;
		cin>>t;
		s+=(t-p.front());
		p.pop();
		p.push(t);
		if (s>m) m=s;
		//cerr<<p.front()<<" t="<<t<<" s="<<s<<" m="<<m<<endl;
	}
	int z=(m+k);


	cout<<(z/2)<<(z%2?".5":"")<<endl;
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

res = r*g*b

for i in range(n):
    for j in range(n):
        jj = i+j
        k = jj+j
        if k >= n: break
        if s[i]!=s[jj] and s[jj]!=s[k] and s[k]!=s[i]:
            res-=1

print(res)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int H,A;
  	cin>>H>>A;
  	if(H%A==0){
      cout<<H/A<<endl;
    }
  	else{
      cout<<H/A+1<<endl;
    }
}

Measured memory_bytes: 256
# include "iostream"
# include "cstdio"
# include "vector"

using namespace std;

const int maxm=1e2+10;

int A[maxm];
int N,K;
vector<int> Ans;

void Add(int x){
	Ans.push_back(x);
	if(A[x]==0){
		puts("-1");
		exit(0);
	}
	A[x]--;
	return;
}
int main(){
	register int j,i,Last;
	scanf("%d%d",&N,&K);
	for(i=1;i<=N;i++) scanf("%d",A+i);
	A[0]=maxm*maxm;
	for(j=0;j<=K;j++){
		int x=0;
		for(i=1;i<=N;i++) if(i!=Last and A[i]<A[x]) x=i;
		for(i=1;i<=N;i++) if(i!=x and i!=Last) Add(i);
		Add(x);Last=x; 
	}
	printf("%d\n",Ans.size());
	for(i=0;i<Ans.size();i++) printf("%d ",Ans[i]);
	return 0;
}

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

#define V vector<int>
#define VV(v, n, m) vector<V> v(n, V(m));
#define _4(i, n) for(int i = 0; i < n; i++)
#define g_arr(arr, n) _4(i, n) cin >> arr[i];
#define p_vec(vec) _4(i, (int)vec.size()) cout << vec[i] << ' '; cout << endl;

typedef long long ll;

using namespace std;

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(0);
    cin.tie(NULL);

    int n;
    cin >> n;

    V h(n);

    g_arr(h, n);

    V dp(n);

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for(int i = 2; i < n; i++) {
        int co1 = abs(h[i] - h[i - 1]), co2 = abs(h[i] - h[i - 2]);
        dp[i] = min(dp[i - 1] + co1, dp[i - 2] + co2);
    }

    cout << dp[n - 1];

    return 0;
}



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

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class ACantWaitForHoliday {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        vector<string> date = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
        string s;cin >> s;
        for(int i = 0;i < 7;i++){
            if(s == date[i]) cout << 7 - i << endl;
        }
    }
};

int main() {
	ACantWaitForHoliday solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A,B,C,D;
  scanf("%d%d%d%d",&A,&B,&C,&D);
  int a=A/D;
  int b=A%D;
  int c=C/B;
  int d=C%B;
  if(b!=0){
    a=a+1;
  }  
  if(d!=0){
    c=c+1;
  }
  if(a<c){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


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

/* 各ノードを
 * * 親
 * * 一番左の子
 * * 右の兄弟
 * の3つの要素だけで表せる
 */

#define MAX 100005
#define NIL (-1)

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";
    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";
    cout << "[";
    for ( i = 0,  c = T[u].l; c != NIL; i++, c = T[c].r ) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void rec(int u, int p) {
    D[u] = p;
    if (T[u].r != NIL) rec(T[u].r, p);
    if (T[u].l != NIL) rec(T[u].l, p + 1);
}

int main() {
    int i, j, d, v, c, l, r;
    cin >> n;
    // initialize
    for(i = 0; i < n; i++) {
        T[i].p = T[i].l = T[i].r = NIL;
    }
    for (i = 0 ; i < n; i++) {
        cin >> v >> d;
        for(j = 0; j < d; j++) {
            cin >> c;
            // j = 0 のときは、親の一番左の子として登録
            // j >= 1 のときは親から見た左の子にとっての右の兄弟として登録
            if ( j == 0 ) T[v].l = c;
            else T[l].r = c;
            l = c;  // ここで子の位置を覚えておく
            T[c].p = v;  // 子に親を登録
        }
    }
    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) r = i;
    }
    rec(r, 0);
    for (int i = 0; i < n; i++) print(i);
    return 0;
}



Measured memory_bytes: 7664