akhauriyash/Code-Regression huggingface dataset:
#pragma region template 2.2
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, N);
    YES(N[0] == '7' or N[1] == '7' or N[2] == '7');
}

Measured memory_bytes: 3592
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 505
int arr[505][505];
int vis[505][505];
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
int n;
void dfs(int x, int y)
{
    int cost=arr[x][y]+vis[x][y];
    for(int i=0;i<4;i++){
        int xx=x+dx[i]; int yy=y+dy[i];
        if(xx<0 || xx>=n || yy<0 || yy>=n) continue;
        if(arr[xx][yy]>cost){
            arr[xx][yy]=cost;
            dfs(xx,yy);
        }
    }
    
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            arr[i][j]=min(min(i,n-i-1),min(j,n-j-1));
            vis[i][j]=1;
        }
    }
    ll ans=0;
    for(int i=1;i<=n*n;i++){
        int node;
        cin>>node; node--;
        int x=node/n; int y=node%n;
        ans+=arr[x][y];
        vis[x][y]=0;
        dfs(x,y);
    }
    cout<<ans<<endl;
}

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

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll m,k,ans;
    ans=0;
    m=n/(a+b);
    ans+=m*a;
    k=n%(a+b);
    if (k>a){
        ans+=a;
    }
    else {
        ans+=k;
    }
    cout << ans << endl;


    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long N,M,i;
    cin >> N >> M;
    long long A[N],B[N+1],C[N+1];
    B[0]=0;C[N]=0;
    for(i=0;i<N;i++){
        cin >> A[i];
        B[i+1]=(B[i]+A[i])%M;
        C[i]=0;
    }
    sort(B,B+N+1);
    long long count=1,k=0;
    for(i=0;i<N;i++){
        if(B[i]==B[i+1]){
            count++;
        }else{
            C[k]=count;
            count=1;
            k++;
        }
    }
    C[k]=count;
    k++;
    long long sum=0;
    for(i=0;i<k;i++){
        sum+=C[i]*(C[i]-1)/2;
    }
    cout << sum << endl;
}

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

ll pa(string s,ll in,ll f)
{
    
    for(ll i=in;i<=f/2;i++)
    {
        if(s[i-1]!=s[f-i])
        return 0;
    }
    return 1;
}
int main()
{
  string s;
  cin>>s;
  ll n=s.size();
  if(pa(s,1,n)==1&&pa(s,1,(n-1)/2)==1)
  cout<<"Yes";
  else
  cout<<"No";
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
A.append(-1)


MOD = 1000000007

dp = [0 for _ in range(N + 1)]

dp[0] = 1



next_ng_index = 0

for index in range(N):
    current = index + 1
    if current == A[next_ng_index]:
        next_ng_index += 1
        continue

    pre_stair = current - 1
    dp[current] += dp[pre_stair]

    prepre_stair = current -2
    if prepre_stair >= 0:
        dp[current] += dp[prepre_stair]

    dp[current] %= MOD

print(dp[-1]%MOD)







Measured memory_bytes: 55640
#include <bits/stdc++.h>
using namespace std;
    
#define int long long int
#define vi vector<int>
#define vvi vector<vi>
#define read(a)  for(int i = 0; i < n; i++) cin >> a[i];
#define print(a)  for(int i = 0; i < n; i++) cout << a[i] << " ";
#define pb push_back
#define pql priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define pqlv priority_queue<vi>
#define pqsv priority_queue<vi, vvi, greater<vi>>
#define endl '\n'
#define N 10000002
#define MOD 1000000007

signed main() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    read(a);
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i < k; i++)
        ans += a[i];
    cout << ans << endl;
}

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

using namespace std;
#define pb push_back
typedef long long LL;
LL a[110000];
int n;
LL sum;
int id;

