akhauriyash/Code-Regression huggingface dataset:
/*
    BY - Darkworld1 ( Tanu kumar )
    college - AIT
    Problem - contest ( div 3 )
*/
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define rep(i,a,n) for( int i = a ; i < n ; i++ )
#define prep( i, a , n ) for ( int i = a ; i>= n ; i--)
#define   pr pair<int,int>
const int N = 13 , M=N,inf=(int)1e9;
const int mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
ll ans ;
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){

        int n , T ;
        cin >> n >>T ;
        vector < pair<int , int> > a(n,{0,0}) ;
        for ( int i = 0 ; i < n ; i++){
            cin >> a[i].ff >> a[i].ss;
        }
        int minm = 1001 ;
        for ( int i = 0 ; i < n ; i++){
            if( a[i].ss <= T)
                minm = min( minm , a[i].ff);
        }
        if(minm == 1001)
            cout <<"TLE";
        else
            cout << minm ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}
/*
    ---------------- lemmas-----------------------------------
   1)
   2)
   3)

*/


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

int main(void){
    while (1) {
        string s;
        cin >> s;
        if (s == ".") return 0;
        
        int ans = 0;
        for (int i = 0; i < 27; i++) {
            int p = i % 3, q = (i / 3) % 3, r = (i / 9) % 3;
            
            int neg[30], idx = 0;
            vector<char> ope;
            vector<int> val[30];
            for (int i = 0; i < 30; i++) neg[i] = 0;
            for (int j = 0; j < s.size(); j++) {
                if (char(s[j]) == '-') neg[idx]++;
                else if (char(s[j]) == '+') ope.push_back(1);
                else if (char(s[j]) == '*') ope.push_back(2);
                else if (char(s[j]) == 'P') {
                    if (neg[idx] % 2 == 0) val[idx].push_back(p);
                    else val[idx].push_back(2 - p);
                    neg[idx] = 0;
                }
                else if (char(s[j]) == 'Q') {
                    if (neg[idx] % 2 == 0) val[idx].push_back(q);
                    else val[idx].push_back(2 - q);
                    neg[idx] = 0;
                }
                else if (char(s[j]) == 'R') {
                    if (neg[idx] % 2 == 0) val[idx].push_back(r);
                    else val[idx].push_back(2 - r);
                    neg[idx] = 0;
                }
                else if (char(s[j]) == '(') idx++;
                else if (char(s[j]) == ')') {
                    idx--;
                    if (ope[ope.size() - 1] == 1) {
                        if (neg[idx] % 2 == 0) 
                        val[idx].push_back(max(val[idx + 1][0], val[idx + 1][1]));
                        else val[idx].push_back(2 - max(val[idx + 1][0], val[idx + 1][1]));
                    }
                    else {
                        if (neg[idx] % 2 == 0) 
                        val[idx].push_back(min(val[idx + 1][0], val[idx + 1][1]));
                        else val[idx].push_back(2 - min(val[idx + 1][0], val[idx + 1][1]));
                    }
                    neg[idx] = 0;
                    ope.pop_back();
                    val[idx + 1].clear();
                }
                else {
                    if (neg[idx] % 2 == 0) val[idx].push_back(int(s[j] - '0'));
                    else val[idx].push_back(2 - int(s[j] - '0'));
                    neg[idx] = 0;
                }
            }
            
            if (val[0][0] == 2) {
                ans++;
            }
            //cout << p << " " << q << " " << r << " " << val[0][0] << endl;
            for (int j = 0; j < 30; j++) val[j].clear();
            ope.clear();
        }
        
        cout << ans << endl;
    }
}



Measured memory_bytes: 3020
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n, m, q;
int a[50], b[50], c[50], d[50];
vi v;

int ans = 0;

int check() {
    int ans = 0;
    forn(i, q) {
        if (v[b[i]] - v[a[i]] == c[i]) {
            ans += d[i];
        }
    }

    return ans;
}

void rec(int i, int cur) {
    if (i >= n) {
        chmax(ans, check());
        return;
    }
    for (int j = cur; j <= m; j++) {
        v.push_back(j);
        rec(i + 1, j);
        v.pop_back();
    }
}

