akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
	int X,Y,i,j,a,b,ab ,flag;
	scanf("%d %d",&X,&Y);
	flag=0;
	i=X;
	j=0;
	while(i>-1){
		ab=0;
		a=0;
		b=0;
		a=2*i;
		b=4*j;
		ab=a+b;
		if(ab==Y)flag=1;
		i=i-1;
		j=j+1;
	}
	if(flag==0)printf("No");
	if(flag==1)printf("Yes");
	return 0;
}


Measured memory_bytes: 1728
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
n=int(input())
a=[0]
a.extend(lmp())
l=[0]*(n+1)#iの倍数の箱にいくつ玉が入っているか
ans=[]

for i in range(n,0,-1):
    if (l[i]-a[i])%2==1:
        ans.append(i)
        for k in make_divisors(i):
            l[k]+=1

print(len(ans))
print(*ans[::-1])
    

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

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


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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> p(n, k) ;
    int a;
    rep(i, q){
        cin >> a;
        p[a - 1] += 1;
    } 
    rep(i, n){
        p[i] -= q;
        if(p[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }    
    return 0;
}

Measured memory_bytes: 1024
/* Author : Pranav Deshmukh
            PICT,Pune
   Stay Focused!
*/

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define float           double
#define ms(s, n) 		memset(s, n, sizeof(s))
#define dip(type,var)   type var; cin>>var;
#define dipi(x)         int x; cin>>x;
#define dipi2(x,y)      int x,y; cin>>x>>y;
#define w(x)            int x; cin>>x; while(x--)
#define mka(type,arr,n) type *arr=new type[n];
#define fo(i,n)         for(int i=0;i<n;i++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define endl            "\n"
#define f               first
#define s               second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

// void c_p_c()
// {
// 	ios_base::sync_with_stdio(0);
// 	cin.tie(0);
// 	cin.tie(0);
// #ifndef ONLINE_JUDGE

// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
// }

int32_t main() {
	// c_p_c();
	int count = 0;
	dipi(n);
	mka(int, arr, n);
	fo(i, n) {
		cin >> arr[i];
	}
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (arr[i] + arr[j] > arr[k] && arr[j] + arr[k] > arr[i] && arr[i] + arr[k] > arr[j] && arr[i] != arr[j] && arr[j] != arr[k] && arr[i] != arr[k]) {
					count++;
				}
			}
		}
	}
	cout << count << endl;
	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}


Measured memory_bytes: 3780
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include<iostream>
#include<queue>
#include<string>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<(int)s.size();i++){
		if(s[i]==',')
			s[i]=' ';
	}
	cout<<s<<"\n";

	return 0;
}



Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    vi diameters = input<int>(N);

    sort(diameters.begin(), diameters.end());

    int height = 1;
    int previous = diameters[0];

    repeat (i, diameters.size()) {
        if (previous != diameters[i]) {
            height++;
            previous = diameters[i];
        }
    }
    cout << height << endl;
    return 0;
}


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