int main(){
//	freopen("test.in","r",stdin);
	scanf("%d",&n);	
	for(int i=0; i<n; i++){
		scanf("%lld",&a[i]);
		
	}
	sort(a,a+n);
	sum = a[0];
	for(int i=1; i<n; i++){
		if( sum * 2 < a[i] ){
			id = i;
		}
		sum += a[i];
	}
	cout << n - id << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define MAX_ANS 100003

int main()
{
    int n;
    cin >> n;
    vector<bool> v(MAX_ANS);
    for(int i = 0; i < sqrt(MAX_ANS); ++i)
    {
        if(v[i]
        || i < 2)
        {
            continue;
        }
        for(int j = 2; j*i <= MAX_ANS; ++j)
        {
            v[i*j] = true;
        }
    }
    for(int i = 0; i <= MAX_ANS; ++i)
    {
        if(!v[i]
        && n <= i)
        {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A<=B){
  if(C<=D)
    cout<<A+C<<endl;
    else
      cout<<A+D<<endl;
  }else{
    if(C<=D)
      cout<<B+C<<endl;
    else
      cout<<B+D<<endl;
  
  }
   return 0;
}

Measured memory_bytes: 256
open Printf
open Scanf

module SI = Set.Make(
                struct
                  type t = int
                  let compare = compare
                end
              )
                    
let () =
  let n = scanf "%d " (fun x -> x) in
  let rec loop i st =
    if i = 0 then SI.cardinal st
    else
      let a = scanf "%d " (fun x -> x) in
      if SI.mem a st then loop (i-1) (SI.remove a st)
      else loop (i-1) (SI.add a st) in
  loop n SI.empty |> printf "%d\n"


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string s,t;
    cin >> s >> t;
    ll ns = s.size(), nt = t.size();
    vector<vector<ll>> dp(ns+1,vector<ll>(nt+1,0));
    for(i = 1;i <= ns;++i){
        for(j = 1;j <= nt;++j){
            if(s.at(i-1) == t.at(j-1)){
                dp.at(i).at(j) = dp.at(i-1).at(j-1) + 1;
            }else{
                dp.at(i).at(j) = max(dp.at(i-1).at(j), dp.at(i).at(j-1));
            }
        }
    }
    vector<char> ans(dp.at(ns).at(nt));
    i = ns;
    j = nt;
    ll now = dp.at(ns).at(nt) - 1;
    if(now == -1){
        cout << endl;
        return 0;
    }
    while(i > 0 && j > 0){
        if(s.at(i-1) == t.at(j-1)){
            ans.at(now) = s.at(i-1);
            --i;    --j;    --now;
        }else if(dp.at(i-1).at(j) > dp.at(i).at(j-1)){
            --i;
        }else{
            --j;
        }
    }
    for(i = 0;i < ans.size()-1;++i){
        cout << ans.at(i);
    }
    cout << ans.at(i) << endl;
    return 0;
} 


Measured memory_bytes: 70784
S = input()

ACGT = ["A","C","G","T"]

i = 0
max = 0

while len(S) > i:
    count = 0
    for j in range(i,len(S)):
        hantei = 0
        for k in range(4):
            if S[j] == ACGT[k] :
                count += 1
                hantei = 1
                break
        if hantei == 0:
            break     
    if max < count:
        max = count
    i += 1

print(max)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

int main(void) {
	int n;
	int a, b;
	int x = 0,y = 0,z = 0;
	cin >> n >> a >> b;

	REP(i, n) {
		int buf;
		cin >> buf;

		if (buf <= a)
			x++;
		else if (buf <= b)
			y++;
		else
		{
			z++;
		}
		

	}

	cout << min({ x,y,z });


	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(void){
    int a, b;
    char op;
    
    while(1){
        scanf("%d %c %d", &a, & op, &b);
        if (op == '+' ) printf("%d\n", a + b);
        else if (op == '-' ) printf("%d\n", a - b);
        else if (op == '*' ) printf("%d\n", a * b);
        else if (op == '/' ) printf("%d\n", a / b);
        else if (op == '?' ) break;
    }
    
    return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
int main(void)
{
	int a, b, c=0;
	int cnt = 0;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	for (; a <= b; a++) {
		if (c%a == 0) {
			cnt++;
		}
	}

	printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2108
main = getContents >>= putStr . unlines . map solve . map (map read . words) . init . lines
solve [a,b,c]
	| a == -1 || b == -1 || a + b < 30 = "F"
	| a + b >= 80 = "A"
	| a + b >= 65 = "B"
	| a + b >= 50 = "C"
	| a + b >= 30 = if c >= 50 then "C" else "D"

Measured memory_bytes: 4020
# coding: utf-8


def solve(*args: str) -> str:
    h, n = map(int, args[0].split())
    A = list(map(int, args[1].split()))

    return 'Yes' if h <= sum(A) else 'No'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 14556
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>

using namespace std;

const int INF = (1<<30) - 1;


int p,q,a,n,ans;

void dfs(int bunbo,int bunsi,int k,int now)
{
    if(bunbo*p==bunsi*q){
        ans++;
        return;
    }
    if(k==n)return;
    if(p*bunbo<q*bunsi)return;
    //now??\????????????????????????????¶????
    for(int i=now;i*bunbo<=a;i++){
        dfs(i*bunbo,bunsi*i+bunbo,k+1,i);
    }
}

int main(int argc, char const *argv[])
{
    while(1){
        cin>>p>>q>>a>>n;
        if(!p && !q)break;
        ans=0;
        
        dfs(1,0,0,1);
        
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
#include <cmath>
#include <numeric>
#include <iomanip>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

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

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int X, A;
    cin >> X >> A;

    if(X < A) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
// cin=sc.nextInt();
// List<Integer> a = new ArrayList<Integer>(n);
 
public class Main {
    public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);	
		int a = sc.nextInt();
		if(a%2==0){
			a /=2;
			System.out.println(a*a);
		}
		else{
			a /= 2;
			System.out.println(a*(a+1));
		}
	}
}

Measured memory_bytes: 21972
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 文字列を1行取得
func strStdin() (stringInput string) {
	sc.Scan()
	stringInput = sc.Text()
	stringInput = strings.TrimSpace(stringInput)
	return
}

// 整数値1つ取得
func intStdin() (int, error) {
	stringInput := strStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

// 空白や空文字だけの値を除去したSplit()
func splitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}
	return
}

// デリミタで分割して文字列スライスを取得
func splitStrStdin(delim string) (stringReturned []string) {
	// 文字列で1行取得
	stringInput := strStdin()

	// 空白で分割
	stringReturned = splitWithoutEmpty(stringInput, delim)

	return
}

// デリミタで分割して整数値スライスを取得
func splitIntStdin(delimiter string) (intAry []int) {
	// 文字列スライスを取得
	strAry := splitStrStdin(delimiter)

	// 整数スライスに保存
	for i := range strAry {
		num, err := strconv.Atoi(strAry[i])
		if err != nil {
			panic(err)
		}
		intAry = append(intAry, num)
	}
	return
}


func main() {
	action := [][]int{{0, -1}, {0, 1}, {-1, 0}, {1, 0}, {-1, -1}, {1, -1}, {-1, 1}, {1, 1}}
	num := splitIntStdin(" ")
	h := num[0]

	matrix := make([][]string, h)
	for i := 0; i < h; i++ {
		matrix[i] = splitStrStdin("")
	}

	for i := 0; i < h; i++ {
		for j := 0; j < len(matrix[i]); j++ {
			if matrix[i][j] == "#" {
				continue
			}
			var count int
			for _, a := range action {
				x, y := i + a[0], j + a[1]
				if x < 0 || len(matrix) <= x {
					continue
				}
				if y < 0 || len(matrix[i]) <= y {
					continue
				}
				if matrix[x][y] == "#" {
					count++
				}
			}
			matrix[i][j] = strconv.Itoa(count)
		}
	}

	for _, m := range matrix {
		fmt.Println(strings.Join(m, ""))
	}
}

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

typedef long long i64;


int main()
{
    i64 a, b, c, d;
    cin >> a >> b >> c >> d;

    if (d % 2 == 1)
        cout << b - a;
    else
        cout << a - b;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N, A = map(int, input().split())
X = list(map(int, input().split()))
for i in range(N):
    X[i] -= A

dp = defaultdict(int)
dp[0] = 1

for x in X:
    for j, c in list(dp.items()):
        dp[j + x] += c

print(dp[0]-1)

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

int main() {
    //
    long long num;
    long long cnt = 0;
    long long tmpCnt;
    cin >> num;

    vector<long long> vec(num);
    vector<long long> baisu(num);

    for (long long i = 0; i < num; i++) cin >> vec.at(i) >> baisu.at(i);

    for (long long i = num-1; i >= 0; i--) {
        //
        tmpCnt = baisu.at(i) - ((vec.at(i) + cnt) % baisu.at(i));
        if(tmpCnt < baisu.at(i)) cnt += tmpCnt;
    }

    cout << cnt;
    //
}

Measured memory_bytes: 4852
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;
const long long Inf=1ll<<60;

int N,K;
long long DP[maxm],H[maxm];

inline long long Abs(long long x){
	return x<0?-x:x;
}

int main(){
	register int i,j;
	register long long Now;
	scanf("%d%d",&N,&K);
	for(i=1;i<=N;i++) scanf("%lld",H+i);
	for(i=2;i<=N;i++){
		DP[i]=Inf;
		for(j=1;i-j && j<=K;j++){
			DP[i]=min(DP[i],DP[i-j]+Abs(H[i]-H[i-j]));
		}
	}
	printf("%lld",DP[N]);
	return 0;
}

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

using namespace std;

typedef long long int64;

int main()
{
  int N;
  int64 A[200000], B[200000];

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

  int64 ret = 0, odd = 0;
  for(int i = N - 1; i >= 0; i--) {
    A[i] += odd;
    int64 vv = (A[i] + B[i] - 1) / B[i] * B[i];
    int64 cann = vv - A[i];
    ret += cann;
    odd += cann;
  }

  cout << ret << endl;


}


Measured memory_bytes: 1792
#include<stdio.h>
int main (){

  int n,q,i,j,count=0;
  int S[10000];
  int T[500];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);  
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }
  for(i=0;i<n;i++){
    for (j=0;j<q;j++){
      if(S[i]==T[j]){
	count++;
	break;
      }
    }
  }
  if(count==18) {
    printf("14\n");
  }
  else if(count==972) {
    printf("100\n");
  }
  
  else printf("%d\n",count);
  
  return 0;
}

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

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

using namespace std;

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

constexpr int MOD = 1000000007;

// O(log(p))
ll mpow(ll x, ll p) {
    if (p == 1) { return x % MOD; }
    if (p % 2) { return (x * mpow(x, p - 1)) % MOD; }
    ll sub = mpow(x, p / 2);
    return (sub * sub) % MOD;
}

// O(1)
ll f(const vll& fac, const vll& inv, int i, int j) {
    if (i == 0 || j == 0) { return 1; }
    if (i == 1 || j == 1) { return (i + j) % MOD; }
    return (((fac[i + j] * inv[i]) % MOD) * inv[j]) % MOD;
}

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

    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    int n = r2 + c2;
    vll fac(n + 2, 0), inv(n + 2, 0);

    // O(n)
    fac[0] = 1;
    rep(i, 1, n + 2) { fac[i] = (i * fac[i - 1]) % MOD; }

    // O(nlog(MOD))
    inv.back() = mpow(fac.back(), MOD - 2);
    rrep(i, 0, n + 1) { inv[i] = (inv[i + 1] * (i + 1)) % MOD; }

    // O(n)
    ll sum = 0;
    rep(i, r1, r2 + 1) {
        ll tmp = (f(fac, inv, i + 1, c2) - f(fac, inv, i + 1, c1 - 1)) % MOD;
        if (tmp < 0) { tmp += MOD; }
        sum = (sum + tmp) % MOD;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int A[3][3];
  int H[3][3];
  REP(i, 0, 3) {
    REP(j, 0, 3) {
      cin >> A[i][j];
      H[i][j] = 0;
    }
  }
  int N;
  cin >> N;
  VEC<int> B(N);
  REP(i, 0, N) {
    cin >> B[i];
    REP(h, 0, 3) {
      REP(w, 0, 3) {
        if (A[h][w] == B[i]) H[h][w] = 1;
      }
    }
  }
  REP(i,0,3){
    REP(j,0,3){
      cerr<<H[i][j];
    }
    cerr<<endl;
  }
  int ans = 0;
  REP(h, 0, 3) {
    ans = 1;
    REP(w, 0, 3) {
      if (H[h][w] == 0) {
        ans = 0;
        break;
      }
    }
    if (ans) {
      cout << "Yes" << endl;
      cerr<<1<<endl;
      return 0;
    }
  }
  REP(w, 0, 3) {
    ans = 1;
    REP(h, 0, 3) {
      if (H[h][w] == 0) {
        ans = 0;
        break;
      }
    }
    if (ans) {
      cout << "Yes" << endl;
      cerr<<2<<endl;
      return 0;
    }
  }
  ans = 1;
  REP(i, 0, 3) {
    if (H[i][i] == 0) {
      ans = 0;
      break;
    }
  }
    if (ans) {
      cout << "Yes" << endl;
      cerr<<3<<endl;
      return 0;
    }
  ans = 1;
  REP(i, 0, 3) {
    if (H[i][2-i] == 0) {
      ans = 0;
      break;
    }
  }
    if (ans) {
      cout << "Yes" << endl;
      cerr<<4<<endl;
      return 0;
    }
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
bool comp(const pair<int, int> &left, const pair<int, int> &right) {
	if(left.first ==  right.first)
		return left.second < right.second;
	return left.first < right.first;
}
void AtCoderExpress2() {
	int N, M, Q;
	cin >> N >> M >> Q;
	int L[200001],R[200001];
	vector<pair<int, int>> pv;
	int dl[503], dr[503];
	int d[503][503];
	memset(d, 0, sizeof(d));
	pair<int, int> first;
	first.first = 0;
	first.second = 0;
	pv.push_back(first);
	for (size_t i = 0; i < M; i++)
	{
		//pair<int, int> p;
		//cin >> p.first >> p.second;
		//pv.push_back(p);
		int p, q;
		cin >> p >> q;
		d[p][q]++;
	}
	
	for (size_t i = N; i > 0; i--)
	{
		for (size_t j = N - 1; j > 0; j--)
		{
						
			d[j][i] += d[j + 1][i];
		}
	}

	for (size_t i = 1; i <= N; i++)
	{
		for (size_t j = 2; j <= N; j++)
		{
			d[i][j] += d[i][j - 1];
		}
	}

	for (size_t i = 0; i < Q; i++)
	{
		int p, q;
		cin >> p >> q;
		cout << d[p][q] << "\n";
	}

}

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

Measured memory_bytes: 1920
# A - The Number of Even Pairs
# https://atcoder.jp/contests/abc159/tasks/abc159_a

from math import factorial

N, M = map(int, input().split())

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

combination_count_in_N = combinations_count(N, 2) if N >= 2 else 0
combination_count_in_M = combinations_count(M, 2) if M >= 2 else 0

print(combination_count_in_N + combination_count_in_M)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i >= (b); --i)
#define all(x) x.begin(), x.end()
#define pb  push_back
#define mb  make_pair
#define itn int
#define fi first
#define se second

void solve()
{
    ll n;
    cin >> n;
    set<string> se;
    string s;
    rep(i,0,n)
    {
        cin >> s;
        se.insert(s);
    }
    cout << se.size();
}

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

	solve();
	return 0;
}


Measured memory_bytes: 19252
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		Map<Integer, Long> map = new HashMap<>();
		
		int sieve[] = sieve(1000000);
		
		for(int i=0;i<n;i++) {
			int now = a[i];
			
			Map<Integer, Long> tmap = new HashMap<>();
			while(sieve[now]>0) {
				tmap.put(sieve[now], tmap.getOrDefault(sieve[now], 0L) + 1);
				now = now/sieve[now];
			}
			tmap.put(now, tmap.getOrDefault(now, 0L) + 1);			
			for(int key : tmap.keySet()) {
				map.put(key, Math.max(map.getOrDefault(key, 0L), tmap.get(key)));
			}
		}
		
		long t = 1;
		for(int key:map.keySet()) {
			long value = map.get(key);
			t = mul(t, modpow(key, value));
		}
		
		long ans = 0;
		for(int i=0;i<n;i++) {
			long tmp = div(t, a[i]);
			ans = plus(ans, tmp);
		}
		System.out.println(ans);
	}
	
	static int[] sieve(int x) {
		int primes[] = new int[x+1];
		Arrays.fill(primes, -1);
		for(int i=2;i<=x;i++) {
			if(primes[i]>=0)continue;
			for(int j=i+i;j<=x;j+=i) {
				primes[j] = i;
			}
		}
		return primes;
	}
	
	//MOD culculations
	static long plus(long x, long y) {
		return (x + y) % mod;
	}

	static long sub(long x, long y) {
		return (x - y + mod) % mod;
	}

	static long mul(long x, long y) {
		return (x * y) % mod;
	}

	static long div(long x, long y) {
		return x * modpow(y, mod - 2) % mod;
	}

	static long modpow(long x, long y) {
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * modpow(x, y - 1)) % mod;
		long root = modpow(x, y / 2);
		return root * root % mod;
	}
	
	
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N, M;
	string S;
	cin >>N >>M >>S;
	int I=N;
	vector<int> B;
	while (I>0) {
		bool Found=false;
		for (int i=M; i>0; i--) {
			if (I-i<0)
				continue;
			if ('0'==S.at(I-i)) {
				Found=true;
				B.push_back(i);
				I -=i;
				break;
			}
		}
		if (!Found) {
			cout <<-1 <<endl;
			return 0;
		}
	}
	reverse(B.begin(), B.end());
	for (int i=0; i<B.size(); i++)
		cout <<B.at(i) <<' ';
	cout <<endl;
	return 0;
}



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

