akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;

  ui N{}, M{}; cin >> N >> M;
  vector<ull> A(N);
  rep(0, N) cin >> A[i];

  typedef pair<ull, ui> Pair;
  vector<Pair> BC(M);
  rep(0, M) cin >> BC[i].second >> BC[i].first;

  boost::sort(A, std::less<ull>());
  boost::sort(BC, std::greater<Pair>());

  ull sum = boost::accumulate(A, 0ULL);
  ull inf = boost::accumulate(BC, 1ULL, [](auto res, Pair p) {
    return res + p.second;
    });
  
  ull ans{ sum };
  ull res{ sum }; // 中間結果
  auto it = BC.begin();
  rep(0, inf)
  {
    if (i == N) break;
    if (it == BC.end()) break;

    res += (*it).first;
    res -= A[i];
    --(*it).second;
    if (!(*it).second)
      ++it;

    ans = std::max(ans, res);
  }

  using std::cout;
  cout << ans << '\n';
  
  return;
}

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

  solve();

  return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    int q; cin >> q;
    while (q--) {
        int b, m, e; cin >> b >> m >> e;
        reverse(a.begin() + b, a.begin() + m);
        reverse(a.begin() + m, a.begin() + e);
        reverse(a.begin() + b, a.begin() + e);
    }
    int i = 0; for (int ai: a) cout << (i++ ? " " : "") << ai;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <string.h>

int shiki();
int shiki2();
int num();

char input[101];
int pos = 0;

int num(){
  int n = 0;

  if(input[pos] == '('){
    pos++;
    n = shiki();
    
    if(input[pos] == ')'){
      pos++;
      return n;
    }
  }else{
    while('0' <= input[pos] && input[pos] <= '9'){
      n = n*10 + (input[pos] - '0');
      pos++;
    }
  }
  return n;
}

int shiki2(){
  int first,second;
  
  first = num();
  for(;;){
    if(input[pos] == '*'){
      pos++;
      second = num();
      first *= second; 
    }else if(input[pos] == '/'){
      pos++;
      second = num();
      first /= second;
    }else{
      return first;
    }
  }
}

int shiki(){
  int first,second;
  
  first = shiki2();
  
  for(;;){
    if(input[pos] == '+'){
      pos++;
      second = shiki2();
      first += second; 
    }else if(input[pos] == '-'){
      pos++;
      second = shiki2();
      first -= second;
    }else{
      return first;
    }
  }
}

void clear(){
  memset(input,0,sizeof(input));
  pos = 0;
}

int main(int argc,char* argv[]){
  int n,i,j;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    clear();
    scanf("%s",input);

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

  return 0;
  
}

Measured memory_bytes: 0
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn digits_odd(n: usize) -> bool {
    let div = 10;
    let mut m = n;
    let mut count = 0;
    while m > 0 {
        m /= 10;
        count += 1;
    }
    if count % 2 == 0 {
        false
    }
    else{
        true
    }
}