int main(){
    while( true ){
        int n, m, s, d;
        string amida[30];
        cin >> n;
        if( !n ) break;
        cin >> m >> s >> d;
        for(int i = 0; i < d; i++){
            cin >> amida[i];
        }
        vector< vector<int> > cur(31, vector<int>(n,0));
        for(int i = 0; i < n; i++){
            cur[0][i] = i+1;
        }
        for(int i = 0; i < d; i++){
            vector<int> tmp( cur[i] );
            for(int j = 0; j < n-1; j++){
                if( amida[i][j] == '1' ){
                    swap( tmp[j], tmp[j+1] );
                }
            }
            cur[i+1] = tmp;
        }
        if( cur[d][s-1] == m ){
            cout << 0 << endl;
        }else{
            int a = cur[d][s-1];
            bool ok = false;
            for(int i = 0; i < d && !ok; i++){
                for(int j = 0; j < n-1 && !ok; j++){
                    if( amida[i][j] == '0' &&
                            ( !j       || amida[i][j-1] == '0' ) &&
                            ( j == n-2 || amida[i][j+1] == '0' ) &&
                            ((cur[i][j] == m && cur[i][j+1] == a ||
                              cur[i][j] == a && cur[i][j+1] == m )) ){
                        cout << i+1 << ' ' << j+1 << endl;
                        ok = true;
                    }
                }
            }
            if( !ok ) cout << 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1228
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

public class Main{

	public static void main(String[] args) {
		FastScanner stdIn = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = stdIn.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		long[] s = new long[n+1];
		s[0] = 0;
		for(int i = 1; i < n+1; i++) {
			s[i] = s[i-1]+a[i-1];
		}
		Map<Long,Long>map = new HashMap<>();
		
		for(int i = 0; i < n+1; i++) {
			if(map.containsKey(s[i])) {
				map.put(s[i],map.get(s[i])+1);
			}else {
				map.put(s[i],(long)1);
			}
		}
		long ans = 0;
		
		for(long k: map.keySet()) {
			ans += map.get(k)* (map.get(k)-1)/2;
		}
		out.println(ans);
		out.flush();
	}

}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 54268
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const signed INF_=1001001001; const int INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":"\n");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct union_find {
    vector<int> data;
    union_find(int size) : data(size, -1) {}
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};
signed main() {
    int N=IN,M=IN;
    vector<pii> e(M);
    cin>>e;
    int ans=0;
    REP(i,M) {
        union_find uf(N);
        REP(j,M) {
            if(i==j) continue;
            int a=e[j].first,b=e[j].second;
            uf.unite(a-1,b-1);
        }
        if(uf.size(0)!=N) {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int n; cin >> n;
    string s; cin >> s;
    if(n%2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    string a = s.substr(0, s.size()/2);
    string b = s.substr(s.size()/2, s.size()/2);

    if(a == b) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
        return 0;
    }

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    y = x;
    sort(y.begin(), y.end());
    for (int i = 0; i < n; i++){
        if (y[n / 2] > x[i]) {
            cout << y[n / 2] << endl;
        }else{
            cout << y[n / 2 - 1] << endl;
        }
    }
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var A = int.Parse(ReadLine());
        var B = int.Parse(ReadLine());

        var ans = Enumerable.Range(1, 3).Except(new int[] { A, B }).First();

        WriteLine(ans);
    }
}


Measured memory_bytes: 28104
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b-1]+=1
b=True
for i in range(n):
  if l[i]%2==1:
    b=False
if b:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 3828
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if (S.indexOf("a") != -1 && S.indexOf("b") != -1 && S.indexOf("c") != -1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21972
n = int(input())
l = sorted(map(int, input().split()))
count = 0
for i in range(n-2):
  li = l[i]
  for j in range(i+1, n-1):
    lj = l[j]
    if li == lj:
      continue
    l_sum = li + lj
    for k in range(j+1, n):
      lk = l[k]
      if lj == lk:
        continue
      if lk < l_sum:
        count += 1
      else:
        break
print(count)

Measured memory_bytes: 9148
#include <cstdio>
#include <math.h>

using namespace std;

int main(){
  int a, b;
  while(true) {
    scanf("%d %d", &a, &b);
    if(a==0 && b==0) {
      return 0;
    }
    for(int i=0; i<a; i++) {
      for(int j=0; j<b; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2588
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x, n, y, z=1, i, t;
	scanf("%d", &n);
	if(n>=1 && n<=100){
			z=800*n;
		if(n>15){
			i=n/15;
			t=z-(i*200);
			printf("%d", t);
		}
		else{
			printf("%d", z);
		}
	}
	else{
		printf("Error");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;
typedef long long int ll;

int main(){

    int N;
    cin >> N;
    char s[16];
    int p[256] = {};
    for (int i = 0; i < N; i++) {
        cin >> s;
        p[s[0]]++;
    }
 
    char *c = "MARCH";
    int64_t q[5];
    for (int i = 0; i < 5; i++) {
        q[i] = p[c[i]];
    }
    

    int64_t total = 0;
    total = q[0] * q[1] * q[2] + q[0] * q[1] * q[3] + q[0] * q[1] * q[4] + q[0] * q[2] * q[3] + q[0] * q[2] * q[4] + q[0] * q[3] * q[4] + q[1] * q[2] * q[3] + q[1] * q[2] * q[4] + q[1] * q[3] * q[4] + q[2] * q[3] * q[4];
    

    cout << total << endl;

    return 0;
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

const LL p = 998244353;
const int N = 2e5 + 7;

LL fac[N];
LL inv_fac[N];

LL bin_pow(LL n, LL k) {
  if (k == 0) {
    return 1;
  }

  if (k & 1) {
    return (n * bin_pow(n, k - 1)) % p;
  }

  LL tmp = bin_pow(n, k / 2);
  return (tmp * tmp) % p;
}

LL inv(LL x) { return bin_pow(x, p - 2); }

LL coeff(LL n, LL k) {
  return ((fac[n] * inv_fac[n - k]) % p * inv_fac[k]) % p;
}

int main() {
  _upgrade;
  LL n, m, k;
  cin >> n >> m >> k;

  fac[0] = 1;
  inv_fac[0] = inv(fac[0]);
  for (LL i = 1; i <= n; i++) {
    fac[i] = (i * fac[i - 1]) % p;
    inv_fac[i] = inv(fac[i]);
    assert((fac[i] * inv_fac[i]) % p == 1);
  }

  LL ans = 0;
  for (int i = 0; i <= k; i++) {
    LL next = (coeff(n - 1, i) * m) % p;
    next = (next * bin_pow(m - 1, n - 1 - i)) % p;
    ans = (ans + next) % p;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 6696
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define FOR(a,b,c) for(int a = (b); a <= (c); a++)
#define RFOR(a,b,c) for(int a = (b); a >= (c); a--)
#define all(x) (x).begin(), (x).end()
#define vi vector <int>
#define vvi vector <vi>
#define ll long long
#define vll vector <ll>
#define vvl vector <vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ep emplace
#define fs first
#define sd second
#define mod 998244353
#define EPS 1e-9
#define tc int t; cin >> t; while(t--)
using namespace std;

int main() {
    FIO;
    string s; cin >> s;
    if(s == "ABC") cout << "ARC" << '\n';
    else cout << "ABC" << '\n';
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n;
   std::cin >> n;
   std::vector<Int> xss[3];
   rep(i,3) {
      xss[i].resize(n);
      rep(k,n) std::cin >> xss[i][k];
      std::sort(xss[i].begin(), xss[i].end());
   }
   std::vector<Int> ys(n);
   Int res = 0;
   rep(i,n) {
      Int x = std::lower_bound(xss[0].begin(), xss[0].end(), xss[1][i]) - xss[0].begin();
      Int y = xss[2].end() - std::upper_bound(xss[2].begin(), xss[2].end(), xss[1][i]);
      res += x * y;
   }
   printf("%ld\n", res);
}


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

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

  int N;
  string S;
  cin >> N >> S;
  int red = 0;
  int blue = 0;
  int green = 0;
  for(int i = 0; i < N; i++){
    if(S[i] == 'R'){
      red++;
    } else if(S[i] == 'G'){
      green++;
    } else{
      blue++;
    }
  }

  long long ans = (long long)red * green * blue;

  for(int i = 0; i < N - 2; i++){
    for(int j = i + 1; j < N - 1; j++){
      if(S[i] != S[j]){
        if(2 * j - i < N){
          if(S[i] != S[2 * j - i] && S[j] != S[2 * j - i]){
            ans--;
          }
        }
      }
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n,x; cin>>n>>x;
  vector<int> m(n);
  int ans=0;
  int mini=INF;
  rep(i,n){
    cin>>m[i];
    ans+=m[i];
    mini=min(mini,m[i]);
  }

  int c=n;
  x-=ans;
  c+=(x/mini);
  cout<<c<<endl;


  return 0;

}


Measured memory_bytes: 256
import collections
N = int(input())

lst = [0]*1000000
l = 0
res = 0

for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            lst[l] = i**2 + j**2 + k**2 + i*j + j*k + k*i
            l += 1

L = collections.Counter(lst)

for h in range(1,N+1):
    print(L[h])

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if(n >= m) {
            System.out.println(0);
            return;
        }
        int[] x = new int[m];
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        int[] xx = new int[m - 1];
        for (int i = 0; i < xx.length; i++) {
            xx[i] = x[i + 1] - x[i];
        }
        Arrays.sort(xx);
        int ans = 0;
        for (int i = 0; i < m - n; i++) {
            ans += xx[i];
        }
        System.out.println(ans);
    }
}

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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define pb(x) push_back(x)
#define fo(i, a, n) for (i = (a); i < (n); i++)
#define foe(i, a, n) for (i = (a); i <= (n); i++)
// clang-format off
#define vin(a) for (ll i = 0; i < sz(a); i++) { cin >> a[i]; } 
#define vout(a) for (auto x : a) { cout << x << " "; }
#define sws                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
// clang-format on
#define pd(x) cout << x
#define sd(x) cin >> x
#define nl cout << endl
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define foreach(i, a)                                                          \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
// int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve() {
  ll m, n;
  ll i, j;
  cin >> n >> m;
  unordered_set<int> s;
  fo(i, 0, m) {
    cin >> j;
    s.insert(j);
  }
  for (;;) {
    j = n;
    bool ok = true;
    while (j > 0) {
      i = j % 10;
      j /= 10;
      if (s.find(i) != s.end()) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << n << endl;
      return;
    }
    n++;
  }
}

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

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define sll set<ll>
#define str string
#define rev reverse
#define mp make_pair
#define pb push_back
#define acc accumulate
#define vll vector<ll>
#define eb emplace_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define dq deque<ll>
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mll map<ll,ll>
bool visited[200005];
vll adj[200005];
ll dist[200005];

void initialize()
{
    for(ll i=0;i<200005;i++)
    {
        visited[i]=false;
        adj[i].clear();
        dist[i]=0;

    }
}

void bfs(ll s)
{
    visited[s]=true;
    list<ll> q;
    q.pb(s);
    ll i;
    while(!q.empty())
    {
        s=q.front();
        q.pop_front();
        //cout << s << endl;
        for(i=0;i!=adj[s].size();i++)
        {
            if(!visited[adj[s][i]])
            {
                dist[adj[s][i]]=s;
                visited[adj[s][i]]=true;
                q.pb(adj[s][i]);
            }
        }
       
    }
    
}


void solve()
{
    ll nodes,edges,i,p,q;
    cin >> nodes >> edges;
    initialize();
    ll c=0;
    for(i=0;i<edges;i++)
    {
        cin >> p >> q;
        adj[p].pb(q);
        adj[q].pb(p);
    }
    bfs(1);
    ll f=1;
    for(i=2;i<=nodes;i++)
    {
        if(dist[i]==0)
            f=0;
    }
    if(f==0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
        for(i=2;i<=nodes;i++)
        {
            cout << dist[i] << endl;
        }
    }
    
}

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

Measured memory_bytes: 18060
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a - (b + c) >= 0) {
            System.out.println(0);
        } else {
            System.out.println(b + c - a);
        }
    }

}


Measured memory_bytes: 21844
N = int(input())

Q = 10 ** 9 + 7

a10 = 1
a9 = 1
a8 = 1

for _ in range(N):
    a10 *= 10 
    a9 *= 9 
    a8 *= 8
      
    a10 %= Q
    a9 %= Q
    a8 %= Q

ans = (a10 - (2 * a9 - a8)) % Q

print(ans)

Measured memory_bytes: 9096
#include <iostream>

using namespace std;

const int MAX_N = 3e5 + 5;

typedef long long ll;

int arr [MAX_N];
ll altpref [MAX_N];

bool can (ll K, int n) {
  ll req = K;
  for (int i = 1; i <= n; i += 2) {
    if (altpref[i] >= req) {
      if (i == n) return true;
      req = min(req, altpref[i + 1] + K);
    }
  }
  return false;
}

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }

  if (n % 2 == 0) {
    // easy case
    int anse = 0, anso = 0;
    for (int i = 1; i <= n; i++) {
      if (i % 2 == 0) {
        anse += arr[i];
      } else {
        anso += arr[i];
      }
    }

    int ans = max(anse, anso);
    cout << ans << " " << sum - ans << '\n';
  } else {
    // hard case
    int def = 0;
    for (int i = 2; i <= n; i += 2) {
      def += arr[i];
    }

    for (int i = 1; i <= n; i++) {
      if (i % 2 == 1) {
        altpref[i] = altpref[i - 1] + arr[i];
      } else {
        altpref[i] = altpref[i - 1] - arr[i];
      }
    }

    int ans = 0;
    for (int i = 1 << 29; i != 0; i /= 2) {
      if (can(ans + i, n)) {
        ans += i;
      }
    }

    ans += def;
    cout << ans << " " << sum - ans << '\n';
  }
}


Measured memory_bytes: 7148
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]

n=II()
s=SI()
allr=s.count("R")
lr=s[:allr].count("R")
print(allr-lr)


Measured memory_bytes: 9412
import java.util.Scanner;

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

			int n = sc.nextInt();
			
			String s = sc.next();
			
			if ( n % 2 != 0 ) {
				System.out.println("No");
				return;
			}
			
			boolean isMatch = true;
			for(int i = 0 ; i < n / 2 ; i++ ) {
				if ( s.charAt(i) != s.charAt(n/2 + i) ) {
					isMatch = false;
				}
			}
			
			System.out.println(isMatch ? "Yes" : "No");
			
		}
	}
}