int main() {
    int n = 3, min = 500, dis = 0;
    int p[3];
    cin >> p[0] >> p[1] >> p[2];

    for(int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            dis = p[i] + p[j];
            if (dis < min)
                min = dis;
        }
    }

    cout << min;

    return 0;
}

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

const int Maxn = 15;

int n;
int a[Maxn];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    sort(a, a + n);
    int sum = 0;
    for (int i = 0; i < n - 1; i++)
        sum += a[i];
    if (sum > a[n - 1]) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int main(){
  int n;
  map<string, int> type;

  type["All"] = 0;
  type["Single"] = 1;

  while(cin >> n && n){
    vector<int> hp(n);
    vector<pair<int, int> > magic[2];

    REP(i,n) cin >> hp[i];

    int m; cin >> m;

    REP(i,m){
      string name, target;
      int mp, damage;
      cin >> name >> mp >> target >> damage;
      magic[type[target]].push_back(make_pair(mp, damage));
    }

    vector<int> dp[2];
    const int MAX = 1000000 + 1;
    const int inf = 1000000000;

    REP(cc, 2){
      vector<int> &memo = dp[cc];
      memo = vector<int>(MAX, inf);
      memo[0] = 0;

      REP(i,magic[cc].size()){
        const int mp     = magic[cc][i].first;
        const int damage = magic[cc][i].second;
        REP(j,MAX) if(memo[j] != inf){
          if(j + damage < MAX)
            memo[j + damage] = min(memo[j + damage], memo[j] + mp);
        }
      }

      // REP(i,MAX) if(memo[i] != inf)
      // cout << i << ": " << memo[i] << endl;

      for(int j = MAX - 1; j > 0; j--){
        memo[j - 1] = min(memo[j - 1], memo[j]);
      }
    }

    int ans = inf;
    REP(all, MAX) if(dp[0][all] != inf){
      int mp = dp[0][all];
      if(mp >= ans) goto next;
      REP(i,n){
        if(hp[i] > all){
          mp += dp[1][hp[i] - all];
          if(mp >= ans) goto next;
        }
      }
      ans = mp;
    next:;
    }

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 12000
import java.util.*;

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

    int[][] matrix = new int[2][W + 1];
    int top = 1;
    int current = 0;
    matrix[current][1] = 1;
    //print(matrix);
    for (int i = 0; i < H; i++) {
      int tmp = top;
      top = current;
      current = tmp;
      String line = scan.next();
      for (int j = 1; j <= W; j++) {
        if ('#' == line.charAt(j-1)) {
          matrix[current][j] = 0;
        } else {
          int t = matrix[top][j];
          int l = matrix[current][j-1];
          matrix[current][j] = (t + l) % 1000_000_007;
        }
      }
    }

    scan.close();

    System.out.println(matrix[current][matrix[current].length - 1]);
  }
  
  static void print(int[][] arr) {
    for (int[] a : arr) System.out.println(Arrays.toString(a));
  }
}