int main() {
    fastio();

    cin >> n >> m >> q;

    forn(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    rec(0, 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3580
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int p=1e9+7;
char str[2][80];
int main()
{
	int n=ri(),i;
	ll ans;
	scanf("%s%s",str[0]+1,str[1]+1);
	if(str[0][1]==str[1][1])	ans=3,i=2;
	else	ans=6,i=3;
	while(i<=n)
	{
		if(str[0][i]==str[1][i])
		{
			if(str[0][i-1]==str[1][i-1])	ans=ans*2%p;
			i++;
		}
		else	
		{
			if(str[0][i-1]==str[1][i-1])	ans=ans*2%p;
			else	ans=ans*3%p;
			i+=2;
		}
	}
	wi(ans);putchar('\n');
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

class BinaryIndexedTree:
    def __init__(self, size):
        """
        :param int size:
        """
        self.bit = [0 for _ in range(size)]
        self.size = size
 
    def add(self, i, w):
        """
        i番目にwを加える
        :param int i:
        :param int w:
        :return:
        """
        x = i + 1
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return
 
    def sum(self, i):
        """
        [0,i]の合計
        :param int i:
        :return:
        """
        res = 0
        x = i + 1
        while x > 0:
            res += self.bit[x - 1]
            x -= x & -x
        return res
 
    def search(self, x):
        """
        二分探索。和がx以上となる最小のインデックス(>= 1)を返す
        :param int x:
        :return :
        """
        i = 1
        s = 0
        step = 1 << (self.size.bit_length() - 1)
        while step:
            if i + step <= self.size and s + self.bit[i + step - 1] < x:
                i += step
                s += self.bit[i - 1]
            step >>= 1
        return i
 
    def __len__(self):
        return self.size

n, q = LI()
c = LI()
lr = [LI() + [i] for i in range(q)]
lr.sort(key=itemgetter(1))
last = [-1] * (n+1)
ans = [0]*q
BIT = BinaryIndexedTree(n+1)
R = 0
for l, r, i in lr:
    while R < r:
        if last[c[R]] >= 0:
            BIT.add(last[c[R]], -1)
        last[c[R]] = R+1
        BIT.add(R+1, 1)
        R += 1
    ans[i] = BIT.sum(r) - BIT.sum(l-1)
for i in ans:
    print(i)
    
    

Measured memory_bytes: 212752
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var a, b int
	con.Scan(&a, &b)
	if a == 1 {
		a = 14
	}
	if b == 1 {
		b = 14
	}
	if a > b {
		con.Println("Alice")
	} else if b > a {
		con.Println("Bob")
	} else {
		con.Println("Draw")
	}
	return nil
}


Measured memory_bytes: 640
import java.util.*;
class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n, k;
		String s;
		n = input.nextInt();
		s = input.next();
		k = input.nextInt();
		StringBuilder answer = new StringBuilder();
		for(int i = 0; i < n; i++)
		{
			if(s.charAt(i) != s.charAt(k-1))
			{
				answer.append("*");
			}
			else
			{
				answer.append(s.charAt(i));
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 23636
#include <iostream>
 #include <iomanip>
//  #include<stdio.h>
using namespace std;

int main() {

    int a,b;
    cin>>a>>b;
    double fa=a,fb=b,c;
    c=fa/fb;


    // cout<<" "<<(a/b)<<" "<<(a%b)<<" "<<c<<endl;
    cout <<(a/b)<<" "<<(a%b)<<" "<< fixed << setprecision(5) << c << endl;
    // printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));

}


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

int main(){
    char c;
    cin>>c;
    string s="aeiou";
    for(int i=0; i<5; i++){
        if(s[i]==c){
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
}


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

const int sz = 100001;

int q, l, r, first, second;
bool s[sz];
vector<int> p;

void siv(){
	for(int i = 4; i < sz; i += 2) s[i] = 1;
	for(int i = 3; i * i < sz; i += 2){
		if(!s[i]) {
			for(int j = i * i; j < sz; j += i + i) s[j] = 1;
		}
	}
}

int main(){
	siv();
	s[0] = s[1] = 1;
	for(int i = 2; i < sz; i++){
		if(s[i] == 0 && s[ (i + 1) / 2] == 0) p.push_back(i);
	}
	cin >> q;
	while(q--){
		cin >> l >> r;
		cout << upper_bound(p.begin(), p.end(), r) - lower_bound(p.begin(), p.end(), l) << "\n";
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

/*long C(long n, long r){
    if(n < r) return 0;
    long p[n+1][n+1];
    p[0][0] = 1;
    for(int i = 1; i <= n; i++){
        p[i][0] = 1;
        p[i][i] = 1;
        for(int j = 1; j <= i-1; j++){
            p[i][j] = p[i-1][j] + p[i-1][j-1];
        }
    }
    return p[n][r];
}*/

void solve()
{
    int n;
    long long X = 0, x = 0, ans = 1000000000000000000LL;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        X += a[i];
    }
    for (int i = 0; i < n; i++)
    {
        x += a[i];
        if (i + 1 < n)
            ans = min(ans, abs(X - 2 * x));
    }
    cout << ans << endl;

    return;
}

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

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H ==0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
//			for (int j = 0; j < W/2; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
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():
    a,b,c,d=MI()
    print(max(a*b,c*d))
main()

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

int main() {
	int N;
	long long C;
	cin >> N >> C;
	vector<long long> xc(N + 1), vc(N + 1), xa(N+1), va(N+1);
	xc[0] = 0, vc[0] = 0, xa[0] = 0, va[0] = 0;
	for (int i = 1; i <= N; i++) cin >> xc[i] >> vc[i];
	for (int i = N; i >= 1; i--) xa[i] = C - xc[N - i + 1], va[i] = vc[N - i + 1];
	vector<long long> CF(N + 1), AS(N + 1), AF(N+1), CS(N+1);
	CF[0] = 0, AS[0]=0, AF[0]=0, CS[0]=0;
	for (int i = 1; i <= N; i++) {
		CF[i] = CF[i - 1] + vc[i] - (xc[i] - xc[i - 1]) * 2;
		AS[i] = AS[i - 1] + va[i] - (xa[i] - xa[i - 1]);
		AF[i] = AF[i - 1] + va[i] - (xa[i] - xa[i - 1]) * 2;
		CS[i] = CS[i - 1] + vc[i] - (xc[i] - xc[i - 1]);
	}
	for (int i = 1; i <= N; i++) {
		AS[i] = max(AS[i - 1], AS[i]);
		CS[i] = max(CS[i - 1], CS[i]);
	}
	long long MAX = 0;
	for (int i = 0; i <= N; i++) {
		MAX = max(CF[i] + AS[N - i], MAX);
		MAX = max(AF[i] + CS[N - i], MAX);
	}
	cout << MAX << endl;
}


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

int N, M, Q, ans;
vector<vector<int>> ABCD;

void dfs(vector<int> A, int pre) {
  if (A.size() == N) {
    int sum = 0;
    for (auto a : ABCD) if (A[a[1]] - A[a[0]] == a[2]) sum += a[3];
    ans = max(ans, sum);
    return;
  }
  for (int i = pre; i <= M; i++) {
    vector<int> newA = A;
    newA.push_back(i);
    dfs(newA, i);
  }
}

int main() {
  cin >> N >> M >> Q;
  for (int a, b, c, d; cin >> a >> b >> c >> d;) ABCD.push_back({--a, --b, c, d});
  vector<int> A;
  dfs(A, 1);
  cout << ans << "\n";
}

Measured memory_bytes: 3596
using System;
using System.Linq;

namespace aoj_ALDS1_4_B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			int couny_S = int.Parse(Console.ReadLine());
            int[] S = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToArray();

            int couny_T = int.Parse(Console.ReadLine());
			int[] T = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToArray();

            int matchCount = 0;
            foreach (var number in T)
			{
				int startIndex = 0;
				int endIndex = S.Length - 1;
				while (true)
				{
					int searchIndex = (startIndex + endIndex) / 2;
					if (number == S[searchIndex])
					{
						matchCount++;
						break;
					}
					else if (number < S[searchIndex])
					{
						endIndex = searchIndex - 1;
					}
					else if (number > S[searchIndex])
					{
						startIndex = searchIndex + 1;
					}

                    if (startIndex > endIndex)
					{
						break;
					}
				}
			}

            Console.WriteLine(matchCount);
        }
    }
}



Measured memory_bytes: 29296
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

class Main{
	static boolean ip(long x) {
		if(x == 1) return false;
		for(long i = 2; i * i <= x; i++) if(x % i == 0) return false;
		return true;
	}
	static LinkedList<Long> fact(long n) {
		long tn = n;
		LinkedList<Long> factorize = new LinkedList<Long>();
		if(ip(n)) {
			factorize.add(n);
			n /= n;
		}
		for(long i = 2; i <= tn; i++) {
			if(n == 1) break;
			if(ip(i)) {
				while(n % i == 0) {
					factorize.add(i);
					n /= i;
				}
			}
		}
		return factorize;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		TreeMap<Long, Long> map = new TreeMap<Long, Long>();
		for(long i = 2; i <= N; i++) {
			LinkedList<Long> tmp = fact(i);
			for(long t : tmp) {
				map.put(t, (map.containsKey(t)) ? map.get(t) + 1 : 1);
			}
		}
		long ans = 1;
		for(Entry<Long, Long> ent : map.entrySet()) {
			ans *= ent.getValue() + 1;
			ans %= (1000000000 + 7);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
def f(x):
    x += 1
    ans = 0
    for i in range(50):
        loop = 1 << (i + 1)
        cnt = (x // loop) * (loop // 2)
        cnt += max(0, (x % loop) - (loop // 2))
        if cnt % 2:
            ans += 1 << i
    return ans


A, B = map(int, input().split())
print(f(A - 1) ^ f(B))

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int V;
char a[1234][1234];
bool u[1234];
bool ue[1234];
bool umem[2][1234][1234];
bool mem[2][1234][1234];

int nc(int v){
  if(u[v]++)return 0;
  int c=1;
  for(int i=0;i<V;i++){
    if(a[v][i]=='Y'){
      c+=nc(i);
    }
  }
  return c;
}

int ne(int v){
  if(ue[v]++)return 0;
  int e=0;
  for(int i=0;i<V;i++){
    if(a[v][i]=='Y'){
      e++;
      e+=ne(i);
    }
  }
  return e;
}

int rec(int eo,int ne,int no){
  if(no+ne==2)return eo;
  if(umem[eo][no][ne]++)return mem[eo][no][ne];
  for(int i=0;i<=2;i++){
    if(i<=no&&2-i<=ne){
      if(!rec(eo^(i<2),ne+((i==2)?1:-1),no+((i==2)?-2:0)))return mem[eo][no][ne]=true;
    }
  }
  return false;
}
    
int main(){
  cin>>V;
  for(int i=0;i<V;i++){
    for(int j=0;j<V;j++){
      cin>>a[i][j];
    }
  }
  int eo[2]={};
  bool re=false;
  for(int i=0;i<V;i++){
    if(!u[i]){
      int n=nc(i);
      eo[n%2]++;
      re^=(n*(n-1)/2-ne(i)/2)%2;
    }
  }
  cout<<(rec(re,eo[0],eo[1])?"Taro":"Hanako")<<endl;
}

Measured memory_bytes: 7804
#include <iostream>
#include <vector>

// (Si+1 - Ci + Si) +  Ci+1;

int main() {
  int N = 0;
  std::cin >> N;
  N--;
  std::vector<uint64_t> ret;
  ret.resize(N);
  for (int i = 0; i < N; i++) {
    uint32_t C, S, F;
    std::cin >> C;
    std::cin >> S;
    std::cin >> F;

    ret[i] = C + S;
    for (int j = 0; j < i; j++) {
      uint64_t a = ret[j];
      while (a % F != 0) {
        a++;
      }
      if (a >= S) {
        ret[j] = a + C;
      } else {
        ret[j] = S + C;
      }
    }
  }

  for (const auto &d: ret) {
    std::cout << d << std::endl;
  }
  std::cout << 0 << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
#define REP(i,n) for (int i = 1; i<= (n); i++)
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
const long double PI = acos(-1);
using ll = long long;
using ld = long double;
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= (x); i++){
        if (y == i*2 + (x-i)*4) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3680
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<functional>
#include<unordered_map>
#define io ios::sync_with_stdio(false)
#define inf 0x3f3f3f3f
#define ll long long
#define P pair<int,int>
#define lc rt*2
#define rc rt*2+1
#define s_it set<node>::iterator
#define v_it vector<int>::iterator
const int maxn = 1e7 + 10;
const int mod = 1e9 + 7;
const double PI = 3.1415926536;

using namespace std;

ll f_mod(ll a, ll b, ll p)
{
	ll ans = 1;
	a %= p;
	while (b)
	{
		if (b % 2)
			ans = (ans*a) % p;
		b /= 2;
		a = (a*a) % p;
	}
	return ans%p;
}


int main()
{
	io;
	ll n, a, b;
	cin >> n >> a >> b;
	a = min(a, n - a);
	b = min(b, n - b);
	ll ans = f_mod(2, n, mod) - 1;
	ll x = 1, y = 1;
	for (int i = n; i > n - a; i--)
		x = (x*i) % mod;
	for (int i = 1; i <= a; i++)
		y = (y*i) % mod;
	ans = (ans + mod - f_mod(y, mod - 2, mod)*x%mod) % mod;
	x = 1, y = 1;
	for (int i = n; i > n - b; i--)
		x = (x*i) % mod;
	for (int i = 1; i <= b; i++)
		y = (y*i) % mod;
	ans = (ans + mod - f_mod(y, mod - 2, mod)*x%mod) % mod;
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N, M;
  cin >> N >> M;
  
  vector<pair<int, int>> mise(N);
  int A, B;
  for( int i = 0; i < N; i++ ){
    cin >> A >> B;
    mise.at(i) = make_pair(A, B);
  }
  sort(mise.begin(), mise.end());
  
  int ans = 0;
  int honsu = M; //0本を目指す、買うたびに減る
  for( int i = 0; i < N; i++ ){
    if( mise.at(i).second < honsu ){
      ans += mise.at(i).first * mise.at(i).second;
      honsu -= mise.at(i).second;
    }else{
      ans += mise.at(i).first * honsu;
      cout << ans << endl;
      return 0;
    }
  }
      
  
}



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

int main()
{
    int res=0;
    string s;
    stack<char>stk;
    cin>>s;
    stk.push(s[0]);
    for(int i=1; i<s.size(); i++)
    {
        if(!stk.empty() && stk.top()!=s[i])
        {
            stk.pop();
            res+=2;
        }
        else stk.push(s[i]);
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;


string str(int n, int l){
    string s = to_string(n);
    for(int i = s.length(); i<l; i++){
        s.push_back('0');
    }
    return s;
}

int maxstr(string s){
    sort(s.begin(), s.end(), greater<int>());
    return stoi(s);
}

int minstr(string s){
    sort(s.begin(), s.end());
    return stoi(s);
}

int main(){
    int N, L;

    string s;
    int count, tmp;
    bool endFlag = false;
    map<int, int> cmap;
    while(true){
        cin >> N >> L;
        if(N == 0 && L == 0) break;
        count = 0;
        endFlag = false;
        cmap.clear();

        cmap[N] = count;
        while(!endFlag){
            s = str(N, L);
            tmp = maxstr(s) - minstr(s);
            if(cmap.find(tmp) != cmap.end()){
                count++;
                cout << cmap[tmp] << " " << tmp << " " << count - cmap[tmp] << endl;
                endFlag = true;
            }else {
                cmap[tmp] = ++count;
                N = tmp;
            }
        }
    }
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n;
	cin >> n;
	veci l(n);
	rep(i, n) cin >> l[i];
	int ans = 0;
	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = i + 1; j < n; j++)
		{
			for (size_t k = j + 1; k < n; k++)
			{
				int sum = l[i] + l[j] + l[k];
				int _max = max({l[i], l[j], l[k]});
				if (sum - _max > _max && l[i] != l[j] && l[j] != l[k] && l[i] != l[k])
				{
					ans++;
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int N;
	cin >> N;
	map<ll, int> A;
	ll s = 0;
	for(int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		++ A[a];
		s += a;
	}

	int Q;
	cin >> Q;
	while(Q--) {
		int B, C;
		cin >> B >> C;
		int b = A[B];
		s += b*(C-B);
		A[B] -= b;
		A[C] += b;
		cout << s << "\n";
	}

	return 0;
}

Measured memory_bytes: 9536
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define hell (int)(1e9+7)
#define int long int

using namespace std;

void solve(){
    string s;
    cin>>s;
    int ans=0;
    if(s=="SUN")
        ans=7;
    else if(s=="SAT")
        ans=1;
    else if(s=="FRI")
        ans=2;
    else if(s=="THU")
        ans=3;
    else if(s=="WED")
        ans=4;
    else if(s=="TUE")
        ans=5;
    else if(s=="MON")
        ans=6;
    cout<<ans;
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
t1 a1
..
tn an

n 1000
ti ai 1000

ans 10^18
 */

ll ceil(ll s, ll t){
  return s/t + (s%t==0 ? 0 : 1);
}

int n;
ll a[1000],b[1000];

int main(){
  cin>>n;
  REP(i,n){
    cin>>a[i]>>b[i];
  }

  ll x=a[0],y=b[0];
  REP(i,n-1){
    ll u = max(ceil(x,a[i+1]), ceil(y,b[i+1]));
    x = a[i+1] * u;
    y = b[i+1] * u;
  }

  cout<<x+y<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define     fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     ll                      long long
#define     pb                      push_back
#define     M                       1000000007
using namespace std;
int main()
{
    ll n,x,sum=0;
    vector<ll>v;
    for(ll i=0; i<3; i++)
    {
        cin>>x;
        v.pb(x);
    }
    sort(v.begin(),v.end());
    for(ll i=0; i<v.size()-1; i++)
    {
        sum+=(v[i+1]-v[i]);
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>

using namespace std;

#define N 10005   
int main(){
	int i,j,len;
	int n;
	while(scanf("%d",&n) != EOF) {  
		if(n == 0 || n == 1) {
			printf("1\n");
			continue;
		}
		long s[N]={1, 1};
		len = 1;
		for(i = 2;i <= n; i ++){
			for(j = 0; j < len; j ++)
				s[j] = s[j] * i;
			for(j = 0;j < len - 1; j ++) {
				s[j + 1] += s[j] / 10000;
				s[j] = s[j] % 10000;
			}
			if(s[j] > 10000 ) {
				s[j + 1] = s[j] / 10000;
				s[j] = s[j] % 10000;
				len ++;       
			}
		}
		printf("%d",s[len - 1]);
		for(j = len - 2; j >= 0; j --)
			printf("%04d", s[j]);
		printf("\n");
	}   
	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define in(x, a, b) (a <= x && x < b)
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

ll power(ll a, ll b, ll P) {
	ll result = 1;
	while(b) {
		if(b % 2) result = (result * a) % P;
		a = (a * a) % P;
		b /= 2;
	}
	
	return result;
}

void solve() {
	int n;
	string s;
	cin >> n >> s;
	
	int cnt = 0;
	for(int i = 0; i < s.length(); i++) if(s[i] == '1') cnt++;
	
	vector<vi> values(n, vi(2));
	vi sum(2, 0);
	for(int i = 0; i < n; i++) {
		if(cnt - 1 > 0) values[i][0] = power(2, n - i - 1, cnt - 1);
		values[i][1] = power(2, n - i - 1, cnt + 1);
		if(cnt - 1 > 0) sum[0] = (sum[0] + values[i][0] * (s[i] - '0')) % (cnt - 1);
		sum[1] = (sum[1] + values[i][1] * (s[i] - '0')) % (cnt + 1);
	}
	
	for(int i = 0; i < n; i++) {
		int m;
		if(s[i] == '0') {
			m = (sum[1] + (values[i][1])) % (cnt + 1);
		} else {
			if(cnt - 1 > 0) m = (sum[0] - (values[i][0]) + cnt - 1) % (cnt - 1);
			else {
				cout << 0 << endl;
				continue;
			}
		}
		
		if(m == 0) {
			cout << 1 << endl;
			continue;	
		}
		
		int ans = 0;
		while(m) {
			int mod = __builtin_popcount(m);
			m %= mod;
			ans++;
		}
		
		cout << ans + 1	 << endl;
	}
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 14452
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
long = read :: String -> Integer
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = long . head . words
printer = unlines . (:[]) . show

gcd3 a b c = gcd a $ gcd b c

solver k = sum [(if a==b && b==c then 1 else if a/=b && b/=c then 6 else 3) * gcd3 a b c | a<-[1..k], b<-[a..k], c<-[b..k]]

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    vector<int> a(n);
    ll res=1,odd=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2) odd++;
        res*=3;

    }
    res -= (1<<(n-odd));
    cout<<res<<endl;
}


Measured memory_bytes: 256
from sys import stdin
import numpy as np


# noinspection PyShadowingBuiltinsInspection

def main():
    K, X = [int(x) for x in input().split()]
    if 500 * K >= X:
        print("Yes")
    else:
        print("No")

    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 22144
#include<iostream>
#include<cstdio>
#include<stack>
#include<cstdlib>

using namespace std;

int main()
{
    stack<int> s;

    char ch[100];
    while(scanf("%s",ch)!=EOF)
    {
        int a,b;

        if(ch[0]=='+')
        {

            b=s.top();
            s.pop();
            a=s.top();
            s.pop();
            s.push(a+b);
        }else if(ch[0]=='-')
        {
            b=s.top();
            s.pop();
            a=s.top();
            s.pop();
            s.push(a-b);
        }else if(ch[0]=='*')
        {
            b=s.top();
            s.pop();
            a=s.top();
            s.pop();
            s.push(a*b);
        }else
        {
            s.push(atoi(ch));
        }

    }

    printf("%d\n",s.top());


    return 0;
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

const int mod=1e9+7;
const int inf=-1;
const int sz=2e5;

#define pi acos(-1);
#define pb push_back;
#define mp make_pair;
#define ff first;
#define ss second;
#define gap ' ';
#define lb lower_bound;
#define ub upper_bound;
#define clr(x) memset(x,0,sizeof(x));
#define all(x) x.begin(),x.end();
#define rall(x) x.begin(),x.end();
#define dbg puts("finding wrong");
#define case(x,y) printf("Case %lld: %lld\n",++x,y);
#define fastio ios::sync_with_stdio(false);cin.tie(0);

typedef vector<ll> v;
typedef map<ll,ll>use;
typedef set<ll>st;
typedef queue<ll>q;
typedef deque<ll>dq;
typedef pair<ll,ll>pa;
typedef vector<pa>vii;

int ar[sz];

int main()
{
  fastio;
  ll r=0, w=0, ans=0, i, n;
  string s;

  cin>>n>>s;

  for(i=0; i<n; i++)
  {
  	if(s[i]=='R')r++;
  }

  for(i=0; i<r; i++)
  {
  	if(s[i]=='W')ans++;
  }

  printf("%lld\n",ans);
}


Measured memory_bytes: 3860
#include <stdio.h>
#include<math.h>
int main(void) {
double a,b,c,d;
double e;
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
e=(a-c)*(a-c)+(b-d)*(b-d);
e=sqrt(e);
printf("%f",e);
  return 0;
}


Measured memory_bytes: 2068
n, a, b, c ,d = map(int, input().split())
s = input()[:max(c,d)]
 
def main():
    if "##" in s[b:d-2]:
        return "No"
    if "##" in s[a:c-2]:
        return "No"
 
    if c < d:
        return "Yes"
    
    else:
 
        if "..." in s[b-2:d+1]:
            return "Yes"
                
        return "No"
 
print(main())


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    int N;
    string S, T;
    cin >> N >> S >> T;
    string x = "";
    rep(i, N){
        x += S[i];
        x += T[i];
    }
    cout << x << endl;
}

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


int main(void)
{
	//変数の宣言
	int n;
	int a[110];
	int sum;
	double ave;
	int near;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	sum=0;
	for(i=0;i<n;i++){
		sum=sum+a[i];
	}
	
	ave=(double)sum/n;
	
	for(i=0;i<n;i++){
		if(i==0){
			temp=abs(a[i]*n-sum);
//			printf("i=%d,temp=%d\n",i,temp);
			ans=0;
			near=temp;
		}else{
			temp=abs(a[i]*n-sum);
//			printf("i=%d,temp=%d\n",i,temp);
			if(temp<near){
				near=temp;
				ans=i;
			}
		}
	}
//	printf("計算部分終了\n");
	//出力
	
	
	printf("%d\n",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main()
{
	int H, A, i=0;

	cin >> H;
	cin >> A;
	if (H > 10000 || A > 10000)return 0;
	
	while (H>0)
	{
		H = H - A;
		i++;
	}
	cout << i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main(void){
    int n,a[256],alice=0,bob=0;
    cin >> n;
    
    for(int i=0;i<n;i++) cin >> a[i];
    
    sort(a, a+n, greater<int>());
    for(int i=0;i<n;i++){
        if(i%2!=0){
            alice += a[i];
        } else {
            bob += a[i];
        }
        
    }
    
    cout << (-1)*(alice-bob) << endl;
    
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double T = (double) Integer.parseInt(sc.next());
		double X = (double) Integer.parseInt(sc.next());
		sc.close();

		double ans = T / X;
		System.out.println(ans);

	}

}

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

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;

int main(){
	int n;
	cin>>n;
	int h[100];
	for (int i = 0; i < n; ++i){
		cin>>h[i];
	}

	int count=0;
	for (int i = 0; i < n; ++i){
		bool flag=true;
		for (int j = 0; j < i; ++j){
			if(h[j]>h[i]){
				flag=false;
			}
		}
		if(flag)
			count++;
	}

	cout<<count<<endl;


}

Measured memory_bytes: 256
A, B, C, D = input()
op = ['+', '-']
for op1 in op:
  for op2 in op:
    for op3 in op:
      s = A + op1 + B + op2 + C + op3 + D
      if eval(s) == 7:
        print(s + '=7')
        exit()

Measured memory_bytes: 3060
L = []

H, W = map(int, input().split())
for i in range(H):
	S = list(input())
	L.append(S)

ans1 = [[0 for i in range(W)] for j in range(H)]
ans2 = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
	val = 0
	l = []
	for j in range(W):
		if L[i][j] == "#":
			for k in l:
				ans1[i][k] = val
			val = 0
			l = []
		else:
			val += 1
			l.append(j)
	for k in l:
		ans1[i][k] = val

for i in range(W):
	val = 0
	l = []
	for j in range(H):
		if L[j][i] == "#":
			for k in l:
				ans2[k][i] = val
			val = 0
			l = []
		else:
			val += 1
			l.append(j)
	for k in l:
		ans2[k][i] = val


ans = -1
for i in range(H):
	for j in range(W):
		x = ans1[i][j] + ans2[i][j] - 1
		if x > ans:
			ans = x

print(ans)

Measured memory_bytes: 249920
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    while(true){
      val in = StdIn.readLine().split(" ")
      if(in(1).toString == "?") return
      println(
        in(1).toString match {
          case "+" => in(0).toInt + in(2).toInt
          case "-" => in(0).toInt - in(2).toInt
          case "*" => in(0).toInt * in(2).toInt
          case "/" => in(0).toInt / in(2).toInt
        }
      )
    }
  }
}

Measured memory_bytes: 43560
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
using namespace std;


int main(){
	string str;
	cin >> str;
	str.insert(4, " ");
	cout << str << endl;
	return 0;
}

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

using namespace std;

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

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

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;

    vi a(n);
    VIN(a);

    ll l=a[0];

    FOR(i,k,n){
        //DEBUG2(a[i-k], a[i]);
        if(a[i-k] < a[i]) yn;
    }
    
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/



/*ここからmain関数*/

int main()
{
	// A0 G1 C2 T3
	int N;
	cin >> N;

	int dp[101][4][4][4];
	for (int len = 0; len <= N; len++)
	{
		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				for (int k = 0; k < 4; k++)
				{
					dp[len][i][j][k] = 0;
				}
			}
		}
	}
	dp[0][3][3][3] = 1;

	for (int len = 0; len < N; len++)
	{
		//3文字前
		for (int i = 0; i < 4; i++)
		{
			//2文字前
			for (int j = 0; j < 4; j++)
			{
				//1文字前
				for (int k = 0; k < 4; k++)
				{
					if (dp[len][i][j][k] == 0) continue;

					for (int a = 0; a < 4; a++)
					{
						if (j == 0 && k == 1 && a == 2) continue;
						if (j == 0 && k == 2 && a == 1) continue;
						if (j == 1 && k == 0 && a == 2) continue;
						if (i == 0 && k == 1 && a == 2) continue;
						if (i == 0 && j == 1 && a == 2) continue;

						dp[len + 1][j][k][a] += dp[len][i][j][k];
						dp[len + 1][j][k][a] %= 1000000007;
					}
				}
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			for (int k = 0; k < 4; k++)
			{
				ans += dp[N][i][j][k];
				ans %= 1000000007;
			}
		}
	}

	cout << ans;

	return 0;
}

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

int main()
{
  int P, Q, R;
  cin >> P >> Q >> R;
  cout << min({P+Q, Q+R, P+R}) << endl;
}

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

void chmax(int64_t& a, int64_t b){
    a = max(a, b);
}

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    static int A[3001][3001];
    while(K--){
        int a, b, c;
        cin >> a >> b >> c;
        A[a-1][b-1] = c;
    }

    static int64_t dp[3001][3001][5] = {0};
    dp[0][0][1] = A[0][0];
    for(int i=0; i<N; i++) for(int j=0; j<M; j++) for(int k=0; k<4; k++){
        chmax(dp[i+1][j][0], dp[i][j][k]);
        chmax(dp[i+1][j][1], dp[i][j][k] + A[i+1][j]);
        chmax(dp[i][j+1][k], dp[i][j][k]);
        chmax(dp[i][j+1][k+1], dp[i][j][k] + A[i][j+1]);
    }

    int64_t ans = 0;
    for(int k=0; k<=3; k++) chmax(ans, dp[N-1][M-1][k]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 390236
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	string s;
	cin >> s;
	int l = 0, r = s.size()-1;
	int ans = 0;
	while (l < r)
	{
		if (s[l] == s[r]) {l++; r--;}
		else if (s[l] == 'x') {l++; ans++;}
		else if (s[r] == 'x') {r--; ans++;}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define mid(l, r) ((l)+(r))/2
#define len(a) (a).length()
#define sz(a) (a).size()
#define xx first
#define yy second
#define inf int(2e9)
#define ff(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i, a, b) for(int (i) = (a); (i) >= (b); --(i))

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
ll s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> s;
    ll a,b,c,d;
    a = sqrt(s);
    c = sqrt(s);
    if(a*a == s){
        cout << 0 << " " << 0<< " " << 0 <<" " << a <<" " << a << " " << 0 << endl;
        return 0;
    }
    if(a*a > s){
        a--;
        c--;
    }
    while(c<=1e9){
        if(a*(c+1) < s)c++;
        else break;
    }
    while(a<=1e9-1){
        if((a+1)*c < s)a++;
        else break;
    }
    s -= a*c;
    b = 1;
    d = s;
    cout << 0 << " "<< d <<" " << a << " " << 0 << " " << a+b <<" " << c << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vl a(n);
    vl b(n);
    REP(i, n) {
        cin >> a[i];
        b[i] = a[i] - i;
    }
    map<ll, int> m;
    REP1(i, n) m[b[i]]++;
    ll ans = 0;
    REP(i, n - 1) {
        m[a[i] - i]--;
        ans += m[-(a[i] + i)];
    }
    cout << ans << endl;
}


Measured memory_bytes: 29068
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int L, R, d;
  cin >> L >> R >> d;

  int cnt = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0) cnt++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3568
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,S[666666],ans,a[666666];
int main(){
	scanf("%d",&n);
	FOR(i,1,n){
		getint(a[i]);
		if (a[i]>n) ++ans;
		else S[a[i]]++;
	}
	FOR(i,1,n)
		if (S[i]<i) ans+=S[i]; else ans+=S[i]-i;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int N,r,l,count;
 	cin>>N;
  count=0;
  for(int i=0;i<N;i++){
  cin >>l>>r;
    count+=(r-l)+1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct RollingHash{
    static const int MD = 3;
    const vector<ll> hash_base{1009,1021,1013};
    const vector<ll> hash_mod{1000000009,1000000007,1000000021};

    int n;
    vector<ll> hs[MD], pw[MD];

    RollingHash(){}
    RollingHash(const string &s){
        n = s.size();
        for(int i=0; i<MD; ++i){
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for(int j=0; j<n; ++j){
                pw[i][j+1] = pw[i][j]*hash_base[i] % hash_mod[i];
                hs[i][j+1] = (hs[i][j]*hash_base[i]+s[j]) % hash_mod[i];
            }
        }
    }

    ll hash_value(int l, int r, int i){
        return ((hs[i][r] - hs[i][l]*pw[i][r-l])%hash_mod[i]+hash_mod[i])%hash_mod[i];
    }

    // 1-index
    bool match(int l1, int r1, int l2, int r2){
        bool ret = true;
        for(int i=0; i<MD; ++i) ret &= (hash_value(l1-1,r1,i) == hash_value(l2-1,r2,i));
        return ret;
    }

    vector<ll> calc(int l, int r){
        vector<ll> ret;
        rep(i,3) ret.pb(hash_value(l-1,r,i));
        return ret;
    }
};

int main()
{
    int n,m;
    string s;
    cin >>n >>m >>s;

    RollingHash RH(s);
    set<vector<ll>> X;
    int L=1,R=1;
    while(m--)
    {
        string q;
        cin >>q;

        int add=1;
        if(q[1]=='-') add=-1;

        if(q[0]=='R') R+=add;
        else L+=add;

        X.insert(RH.calc(L,R));
    }

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

Measured memory_bytes: 50192