Measured memory_bytes: 20688
using System;

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split();
        var n = int.Parse(nm[0]);
        var m = int.Parse(nm[1]);
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var pairs = new Tuple<int, int>[m];
        for (int i = 0; i < m; i++)
        {
            var bc = Console.ReadLine().Split();
            pairs[i] = Tuple.Create(int.Parse(bc[0]), int.Parse(bc[1]));
        }

        Array.Sort(a);
        Array.Sort(pairs, (x, y) => y.Item2 - x.Item2);

        for (int i = 0, j = 0; j < n && i < m; i++)
        {
            for (int k = 0; j < n && k < pairs[i].Item1; j++, k++)
            {
                a[j] = Math.Max(a[j], pairs[i].Item2);
            }
        }

        var ans = 0L;
        for (int i = 0; i < n; i++)
        {
            ans += a[i];
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 31684
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>

using namespace std;

typedef long long ll;


const int INF = 1e9;
const ll LLINF = 1LL<<60;

struct edge
{
	int to, co;
	edge(int t, int c) :to(t), co(c) {}
};

struct st
{
	int a, b, co;
	st(int a, int b, int co) :a(a), b(b), co(co) {}
};

int N, M, C;
int d[100000];
vector<edge> g[100000];
vector<st> v;
ll sum;
map<ll, ll> mp;

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>> pq;
	fill(d, d + N, INF);
	d[s] = 0;
	pq.push(P(0, s));

	while (!pq.empty())
	{
		P p = pq.top(); pq.pop();
		if (d[p.second] < p.first) continue;
		for (auto e : g[p.second]) {
			if (d[e.to] > p.first + e.co) {
				d[e.to] = p.first + e.co;
				pq.push(P(d[e.to], e.to));
			}
		}
	}
}