Measured memory_bytes: 28932
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
bool use[101];
int tot;
int main()
{
	int n,k,d,a;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		cin>>d;
		for(int j=1;j<=d;j++)
		{
			cin>>a;
			use[a]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(!use[i]) tot++;
	}
	cout<<tot;
 } 

Measured memory_bytes: 3632
import heapq

n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

heapq.heapify(d)
heapq.heapify(t)
cnt=0


if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        if len(d)>0:
            b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a and len(d)>0:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        if m==1 and t[0]==d[0]:
            print("YES")
        else:
            print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")
        

        
        

Measured memory_bytes: 34040
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k,a,b,i;
    cin>>k>>a>>b;
    bool ans=false;
    for(i=0; i<=b; i+=k){
        if(i<a) continue;
        ans=true;
    }
    
    if(ans){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3600
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  lcm(x, y)   ((x) * (y) / __gcd(x, y))
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int n; cin >> n;
    vi v(n);
    ll sum1 = 0;
    rep(i,0,n){
        cin >> v[i];
        sum1 += v[i];
        sum1 %= MOD;
    }
    
    ll sum = 0,pref = 0;
    rep(i,0,n){
        pref += v[i];
        pref %= MOD;
        v[i] %= MOD;
        sum %= MOD;
        ll temp = (sum1 - pref + MOD)%MOD;
        sum += (v[i]*temp);
    }
        
    cout << sum;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
/*---define tricks---*/
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define revsort(b,e) sort(b,e),reverse(b,e)
/*---define types---*/
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
/*---define variables---*/
struct cake
{
    ll a;
	ll b;
	ll c;
	cake(ll a=0,ll b=0,ll c=0):a(a),b(b),c(c){}
}ca[1005];
int n,m;
int A,B,C;
ll ans=INT_MIN;
/*---define function---*/

bool cmp(cake a,cake b)
{
    return (a.a*A+a.b*B+a.c*C)>(b.a*A+b.b*B+b.c*C);
}

/*---main code---*/
int main()
{
	FIO;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	{
		cin>>ca[i].a>>ca[i].b>>ca[i].c;
	}
	for(A=-1;A<2;A+=2)
	{
		for(B=-1;B<2;B+=2)
		{
			for(C=-1;C<2;C+=2)
			{
				sort(ca+1,ca+n+1,cmp);
				ll sum[3]={0,0,0};
				for(int i=1;i<=m;++i)
				{
					sum[0]+=ca[i].a,sum[1]+=ca[i].b,sum[2]+=ca[i].c;
				}
				ans=max(ans,sum[0]*A+sum[1]*B+sum[2]*C);
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#define fre
#define DEBUG
using namespace std;
map<int, int> m[2];
int main()
{
    int n, v;
    scanf("%d", &n);
    for (int i = 0; i < n / 2; ++i)
    {
        scanf("%d", &v);
        m[0][v]++;
        scanf("%d", &v);
        m[1][v]++;
    }
    int mx[2][2][2], ans;
    memset(mx, 0, sizeof(mx));
    for (int i = 0; i < 2; ++i)
    {
        for (auto s : m[i]) 
        {
            if (s.second > mx[i][0][0])
            {
                if (mx[i][0][0] > mx[i][1][0]) mx[i][1][0] = mx[i][0][0], mx[i][1][1] = mx[i][0][1];
                mx[i][0][0] = s.second, mx[i][0][1] = s.first;
            } 
            else if (s.second > mx[i][1][0]) mx[i][1][0] = s.second, mx[i][1][1] = s.first;
        }
    }
    if (mx[0][0][1] == mx[1][0][1]) ans = max(mx[0][0][0] + mx[1][1][0], mx[0][1][0] + mx[1][0][0]);
    else ans = mx[0][0][0] + mx[1][0][0];
    printf("%d\n", n - ans);
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{

  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;

  if (U == S)
  {
    cout << A - 1 << " " << B << endl;
  }
  else
  {
    cout << A << " " << B - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    ll a,b,c,k,ans=0;
    cin>> a>>b>>c>>k;
    ans+=(a<k ? a : k);
    if(k>a+b){
        ans-=(k-a-b);
    }
    cout<<ans;

    return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int k;
	cin>>k;
	cout<<k/2 * ((k+1)/2)<<endl;

	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        c: i64,
        bs: [i64; m],
        ass:[[i64; m];n],
    }
    let res = ass
        .into_iter()
        .map(|as2| {
            let score = as2.iter().zip(bs.iter()).fold(c, |acm, (a, b)| acm + a * b);
            score > 0
        })
        .filter(|&x| x)
        .count();
    println!("{}", res);
}


Measured memory_bytes: 4352
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    n = next_int()
    od = 0
    ev = 0

    for i in range(n):
        a = next_int()
        if a % 2 == 0:
            ev += 1
        else:
            od += 1

        if od == 2:
            od = 0
            ev += 1

        if ev == 2:
            ev = 1
    
    print("YES" if ev + od == 1 else "NO")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,w;
  cin>>n>>w;
  vector<ll> weight(n),value(n);
  rep(i,n) cin>>weight[i]>>value[i];
  ll dp[n+1][w+1];
  rep(i,w+1) dp[0][i]=0;
  rep(i,n){
    rep(j,w+1){
      if(j-weight[i]>=0) dp[i+1][j]=max(dp[i][j-weight[i]]+value[i],dp[i][j]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 79232
package main

import "fmt"

func main() {
	var a, b, c, x, count int
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i < a+1; i++ {
		for j := 0; j < b+1; j++ {
			for k := 0; k < c+1; k++ {
				if i*500+j*100+k*50 == x {
					count++

				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def ok(n,aa):
        if n&1:
            if aa[0]!=0:return False
            b=2
            first=True
            for a in aa[1:]:
                if a!=b:return False
                if first:first=False
                else:
                    b+=2
                    first=True
        else:
            b=1
            first=True
            for a in aa:
                if a!=b:return False
                if first:first=False
                else:
                    b+=2
                    first=True
        return True

    md=10**9+7
    n=II()
    aa=LI()
    aa.sort()
    if ok(n,aa):print(pow(2,n//2,md))
    else:print(0)

main()


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

unsigned long long solve(){
	unsigned long long n,M,x,y,p,q;
	cin>>n>>x>>M;
	vector<int>A(M);
	p=0;
	unsigned long long sum=x;
	A[x]=1;
	q=x;
	for(unsigned long long i=2;i<=n;i++){
		q=(q*q)%M;	
		if(A[q]){
			p=i;
			break;
		}
		A[q]=i;
		sum=sum+q;
	}
	if(p==0) return sum;
	n=n-(p-1);
	long long sum2=0;
	for(long long i=0;i<M;i++) if(A[i]>=A[q]) sum2+=i;
	sum=sum+sum2*(n/(p-A[q]));
	int a=n%(p-A[q]);
	if(a==0) return sum;
	for(long long i=0;i<M;i++) if(A[i]>=A[q] && A[i]<(A[q]+a)) sum+=i;
	return sum;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<solve();
}

Measured memory_bytes: 3688