fn main(){
    let mut N = read::<usize>();
    let mut ans: usize = 0;

    for i in 0..N+1 {
        if digits_odd(i) {
            ans += 1;
        }
        else{
            ;
        }
    }
   
   println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

int top, S[1000];

void push(int x) {
        S[++top] = x;
}

int pop() {
        top--;
        return S[top+1];
}

int main() {
        int a, b;
        top = 0;
        char ch[100];
        while(scanf("%s", ch) != EOF) {
                if(ch[0] == '+') {
                        a = pop();
                        b = pop();
                        push(a + b);
                }
                else if(ch[0] == '-') {
                        a = pop();
                        b = pop();
                        push(b - a);
                }
                else if(ch[0] == '*') {
                        a = pop();
                        b = pop();
                        push(a * b);
                } else {
                        push(atoi(ch));
                }
        }
        cout << pop() << endl;
        return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, n;
    cin>>x>>n;
    int a[n];
    map<int, int> m;
    for (int i=0; i<n; i++){
        cin>>a[i];
        m[a[i]]++;
    }
    int cnt = 0;
    int res;
    while(1){
        int l = x-cnt;
        int r = x+cnt;
        if (m.find(l)==m.end()){
            cout<<l<<endl;
            return 0;
        }
        if (m.find(r)==m.end()){
            cout<<r<<endl;
            return 0;
        }
        cnt++;
    }

}

Measured memory_bytes: 3584
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int i = 1;
		while(sc.hasNextInt()){
			int value = sc.nextInt();
			if(value != 0){
				System.out.println("Case " + (i++) + ": " + value);
			}
			else{
				break;
			}
		}
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> order;
  vector<int> score;
  vector<int> bonus;
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    order.push_back(num);
  }
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    score.push_back(num);
  }
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    bonus.push_back(num);
  }
  
  int res = 0;
  for(int i=0; i<n; i++){
    res += score[i];
  }
  for(int i=0; i<(n-1); i++){
    if(order[i+1] - order[i] == 1){
      res += bonus[order[i]-1];
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    string s;
    cin >> s;
    int count=0;
    for(int i=0;i<s.length()/2;i++){
        //cout << i << "," << s.length()-1-i <<endl;

        char c1 = s[i];
        char c2 = s[s.length()-i-1];
        //cout << c1 << "," << c2 <<endl;
        if(c1!=c2){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,ans=0;
    string s;
    cin>>n>>s;
    for(int m=0;m<n;m++){
    	string S=s.substr(m,n-m);
    	vector<int> Z(S.size());
        Z[0] = S.size();
        int i = 1, j = 0;
        while(i < S.size()){
            while(i + j < S.size() && S[j] == S[i + j]) j++;
            Z[i] = j;
            if(j == 0) { i++; continue; }
            int k = 1;
            while(i + k < S.size() && k + Z[k] < j){
                Z[i + k] = Z[k];
                k++;
            }
            i += k; j -= k;
        }
        int z=S.length();
        for(int x=0;x<z;x++){
        	ans=max(ans,min(x,Z[x]));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
#print(A)

if N==1:
  print(1)
else:
  ans=1
  c=0
  #print(c)
  for i in range(1,N):
    if A[i]>A[i-1]:
      if c==-1:
        c=0
        ans+=1
      else:
        c=1
    elif A[i]<A[i-1]:
      if c==+1:
        c=0
        ans+=1
      else:
        c=-1
    #print(c)
  print(ans)

Measured memory_bytes: 14252
[n, k] = [int(i) for i in input().split()]
s = input()

l = []
cnt = 1
if s[0] == '0':
    l.append(0)
for i in range(len(s) - 1):
    if (s[i] == s[i + 1]):
        cnt += 1
    else:
        l.append(cnt)
        cnt = 1
l.append(cnt)
if s[-1] == '0':
    l.append(0)
m = (len(l)) // 2
sum1 = []
temp = sum(l[0:min(2 * m + 1, 2 * k + 1)])
sum1.append(temp)
if (m > k):
    for i in range(1, m - k + 1):
        temp += l[2 * (k + i) - 1] + l[2 * (k + i)] - l[2 * i - 1] - l[2 * i - 2] 
        sum1.append(temp)
print(max(sum1))


Measured memory_bytes: 5396
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<=n;i++)

int n,a[100],b[100],dp[100][100];

int main(){
	cin>>n;
	rep(i,n)fill(dp[i],dp[i]+n,INF);
	rep(i,n){
		cin>>a[i]>>b[i];
		dp[i][i]=0;
	}
	rep2(i,1,n)rep(j,n-i+1)rep(k,i)dp[j][j+i]=min(dp[j][j+i],dp[j][j+k]+dp[j+k+1][j+i]+a[j]*b[j+k]*a[j+k+1]*b[j+i]);
	cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 0
N = int(input())
a = []
for i in range(N):
    lis = sorted([s for s in input()])
    ans = ''
    for i in lis:
        ans = ans + i    
    a.append(ans)
    
import collections
count = dict(collections.Counter(a))
ans = 0
for k,v in count.items():
    ans += v * (v-1) / 2
print(int(ans))      

Measured memory_bytes: 22856
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	R, G := nextInt(), nextInt()
	fmt.Println(G*2 - R)
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll n,mx=-100,mn=100;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        mx=max(mx,a[i]);
        mn=min(mn,a[i]);
    }
    ll ans=1e9;
    for(ll i=mn;i<=mx;i++){
        ll sum=0;
        rep(j,n) sum+=(a[j]-i)*(a[j]-i);
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = 0;;i++){
        for(int j = 0;;j++){
            if(a>b){
                int k = a;
                a = b;
                b = k;
            }
        else if(b>c){
            int l = b;
            b = c;
            c = l;
            }
        else{
            a = a;
            b = b;
            c = c;
            }
    break;
        }
        if(a <= b && b <= c)
        break;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


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

int main(){
	int h,w;
	cin >> h >> w;
	rep(i,h){
		string s;
		cin >> s;
		cout << s << endl;
		cout << s << endl;
	}
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    n,m=map(int, input().split())
    
    tree=[[] for _ in range(n)]
    for i in range(m):
        x,y,w = map(int,input().split())
        tree[x-1].append(y-1)
        tree[y-1].append(x-1)
    
    singles = [ i for i in range(n) if tree[i]==[]]
    
    visited=[False]*n
    for i in singles:
        visited[i] = True
    ans=len(singles)
    
    from collections import deque
    while False in visited:
        ans+=1
        start = visited.index(False)
        visited[start]=True
        q=deque([(start,togo) for togo in tree[start]])
        while q:
            parent,x = q.pop()
            visited[x]=True
            for y in tree[x]:
                if not visited[y]:
                    q.append((x,y))
    #         print(parent,x,q)
    #     print(visited,ans)
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 62660
#include <stdio.h>
#include <math.h>
#define MAX 50
#define EPS 10e-10

int main(void)
{
	int n1,n2;
	int i;
	int angle,asum;
	float s1,s2;

	while(1){
		s1 = s2 = 0.0;
		
		asum = 0;
		scanf("%d",&n1);
		if(n1 == 0){ break; }
		for(i=0;i<n1-1;i++){
			scanf("%d",&angle);
			asum += angle;
			s1 += sinf((float)angle/180.0*3.141592);
		}
		angle = 360-asum;
		s1 += sinf((float)angle/180.0*3.141592);
		
		asum = 0;
		scanf("%d",&n2);
		if(n2 == 0){ break; }
		for(i=0;i<n2-1;i++){
			scanf("%d",&angle);
			asum += angle;
			s2 += sinf((float)angle/180.0*3.141592);
		}
		angle = 360-asum;
		s2 += sinf((float)angle/180.0*3.141592);
		
		if(s1 > s2-EPS && s1 < s2+EPS ){
			printf("0\n");
		}
		else if(s1 > s2){
			printf("1\n");		
		}
		else{
			printf("2\n");		
		}
	}
	return 0;
}

Measured memory_bytes: 1692
import fractions
import math

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def chk(i):
    cnt=0
    while True:
        if i%2==0:
            i/=2
            cnt+=1
        else:
            break
    return cnt

flag=0
number=chk(A[0])
for i in A:
    if chk(i)!=number:
        print(0)
        exit()

l = 1
for i in A:
    l = l * i//2 // fractions.gcd(l, i//2)
 
print((m // l + 1) // 2)

"""
num=A[0]//2
flag2=0
if flag==0:
    for i in range(1,len(A)):
        num=lcm(num,A[i]//2)
        if num>m:
            flag2=1
            break
    if flag2==1:
        print(0)
    else:
        print(math.ceil(m//num/2))
"""


Measured memory_bytes: 16316
import math

hour_hand_len, min_hand_len, later_hour, later_min = list(map(int, input().split()))

h_ang = 30 * (later_hour + (later_min / 60))
min_ang = 6 * later_min

ang = min(abs(360 - abs(h_ang - min_ang)), abs(h_ang - min_ang))
print(
    math.sqrt(
        (hour_hand_len ** 2)
        + (min_hand_len ** 2)
        - (2 * hour_hand_len * min_hand_len * math.cos(math.radians(ang)))
    )
)


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

int main()
{
    int a, b, c, d;
    int left = 0, right = 0;
    cin >> a >> b >> c >> d;
    
    left = a + b;
    right = c + d;
    if(left > right)
        cout << "Left" << endl;
    else if(left < right)
        cout << "Right" << endl;
    else
        cout << "Balanced" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int n,l,r,x;
    vector<int>b(200009),a(200009);
int main()
{
    unordered_map<string,int>mp;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    for(auto s:{"AC","WA","TLE","RE"})
    {
            cout<<s<<" x "<<mp[s]<<endl;
    }
}


Measured memory_bytes: 4624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N;
    cin >> N;

    int ans = INT_MAX;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        int cnt = 0;
        while (A % 2 == 0) {
            A /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(void){
    string s,t;
    char c1 = -1, c2 = -1;
    bool fail = false;
    int find_pos = -1;

    cin >> s >> t;

    while(s != t){
        c1 = c2 = -1;
        find_pos = -1;
        for(int i=0; i<s.length(); i++){
            char ch = s[i] - 'a';
            char ch_t=t[i] - 'a';
            if(s[i] != t[i] && c1 == -1){
                //cout << (char)(ch + 'a') << ">" << (char)(ch_t + 'a') << " " << i << endl;
                c1 = ch;
                c2 = ch_t;
                find_pos = i;
                i = -1;
                continue;
            }
            if(c1 == ch){
                s[i] = c2+'a';
                if(i<find_pos){
                    //cout << "fail\n";
                    fail = true;
                    break;
                }
            }else if(c2 == ch){
                s[i] = c1+'a';
                //cout << i << " : " << find_pos << endl;
                if(i<find_pos){
                    //cout << "fail\n";
                    fail = true;
                    break;
                }
            }
        }
        //cout << s << endl;
        if(fail){
            break;
        }
    }
    if(fail){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<cstring> 
using namespace std;
int main(){
     int a,b,c,d[110];cin>>a>>b;
     memset(d,0,sizeof(d));
     for(int i=0;i<b;i++){
     	cin>>c;
     	for(int i=0;i<c;i++){
     		int t;cin>>t;
     		d[t]=1;
		 }
	 }
	 int s=0;
	 for(int i=1;i<=a;i++){
	 	if(d[i]==0) s++;
	 } 
	 
	 cout<<s;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll ZERO = 0;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

ll N,A,B;
ll com[200010];

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

ll RepeatSquaring(ll n, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(n, P/2, M);
        return t*t % M;
    }
    return n * RepeatSquaring(n, P-1, M);
}

void COM() {
    com[0] = 1;
    for(ll i = 1;i < min(N + 1,200010ll);i++) {
        com[i] = com[i - 1] * (N - (i - 1)) % MOD * modinv(i,MOD) % MOD;
    }
    return;
}

int main() {
    cin >> N >> A >> B;
    ll ret = RepeatSquaring(2,N,MOD);
    COM();
    ll cnt = com[A] + com[B];
    cnt %= MOD;
    ret--;
    cout << mod(ret - cnt,MOD) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
// #include <prettyprint.hpp>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;

static const ll max_n = 100010;
vector<ll> ants(max_n);
vector<ll> after(max_n);
vector<ll> ans(max_n);
vector<ll> directions(max_n);
// static const ll max_col = 10000;
ll N, M;


void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    ll N, L, T, x, w;
    sll(N);
    sll(L);
    sll(T);

    ll id = -1;

    rep(i, N){
        sll(x);
        sll(w);
        ants[i] = x;
        directions[i] = w;
        if(w==1){
            id = i;
        }
    }

    if(id==-1){
        rep(i,N){
            cout << ((ants[i] - T) % L + L) % L << endl;
        }
    }else{
        ll st_a = ants[id];
        ll target_coord = (st_a + T) % L;
        ll num = id;
        rep(i, N){
            if(directions[i]==1){
                after[i] = (ants[i] + T) % L;
            }else{
                after[i] = ((ants[i] - T) % L + L) % L;
                ll dist = (st_a - ants[i] + L) % L;
                num += (T * 2 + dist)/ L;
                num %= N;
            }
        }

        sort(after.begin(), after.begin()+N);
        ll id_dist = upper_bound(after.begin(), after.begin()+N, target_coord) - after.begin() -1;
        // printf("id=%lld, dist:%lld\n", id, id_dist);
        for(ll i=id_dist;i<id_dist+N;i++, num++){
            num %= N;
            ans[num] = after[i%N];
        }

        rep(i,N){
            printf("%lld\n", ans[i]);
        }
    }




}

int main(){
    Main();

    return 0;

}

Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;
const int INF = 1000000000;

int main(){
	int n;
	cin >> n;
	ll ans = 0;
	map<string,ll> mp;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		sort(s.begin(),s.end());
		mp[s]++;
	}

	for(auto p:mp){
		ans += p.second * (p.second - 1) / 2;
	}

	cout << ans << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int n;
	cin >> n;
	vector <int> a(n);
	int xorr = 0;
	for(int i = 0;i < n;++i) cin >> a[i], xorr ^= a[i];
	for(int i = 0;i < n;++i){
		cout << (xorr ^ a[i]) << " ";
	}
	cout << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std ;
#define pb push_back
#define mp make_pair
#define ll long long
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vll;

void solve(){
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
   
}

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






Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main(){
  int h[5],cnt[4];
  
  while(cin >> h[0],h[0]!=0){
    for(int i=1;i<5;i++) cin >> h[i];
    
    cnt[1] = 0;
    cnt[2] = 0;
    cnt[3] = 0;
    
    for(int i=0;i<5;i++) cnt[ h[i] ]++;
    
    for(int i=0;i<5;i++){
      
      if(cnt[1] == 5 || cnt[2] == 5 || cnt[3] == 5) cout << 3 << endl;
      else if(cnt[1] != 0 && cnt[2] != 0 && cnt[3] != 0) cout << 3 << endl;
      
      else if(cnt[1] == 0){
	if(h[i] == 2) cout << 1 << endl;
	if(h[i] == 3) cout << 2 << endl;
      }
      else if(cnt[2] == 0){
	if(h[i] == 3) cout << 1 << endl;
	if(h[i] == 1) cout << 2 << endl;
      }
      else if(cnt[3] == 0){
	if(h[i] == 1) cout << 1 << endl;
	if(h[i] == 2) cout << 2 << endl;
      }
    }

  }
  return(0);
}



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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
	long n,m,i,j,k,ans,cur,res,mod=998244353;
	cin >> n >> m >> k;
	
	if(m==1&&k==n-1){
		cout << 1 << endl; return 0;
	}else if(m==1){
		cout << 0 << endl; return 0;
	}
	vector<long> pinv(n+1),nc(k+1),mpow(n);
	ans=0;
	for(i=1; i<=n; i++){
		pinv[i]=modinv(i,mod);
	}
	nc[0]=1;
	for(i=1; i<=min(n,k); i++){
		nc[i]=(nc[i-1]*pinv[i])%mod;
		nc[i]=(nc[i]*(n-i))%mod;
	}
	
	mpow[0]=1; mpow[1]=m;
	for(i=1; i<n; i++){
		mpow[i]=(mpow[i-1]*(m-1))%mod;
	}
	
	/*
	for(i=1; i<=n; i++){
		cout << pinv[i] << ' ';
	}
	cout << endl;
	for(i=0; i<=min(n,k); i++){
		cout << nc[i] << ' ';
	}
	cout << endl;
	for(i=0; i<n; i++){
		cout << mpow[i] << ' ';
	}
	cout << endl;
	*/
	ans=0;
	for(i=0; i<=k; i++){
		cur=(m*mpow[n-1-i])%mod;
		cur=(cur*nc[i])%mod;
		ans=(ans+cur)%mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7936
package main

import(
    "fmt"
)



func main() {
    var a string
    fmt.Scan(&a)
    fmt.Printf("%s8%s",a[:3],a[4:])
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(d)  (d).begin(),(d).end()
#define RALL(d) (d).rbegin(), (d).rend()
#define PB push_back
#define MP make_pair
#define SZ(d) int((d).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,d,b) for(int i=(d);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(d) memset((d), 0 ,sizeof(d))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main()
{
	int n = 100001;
	vector<bool> e(n);
	REP(i, 2) e[i] = false;
	FOR(i, 2, n) e[i] = true;

	FOR(i, 3, n)
		FOR(j, 2, sqrt(i)+1) 
			if (i % j == 0)
				e[i] = false;
	auto c = VI(n);
	REP(i, 3) c[i] = 0;
	FOR(i, 3, n)
		c[i] = c[i-1] + ((e[i] && e[(i + 1) / 2]) ? 1 : 0);

	int q;
	cin >> q;
	auto l = VI(q);
	auto r = VI(q);
	
	REP(i, q) {
		int l, r;
		cin >> l >> r;
		cout << c[r] - c[l-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <ctype.h>

int main(void){

    char ch;
    while(1){
        scanf("%c",&ch);
        if(isupper(ch)!=0){
            ch=tolower(ch);
            printf("%c",ch);
        }else if(islower(ch)!=0){
            ch=toupper(ch);
            printf("%c",ch);
        }else{
            printf("%c",ch);
        }
        if(ch=='\n') break;
    }
    return 0;
}



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

int main(){
    int N, M, X;
    int A[M];
    cin >> N >> M >> X;
    int f[N+1];
    for(int i=0;i<=N;i++){
        f[i] = 0;
    }
    for(int i=0;i<M;i++){
        cin >> A[i];
        f[A[i]] = 1;
    }
    int sum1 = 0;
    int sum2=0;
    for(int i=X;i<=N;i++){
        if(f[i]==1) sum1++;
    }
    for(int i=X;i>=0;i--){
        if(f[i]==1) sum2++;
    }
    if(sum1>=sum2) cout <<sum2 <<"\n";
    else cout << sum1 <<"\n";

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int> L(N);
  for (auto &v : L) {
    cin >> v;
  }
  sort(L.begin(), L.end());
  vector<int> cnt(2001, 0);

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = L[i] + 1; j <= 2000; ++j) {
      ans += cnt[j];
    }
    for (int j = 0; j < i; j++) {
      cnt[L[j] + L[i]]++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3652
#Palindromic Numbers
a,b = map(int, input().split())
#12345
ans1=0
ans5=0
ans2=0
ans4=0
ans3=0
n=0
for i in range(a,b+1):
    ans5=i%10
    ans4=(i//10)%10
    ans3=(i//100)%10
    ans2=(i//1000)%10
    ans1=(i//10000)%10
    if ans5 == ans1:
        if  ans4 == ans2:
            n+=1
print(n)



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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, max_shifts = INT_MAX, a;
	cin >> N;
	REP(i, 0, N){
		cin >> a;
		int shifts = 0;
		while(a%2==0){
			a /=2;
			++shifts;
		}
		max_shifts = min(shifts, max_shifts);
	}
	cout << max_shifts;
}


Measured memory_bytes: 256
import sys
inp = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

def resolve():
    def dfs(v, parent):
        for nv in G[v]:
            if nv == parent:
                continue
            value[nv] += value[v]
            dfs(nv, v)

    N, Q = map(int, inp().split())
    G = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, inp().split())
        G[a].append(b)
        G[b].append(a)

    value = [0]*(N+1)
    for _ in range(Q):
        v, score = map(int, inp().split())
        value[v] += score

    dfs(1, 0)
    return print(*value[1:])

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 268412
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int d = scan.nextInt();
		int can = 2*d+1;
		int ans = 0;
		if(n%can == 0) {
			ans = n/can;
		}else {
			ans = n/can+1;
		}
		System.out.println(ans);
	}

}





Measured memory_bytes: 21844
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		String s = sc.next();
		HashSet<Character> set = new HashSet<>();
		for (char c : s.toCharArray()) {
			set.add(c);
		}
		for (char c = 'a'; c <= 'z'; c++) {
			if (set.contains(c)) {
				continue;
			} else {
				System.out.println(s + c);
				return;
			}
		}
//		char ha = 'z';
//		boolean flag = true;
//		for(char c : s.toCharArray()) {
//			if(ha==c) ha--;
//			else flag=false;
//		}
//		if(flag) {
//			System.out.println("-1");
//			return;
//		}
		for (int i = s.length() - 1; i > 0; i--) {
			String ss = s.substring(i);
			String a = s.substring(0, i-1);
			//System.out.println(ss);
			for (char c : ss.toCharArray()) {
				set.remove(c);
			}
			for (char c = s.charAt(i - 1); c <= 'z'; c++) {
				if (set.contains(c)) {
					continue;
				} else {
					System.out.println(a+c);
					return;
				}
			}
			for (char c : ss.toCharArray()) {
				set.add(c);
			}
		}
		System.out.println(-1);
	}
}

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

int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    sort(a.rbegin(),a.rend());
    ll ans=0;
    int t=n-1;
    rep(i,n){
        int lim=2;
        if(i==0)lim=1;
        rep(j,lim){
            if(t>0){
                ans+=a[i];
                t--;
            }
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
map<ll,bool>used;
inline ll oper(ll n,ll m){
	while(n>=m){
		if(n%m==0)n/=m;
		else n%=m;
	}
	return n;
}
set<ll>ans;
int main(void){
	ll n;
	cin>>n;
	if(n==2){
		cout<<1;
		return 0;
	}
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			if(oper(n,i)==1){
				ans.insert(i);
			}
		}
//		cout<<i<<' '<<k<<endl;
	}
	n--;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			ans.insert(i);
			ans.insert(n/i);
		}
//		cout<<i<<' '<<k<<endl;
	}
	cout<<ans.size()+2;
	return 0;
}


Measured memory_bytes: 256
//Created Time:2019年10月27日 星期日 20时09分40秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#define db double
#define N 602

using namespace std;

int n, m;
db mat[N][N], deg[N], ans[N], tmp[N];
bool mp[N][N];

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i){
		int u, v; scanf("%d%d", &u, &v);
		mp[u][v] = true; deg[u] += 1.0;
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j)
			if(mp[i][j])
				mat[i][j] = -1.0 / deg[i];
		mat[i][i] = 1.0; mat[i][n + 1] = 1.0;
	}
	mat[n][n + 1] = 0;
	for(int i = 1; i <= n; ++i){
		int mx = i;
		for(int j = i + 1; j <= n; ++j)
			if(fabs(mat[j][i]) > fabs(mat[mx][i])) mx = i;
		if(i != mx) swap(mat[i], mat[mx]);
		db div = mat[i][i];
		for(int j = i; j <= n + 1; ++j) mat[i][j] /= div;
		for(int j = i + 1; j <= n; ++j){
			div = mat[j][i];
			for(int k = i; k <= n + 1; ++k) mat[j][k] -= mat[i][k] * div;
		}
	}
	for(int i = n; i; --i){
		ans[i] = mat[i][n + 1];
		for(int j = n; j > i; --j) ans[i] -= ans[j] * mat[i][j];
	}

	memcpy(tmp, ans, sizeof tmp);
	db res = ans[1];
	for(int i = 1; i <= n; ++i)
		if(deg[i] > 1.0){
			double mx = 0.0, sum = 0.0;
			for(int j = i + 1; j <= n; ++j)
				if(mp[i][j]) sum += ans[j], mx = max(mx, ans[j]);
			ans[i] = (sum - mx) / (deg[i] - 1) + 1;
			for(int j = i - 1; j; --j){
				ans[j] = 0.0;
				for(int k = j + 1; k <= n; ++k)
					if(mp[j][k]) ans[j] += ans[k];
				ans[j] /= deg[j]; ans[j] += 1.0;
			}
			res = min(res, ans[1]); memcpy(ans, tmp, sizeof ans);
		}
	printf("%.10lf", res);
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#define int long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define rc(s) return cout<<s,0
using namespace std;

int n,a[25];

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie();cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    int maxi=0,ans=0;
    for(int i=1;i<=n;i++){
        maxi=max(maxi,a[i-1]);
        if(a[i]>=maxi) ans++;
    }
    rc(ans);
}


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

int main(){
  int N; cin >> N;
  long long result=0;
  long long absmin=1e9;
  int cntminus=1;
  for(int i=0; i<N; i++){
    long long a; cin >> a;
    if(a>0){
      cntminus*=1;
    }else if(a==0){
      cntminus*=0;
    }else{
      cntminus*=(-1);
    }
    a=(a>0?a:-a);
    result+=a;
    absmin=(absmin<a?absmin:a);
  }
  if(cntminus==-1){
    cout << result - 2 * absmin << endl;
  }else{
    cout << result << endl;
  }
}

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

int main() {
 
int a,b;
string op;

for(int i = 0;i < 10000; i++){   

cin >> a >> op >> b;

if(op == "+"){
    cout << a + b << endl;
}
else if(op == "-"){
    cout << a - b << endl;
}
else if(op == "*"){
    cout << a * b << endl;
}
else if(op == "/" && b != 0){
    cout << a / b << endl;
}
else{

}

if(op == "?"){
    break;
}

}
} 


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

using namespace std;

const int N = 100010;

int cnt[N];

int main() {
  int n;
  scanf("%d", &n);
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ++x;
    ++cnt[x - 1];
    ++cnt[x];
    ++cnt[x + 1];
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans = max(ans, cnt[i]);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
	int h, w;
	cin>>h>>w;
	string s[300];
	for(int i=0; i<h; i++) cin>>s[i];
	char c[1000][1000];
	for(int i=0; i<1000; i++){
		fill(c[i], c[i]+1000, '.');
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(s[i][j]=='#') c[i+300][j+300]='#';
		}
	}

	ll ct1[601][301], ct2[601][301];
	for(int k=0; k<h+w-1; k++){
		ct1[k][0]=0;
		for(int j=1; j<=w; j++){
			ct1[k][j]=ct1[k][j-1];
			if(c[k-j+1+300][j-1+300]=='#') ct1[k][j]++;
		}
	}
	for(int k=0; k<h+w-1; k++){
		ct2[k][0]=0;
		for(int j=1; j<=w; j++){
			ct2[k][j]=ct2[k][j-1];
			if(c[k-w+1+j-1+300][j-1+300]=='#') ct2[k][j]++;
		}
	}

	ll ans=0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(s[i][j]!='#') continue;
			for(int d=1; i-d>=0 && j+d<w; d++){
				if(s[i-d][j+d]!='#') continue;
				if(i+j-2*d<0) continue;
				ans-=ct1[i+j-2*d][max(0, j-d)];
				ans+=ct1[i+j-2*d][j];
			}
			for(int d=1; i-d>=0 && j+d<w; d++){
				if(s[i-d][j+d]!='#') continue;
				if(i+j+2*d>=h+w-1) continue;
				ans-=ct1[i+j+2*d][min(w, j+d+1)];
				ans+=ct1[i+j+2*d][min(w, j+2*d+1)];
			}
			for(int d=1; i+d<h && j+d<w; d++){
				if(s[i+d][j+d]!='#') continue;
				if(i-j-2*d<=-w) continue;
				ans-=ct2[i-j-2*d+w-1][min(j+d, w)];
				ans+=ct2[i-j-2*d+w-1][min(j+2*d, w)];
			}
			for(int d=1; i+d<h && j+d<w; d++){
				if(s[i+d][j+d]!='#') continue;
				if(i-j+2*d>=h) continue;
				ans-=ct2[i-j+2*d+w-1][max(j-d+1, 0)];
				ans+=ct2[i-j+2*d+w-1][j+1];
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4224
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    int n;cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    vector<long long> dp(n,1ll<<62);
    dp[0]=0;
    for(int i=1;i<n;++i){
        if(i-2>=0)dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
        if(i-1>=0)dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
import sys

s=input()

c_count=0
s_count=0
for i in range(len(s)):
    if i==0 and s[i]!="A":
        print('WA')
        sys.exit()
    if 2<=i<=len(s)-2:
        if s[i]=="C":
            c_count+=1
    if s[i].islower():
        s_count+=1
if c_count==1 and s_count==len(s)-2:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Throwable {
        InputStream is = null;
        if (false) {
            String input = "1\n" +
"99999";
            is = new ByteArrayInputStream(input.getBytes());
        } else {
            is = System.in;
        }
        try (BufferedReader r = new BufferedReader(new InputStreamReader(is))) {
            int N = readInt(r);
            int[] as = readInts(r);
            int[] counts = new int[(int)Math.pow(10, 5)];

            for (int a : as) {
                counts[a]++;
            }

            int max = -1;
            int maxIndex = -1;
            for (int i = 0; i < counts.length; i++) {
                int before = i == 0 ? 0 : counts[i - 1];
                int after = i == counts.length - 1 ? 0 : counts[i + 1];
                int total = before + after + counts[i];
                if (total > max) {
                    max = total;
                    maxIndex = i;
                }
            }
            System.out.println(max);
        }
    }

    private static int readInt(BufferedReader r) throws IOException {
        return Integer.parseInt(r.readLine());
    }

    private static int[] readInts(BufferedReader r) throws IOException {
        String[] data = r.readLine().split("\\s");
        int[] vals = new int[data.length];
        for (int i = 0; i < vals.length; i++) {
            vals[i] = Integer.parseInt(data[i]);
        }
        return vals;
    }

}


Measured memory_bytes: 35804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for (int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef vector<vector<vector<ll>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int n;
ll L[90];
int main() {
    cin >> n;
    L[0] = 2;
    L[1] = 1;
    for (int i = 0; i <= n; i++){
        L[i+2] = L[i+1] + L[i];
    }
    cout << L[n] << endl;
    return 0;
}


Measured memory_bytes: 3528
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).*begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const int M = 1000000007;

string s;

typedef string::const_iterator State;
int number(State&);
int term(State&);
int expression(State&);


// ??°??????????????????????????????????????°????????????
int number(State &begin) {
    int ret = 0;

    while (isdigit(*begin)) {
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }

    return ret;
}


// ?????????????????????????????????????????????????????????????????????
int term(State &begin) {
    if (*begin == 'S') {
        begin++; begin++;
        long long ret = expression(begin);
        begin++;
        return ret * ret % M;
    } else {
        return number(begin);
    }
}

// ?????????????????????????????????????????????????????????????????????
int expression(State &begin) {
    int ret = term(begin);

    while(s.end() - begin >= 2){
        if (*begin ==  '>' && *(begin + 1) == '>' && *(begin + 2) != '>'){
            begin++; begin++;
            ret = ret >> min(term(begin), 31);
        } else {
            break;
        }
    }

    return ret;
}

int main(){
    string tmp;
    while(getline(cin,tmp),tmp != "#"){
        s="";
        for(auto it:tmp) if(it != ' ') s+=it;
        State state = s.begin();
        cout << expression(state) << endl;
    }
}

Measured memory_bytes: 4860
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    a = INT()
    s = input()
    if a >= 3200:
        print(s)
    else:
        print('red')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256