int main() {
	cin >> N >> M >> C;
	sum = 0;
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		
		g[a].emplace_back(b, c);
		g[b].emplace_back(a, c);
		v.emplace_back(a, b, c);

		sum += c;
	}

	dijkstra(0);

	vector<ll> sd;
	for (int i = 0; i < N; i++) sd.push_back(d[i]);
	sort(sd.begin(), sd.end());
	sd.erase(unique(sd.begin(), sd.end()), sd.end());

	for (auto e:v) {
		ll tmp = max(d[e.a], d[e.b]);
		if (mp.count(tmp) == 0) mp[tmp] = e.co;
		else mp[tmp] += e.co;
	}

	ll ret = LLINF;
	for (auto e : sd) {
		sum -= mp[e];
		ret = min(ret, C*e + sum);
	}

	cout << ret << endl;


	return 0;
}



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

int main(){
 long long A,B,C,ans;
cin>>A>>B>>C;
  ans=0;
  if(B+C<=A){
    ans=0;
  }
  else{
    ans=C-A+B;
  }
      cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int a, b, c, x = 0;
	cin >> a >> b >> c;
	x = a * 100 + b * 10 + c;
	if (x % 4 == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}
/*
死のマウス
.　　あり許せん！
　　　∧＿＿∧
　|| （＃｀Д´ ） ||
　|| ( |　 　| | |||
　从| |　 　| |从从
￣) ⊂ノ￣￣!_つ￣て
　フヘ(　　　　ヽヘ(＼

*/

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 100000007
typedef long long ll;
using namespace std;
ll n,t[100010];
vector<int> v[100010];
ll DFS(int x,int from){
  if(v[x].size()==1)return t[x];
  ll sum=0,maxi=0;
  lol(i,v[x].size()){
    if(v[x][i]==from)continue;
    ll res=DFS(v[x][i],x);
    if(res<0)return -1;
    sum+=res;
    maxi=max(maxi,res);
  }
  if(sum-t[x]<0)return -1;
  if(sum-t[x]<=min(sum/2,sum-maxi))return t[x]*2-sum;
  return -1;
}
int main(){
  cin>>n;
  lol(i,n)cin>>t[i];
  lol(i,n-1){
    int a,b;cin>>a>>b;
    a--,b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  if(n==2){
    if(t[0]==t[1])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  else{
    lol(i,n)if(v[i].size()>1){
      if(DFS(i,-1)==0)cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
      break;
    }
  }
  return 0;
}


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

int main(){
    int n;
    int k;

    cin>>n;
    cin>>k;

    vector<int> p;
    int temp;

    for(int i=0;i<n;i++){
        cin>>temp;
        p.push_back(temp);
    }
    sort(p.begin(),p.end());

    int ans=0;

    for(int i=0;i<k;i++){
        ans+=p[i];
    }

    cout<<ans;

    return 0;

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

vector<int> v(105);
ll dp[105][100010]; //dp[child #][number of candies left] = possibilities up to this point

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    int n, k;
    cin >> n >> k;
    for(int i=1; i<=n; i++)
        cin >> v[i];
    dp[0][0]=1;
    for(int i=1; i<=n; i++)
    {
        dp[i][0] = 1;
        for(int j=1; j<=100000; j++)
        {
            if(j>v[i]) dp[i][j] = (dp[i][j-1]+dp[i-1][j]-dp[i-1][j-v[i]-1])%mod;
            else dp[i][j] = (dp[i][j-1]+dp[i-1][j])%mod;
        }
    }
    cout << (dp[n][k]+mod)%mod;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  cout << n-i+1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"
const int N = 1e6 + 10;


signed main()
{
    FAST;
    int t;
    t=1;
    
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        cin>>n;
        int a[n];
        map<int,int> mp,mp1;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            mp[a[i]]++;
        }
        
        ans=0;
        
        
        
        for(auto it : mp)
        {
            int num = it.first;
            count = it.second;
            
            if(count==1 && mp1.count(num)==0)
            {
                ans++;
            }
            
            if(mp1.count(num)==0)
            {
                for(i=2;i*num<N;i++)
                {
                    mp1[i*num]++;
                }
            }
            
        }
        
        cout<<ans<<endl;
        
        
    }
        
    
    
    
    
}


Measured memory_bytes: 80100
# c = list(map(int, input().split()))
a, b = map(int, input().split())
# a = [list(map(int, list(input()))) for i in range(n)]
# n = int(input())
# x = list(map(int, input().split()))


min_na = int(12.5 * a)
max_na = int(12.5 * (a + 1))
min_nb = int(10 * b)
max_nb = int(10 * (b + 1))

ret = -1
for i in range(min(min_na, min_nb), max(max_na, max_nb) + 1):
    if int(i * 0.08) == a and int(i * 0.1) == b:
        ret = i
        break

print(ret)


Measured memory_bytes: 3060
//IIT Kanpur FacelessMen India
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 500+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

int arr[N][N];
int f[N];
int main(){
  // freopen("product.in","r",stdin);
  // freopen("product.out","w",stdout);
  int n; scanf("%d",&n);
  int tot=0,ans=mod;
  REP(i,n){
    char s[1000]; scanf("%s",s);
    REP(j,n) {
      if(s[j]=='#') arr[i][j]=1; else arr[i][j]=0;
      tot+=arr[i][j];
    }
  }
  if(tot==0){
    printf("-1\n"); exit(0);
  }
  REP(i,n) {
    int z=1;
    REP(j,n) z=min(z,arr[j][i]); f[i]=z;
  }
  REP(i,n){

    int k=0;
    REP(j,n) if(arr[j][i]) k=1;
    
    int zp=0,lo=0;
    REP(j,n) if(arr[i][j]) zp+=1-f[j]; else lo++;
    ans=min(ans,zp+2*lo+1-k);
    
  }
  assert(ans!=mod);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#define int long long
using namespace std;

signed main() {
  int L; cin >> L;
  vector<tuple<int, int, int> > G;

  for(int i = 1; i <= 18; ++i) {
    G.push_back(make_tuple(i, i + 1, 0));
    G.push_back(make_tuple(i, i + 1, (1 << (i - 1))));
  }

  int Z = L, sum = 0;
  for(int i = 19; i >= 1; --i) {
    while(Z >= (1 << (i - 1))) {
      G.push_back(make_tuple(i, 20, sum));
      sum += (1 << (i - 1));
      Z -= (1 << (i - 1));
    }
  }

  cout << 20 << " " << G.size() << endl;
  for(int i = 0; i < G.size(); ++i) {
    cout << get<0>(G[i]) << " " << get<1>(G[i]) << " " << get<2>(G[i]) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>

using namespace std;

int main(){

	int num,E,from,to,table[10000],tmp;
	vector<int> V[10000];
	queue<int> Q;

	for(int i = 0; i < 10000; i++)table[i] = 0;

	scanf("%d %d",&num,&E);

	for(int i = 0; i < E; i++){
		scanf("%d %d",&from,&to);
		V[from].push_back(to);
		table[to]++;
	}

	for(int i = 0; i < num; i++){
		if(table[i] == 0){
			Q.push(i);
		}
	}

	while(!Q.empty()){
		tmp = Q.front();
		Q.pop();
		printf("%d\n",tmp);
		for(int i = 0; i < V[tmp].size(); i++){
			table[V[tmp][i]]--;
			if(table[V[tmp][i]] == 0){
				Q.push(V[tmp][i]);
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3300
a = list(input())
flg = 1
c_flg = 0
for i in range(len(a)):
    if i == 0:
        if a[0] != 'A':
            flg = 0
            break
    else:
        if 2 <= i <= len(a) - 2:
            if a[i] == 'C':
                c_flg += 1
            else:
                if a[i].isupper():
                    flg = 0
                    break
        else:
            if a[i].isupper():
                flg = 0
                break

if flg and c_flg == 1:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 38512
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
    int N,L[220];
    scanf("%d",&N);
    for(int i=0;i<N*2;i++)
        scanf("%d",&L[i]);
    sort(L,L+2*N,greater<int>());
    int ans=0;
    for(int i=1;i<2*N;i+=2)
        ans+=L[i];
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1712
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  x <- getl toInt
  unless (x == 0) $ do
    xs <- replicateM 4 (getl toInt)
    mapM_ print . solve $ x : xs
    main
  
solve :: [Int] -> [Int]
solve xs
  | length ys == 2 = map (f ys) xs
  | otherwise = [3,3,3,3,3]
  where
    ys = sort . nub $ xs
    f [1,2] n = n
    f [1,3] n = if n == 3 then 1 else 2
    f [2,3] n = n - 1
    
toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4052
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

long long MOD = 1000000007;

int n;
long long a[300005];
long long ma[300005];
long long mi[300005];

int main(){
  cin>>n;
  for(int i=0;i<3*n;i++){
    cin>>a[i];
  }

  long long total = 0LL;
  for(int i=0;i<n;i++) total+=a[i];
  ma[n-1] = total;
  priority_queue<long long> pqma;
  for(int i=0;i<n;i++) pqma.push(-a[i]);
  for(int i=n;i<2*n;i++){
    long long tmp = -pqma.top();
    if(tmp < a[i]){
      pqma.pop();
      pqma.push(-a[i]);
      total -= tmp;
      total += a[i];
    }
    ma[i] = total;
  }

  total = 0LL;
  for(int i=3*n-1;i>=2*n;i--) total += a[i];
  mi[2*n] = total;
  priority_queue<long long> pqmi;
  for(int i=3*n-1;i>=2*n;i--) pqmi.push(a[i]);
  for(int i=2*n-1;i>=n;i--){
    long long tmp = pqmi.top();
    if(tmp > a[i]){
      pqmi.pop();
      pqmi.push(a[i]);
      total -= tmp;
      total += a[i];
    }
    mi[i] = total;
  }

  long long ans = ma[n-1]-mi[n];
  for(int i=n+1;i<=2*n;i++){
    ans = max(ans, ma[i-1]-mi[i]);
  }

  //for(int i=0;i<3*n;i++)cout<<a[i]<<" ";cout<<endl;
  //for(int i=0;i<3*n;i++)cout<<ma[i]<<" ";cout<<endl;
  //for(int i=0;i<3*n;i++)cout<<mi[i]<<" ";cout<<endl;
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007ll
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
struct bipartite_matching
{
	const static int MAX_V=210;
	int V;
	vector<int> G[MAX_V];
	int match[MAX_V];
	bool used[MAX_V];
	void init(int v){
		V = v;
	}
	void add_edge(int u,int v){
		G[u].pb(v);
		G[v].pb(u);
	}
	bool dfs(int v){
		used[v]=true;
		for(int i=0;i<G[v].size();i++){
			int u=G[v][i],w=match[u];
			if(w<0||!used[w]&&dfs(w)){
				match[v]=u;
				match[u]=v;
				return true;
			}
		}
		return false;
	}
	int matching(){
		int res=0;
		memset(match,-1,sizeof(match));
		for(int v=0;v<V;v++){
			if(match[v]<0){
				memset(used,0,sizeof(used));
				if(dfs(v))res++;
			}
		}
		return res;
	}
};
bipartite_matching bp;
int N;
int a[105],b[105],c[105],d[105];
int main(){
	cin >> N;
	bp.init(2*N);
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0;i<N;i++){
		cin >> c[i] >> d[i];
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(a[i]<c[j]&&b[i]<d[j]){
				bp.add_edge(i,j+N);
			}
		}
	}
	cout << bp.matching() << endl;
	return 0;
}

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

// RMQを求めるセグ木, 完全二分木, 蟻本p.155
struct segTree{
    int size; // 2べき, 葉の数
    vector<int> cbt; // complete binary tree
    segTree(int N){
        size = 1;
        while (size < N){
            size *= 2;
        }
        cbt.resize(size * 2 - 1, INT_MAX);
    }

    // v.size <= size の vector を入力
    void input(vector<int> v){
        for (int i = 0; i < v.size(); ++i) {
            cbt[size+i-1] = v[i];
        }
        for (int i = size - 2; i >= 0; --i) {
            cbt[i] = min(cbt[i*2+1], cbt[i*2+2]);
        }
    }

    // 葉のi番目(0-indexed)をxに更新
    void update(int i, int x){
        i += size - 1;
        cbt[i] = x;
        while (i > 0){
            i = (i - 1) / 2;
            cbt[i] = min(cbt[i*2+1], cbt[i*2+2]);
        }
    }

    // 区間[a, b)の最小値(0-indexed)を返す関数
    // 外から呼ぶときは query(a, b, 0, 0, n)
    int query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return INT_MAX;
        if(a <= l && r <= b) return cbt[k];
        int vl = query(a, b, k*2+1, l, (l+r)/2);
        int vr = query(a, b, k*2+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

#define MAX_M 100005

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> jobs(N);
    for (int i = 0; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        jobs[i] = make_pair(B, A); // 順番に注意
    }
    sort(jobs.begin(), jobs.end(), greater<pair<int, int>>());

    // セグ木でスケジュール管理しながら報酬で貪欲
    // 貪欲で棄却される仕事は完全下位互換(または同等)でそれを入れても報酬が上がらないことが保証される
    vector<int>sc(M); // 何日後までに報酬を受け取ればいいか
    for (int i = 0; i < M; ++i) {
        sc[i] = i+1;
    }
    segTree tree(MAX_M);
    tree.input(sc);
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int A = jobs[i].second;
        int B = jobs[i].first;
        int day = tree.query(A-1, tree.size, 0, 0, tree.size);
        if(day == INT_MAX) continue;
        ans += B;
        tree.update(day-1, INT_MAX);
    }
    cout << ans;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	cin.ignore();
	while (n--) {
		string line,word;
		getline(cin,line);
		string::size_type hoshino_pos;
		while ((hoshino_pos = line.find("Hoshino")) != string::npos) {
			line.replace(hoshino_pos + 6,1,"a");
		}
		cout << line << endl;
	}
}

Measured memory_bytes: 3036
#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 ans[105][105];

int main(){
	int h,w;
	cin >> h >> w;
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int id = 0;
	for (int i = 0; i < h; ++i) {
		if(i % 2 == 0){
			for (int j = 0; j < w; ++j) {
				if(a[id] == 0) id++;
				ans[i][j] = id + 1;
				a[id]--;
			}
		}else{
			for (int j = w-1; j >= 0; --j) {
				if(a[id] == 0) id++;
				ans[i][j] = id + 1;
				a[id]--;
			}
		}
	}
	rep(i,h){
		rep(j,w){
			cout << ans[i][j] << " ";
		}cout << endl;
	}
    return 0;
}



Measured memory_bytes: 3716