akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>          // printf(), getc()
#include <stdbool.h>

const char NUL = '\0';

bool
ope_line()
{
	char oline[101];
	const char letter[6][5] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};

	int c = getchar();
	if (c == EOF)
		return false;

	if (c == '\n')
		return true;

	bool b_na = false;
	int ix = 0;
	while (c != '\n' && c != EOF)
	{
		int s = c - '1';

		c = getchar();
		if (c == '\n' || c == EOF)
		{
			b_na = true;
			break;
		}

		int t = c - '1';
		if (0 <= s && s <= 5 && 0 <= t && t <= 4)
			oline[ix++] = letter[s][t];
		else
			b_na = true;

		c = getchar();
	}

	if (b_na)
		printf("NA\n");
	else
	{
		oline[ix] = NUL;
		printf("%s\n", oline);
	}

	if (c == EOF)
		return false;

	return true;
}

int
main(int argc, char **argv)
{
	while (true)
	{
		if (!ope_line())
			break;
	}

	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;

    if ((a != 0 && a <10) && (b != 0 && b <10)) cout << a*b << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3628
l = []
r = []
n, m = gets.strip.split.map(&:to_i)

m.times do |i|
	x, y =  gets.strip.split.map(&:to_i)
	l << x
	r << y
end

lmax = l.max
rmin = r.min

ans = rmin - lmax + 1
if ans < 0
	ans = 0
end
puts ans

Measured memory_bytes: 3456
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author varunvats32
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BFrog2 solver = new BFrog2();
        solver.solve(1, in, out);
        out.close();
    }

    static class BFrog2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] arr = new int[n + 1];

            // dp[i] -> The minimum cost to reach here.
            int[] dp = new int[n + 1];
            Arrays.fill(dp, Integer.MAX_VALUE);

            for (int i = 1; i <= n; i++) {
                arr[i] = in.nextInt();
            }

            dp[1] = 0;
            for (int i = 2; i <= n; i++) {
                for (int j = 1; j <= k; j++) {
                    if (i <= j) continue;
                    dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(arr[i] - arr[i - j]));
                }
            }

            out.println(dp[n]);
        }

    }
}



Measured memory_bytes: 58504
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;



int main() {
    int a,p,ans; cin>>a>>p;
    
    ans=(a*3+p)/2;
    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(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 1024;
int x[MAX_N];
int y[MAX_N];

int main2() {
  int N = nextInt();

  int parity = 0;
  REP(i, N) {
    x[i] = nextInt();
    y[i] = nextInt();
    if ((x[i] + y[i]) & 1) { parity |= 2; } else { parity |= 1; }
  }
  if (parity == 3) {
    cout << -1 << endl;
    return 0;
  }

  bool delta = ((x[0] + y[0]) & 1) == 0;

  vector<int> d;
  if (delta) d.push_back(1);
  for (int i = 0; i < 30; i++) d.push_back(1 << (30-i));
  d.push_back(1);

  printf("%d\n", (int)d.size());
  REP(i, d.size()) { printf(i > 0 ? " " : ""); printf("%d", d[i]); }
  printf("\n");

  REP(q, N) {
    int tx = x[q];
    int ty = y[q];

    string cmd;
    int cur_x = 0, cur_y = 0;
    REP(i, d.size()) {
      if (delta && i == 0) {
        cur_x += d[i];
        cur_y = 0;
        cmd += "R";
        continue;
      }
      int dx = tx - cur_x;
      int dy = ty - cur_y;
      if (dy < dx && dx + dy > 0) { cur_x += d[i]; cmd += "R"; }
      if (dy < dx && dx + dy < 0) { cur_y -= d[i]; cmd += "D"; }
      if (dy > dx && dx + dy > 0) { cur_y += d[i]; cmd += "U"; }
      if (dy > dx && dx + dy < 0) { cur_x -= d[i]; cmd += "L"; }
    }
    printf("%s\n", cmd.c_str());
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main(void){
    string s;
    cin >> s;

    int ans = 0;
    int l = s.length();
    for(int i=0; i <= (l / 2) - 1; i++){
        if(s[i] != s[l - i - 1]) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <boost/multiprecision/cpp_int.hpp>
#include <array>
#include <iostream>
#include <vector>
using bint = boost::multiprecision::cpp_int;



int main()
{
    std::array<bint, 53> powers{};
    powers.at(0) = 1;
    for (int i = 1; i <= 52; i++) {
        powers.at(i) = 2 * powers.at(i - 1);
    }
    int N;
    bint X;
    std::cin >> N >> X;

    bint ans = 0;
    for (int i = N; i >= 0; i--) {
        if (i != 0) {
            bint div = X / (powers.at(i + 2) - 3);
            bint mod = X % (powers.at(i + 2) - 3);
            ans += div * (powers.at(i + 1) - 1);
            X = mod;
            if (X >= powers.at(i + 2) - 3) {
                ans++;
                X -= 3; // remove BPB
            } else if (X >= powers.at(i + 1) - 1) {
                X -= 2; // remove PB
                ans++;
            } else if (X >= 1) {
                X -= 1;
            }
        } else {
            if (X == 1) {
                ans++;
            } else if (X == 2) {
                ans += 2;
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
import collections as col
import math

def prime(n):
    ans = []
    num = n
    for i in range(2,int(n**0.5)+1):
        if i%2==0 and i!=2: continue
        while num%i == 0: num //= i ; ans.append(i)
    if num != 1: ans.append(num)
    return ans

def gcd(a,b): return gcd(b,a%b) if a%b else b

a,b = map(int,input().split())
primes = prime(gcd(a,b)) #math.gcdは使用禁止？
cnt = col.Counter(primes)
ans = len(cnt) + 1
print(ans)
        


Measured memory_bytes: 3316
def fib(memo,n):
    if n in memo:
        return memo[n]
    else:
        if n == 0:
            return 1
        elif n == 1:
            return 1
        else:
            memo[n] = fib(memo,n-1)+fib(memo,n-2)
            return memo[n]

memo = {}
n = int(raw_input())
print fib(memo,n)

Measured memory_bytes: 6408
#include "bits/stdc++.h"
using namespace std;

//素数判定
bool prime(int n) {
	if (1 == n) {
		return false;
	}
	for (int i = 2; i*i <= n; i++) {
		if (0 == n % i) {
			return false;
		}
	}
	return true;
}

int count(int  n,int m) {
	int ret = 0;
	for (int l = 1;l<=m;++l) {
		int tmp = l;
		while (0 == tmp%n) {
			++ret;
			tmp /= n;
		}
	}
	return ret;
}

int main() {
	int N;
	cin >> N;
	vector<int>vec;
	for (int n = 1;n<=N;++n) {
		if (prime(n)) {
			vec.push_back(count(n,N));
		}
	}
	sort(vec.begin(),vec.end());
	int ans = 0;
	ans += vec.end()-lower_bound(vec.begin(), vec.end(), 74); 
	ans += (vec.end() - lower_bound(vec.begin(), vec.end(), 24))*(vec.end() - lower_bound(vec.begin(), vec.end(), 2)-1); 
	ans += (vec.end() - lower_bound(vec.begin(), vec.end(), 14))*(vec.end() - lower_bound(vec.begin(), vec.end(), 4) - 1); 
	ans += (vec.end() - lower_bound(vec.begin(), vec.end(), 4))*(vec.end() - lower_bound(vec.begin(), vec.end(), 4) - 1)*(vec.end() - lower_bound(vec.begin(), vec.end(), 2) - 2)/2;
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N];
    int B[] = new int[N];
    
    for(int i=0; i<N; i++) {
      A[i] = sc.nextInt();
      B[i] = A[i];
    }
    Arrays.sort(B);
    for(int j=0; j<N; j++) {
      if(A[j] == B[N-1]) {
        System.out.println(B[N-2]);
      } else {
        System.out.println(B[N-1]);
      }
    }
  }
}

Measured memory_bytes: 90852
#include<stdio.h>
int main(){
	int N,M,b=0;
  	scanf("%d %d",&N,&M);
  	int a[N],sum=0,count=0;
  	float add=0;
 
  	for(int i=0; i<N; i++){
    	scanf("%d",&a[i]);
  		sum += a[i];
    }
	add = (float)sum/(4*M);
  	for(int i=0; i<N; i++){
		if(a[i] >= add ){
          count++;
        }
    }
  	
  	if(count >= M){
	    printf("Yes");
    }else{
  		printf("No");
    }
	return 0;
}


Measured memory_bytes: 128
//package beginner163.a;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(long testNumber, InputReader in, PrintWriter out) {
            int radius = in.nextInt();
            out.println(2 * radius * Math.PI);
//            out.println("cica");
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

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

int main(){ 
  int n, m;
  cin >> n >> m; 
  if (n == 1 && m == 0) {
    cout << 0 << endl;
    return 0;
  }
  vector<char> d(n, 'a');
  for (int i = 0; i < m; i++) {
    int s;
    char c;
    cin >> s >> c;
    s--;
    if (d[s] != 'a' && d[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    d[s] = c;
  }
  string res = "";
  for (int i = 0; i < n; i++) {
    char c = d[i];
    if (c == 'a') {
      if (i == 0) {
        res += '1';
      } else res += '0';
    } else res += c;
  }
  if (n > 1 && res[0] == '0') cout << -1 << endl;
  else cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

int main(){
    string s ;
    cin >> s ;
    deque<char> w ;
    for (size_t i = 0; i < s.size(); i++)
    {
        w.push_back(s.at(i)) ;
    }
    int q ;
    cin >> q ;
    bool reverse = false ;
    int t , f ;
    char c;
    for (size_t i = 0; i < q; i++)
    {
        cin >> t ;
        if (t == 1)
        {
            if (reverse == 1)
            {
                reverse = 0 ;
            }else
            {
                reverse = 1 ;
            }
            
        }else if (t == 2)
        {
            cin >> f >> c ;
            if (f == 1)
            {
                if (reverse == 0)
                {
                    w.push_front(c) ;
                }else
                {
                    w.push_back(c) ;
                }
            }else if (f == 2)
            {
                if (reverse == 0)
                {
                    w.push_back(c) ;
                }else
                {
                    w.push_front(c) ;
                }
                
                
            }
            
            
        }
        
        
        
    }
    string ans = "" ;
    while (w.size() != 0)
    {
        if (reverse == 0)
        {
            c = w.front() ;
            ans.push_back(c) ;
            w.pop_front() ;
        }else
        {
            c = w.back() ;
            ans.push_back(c) ;
            w.pop_back() ;
        }
        
           
    }
    
    cout << ans << endl ;
}

Measured memory_bytes: 1412
/**
*    created: 01.07.2020 16:36:59
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int mod = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n,m;
    map<string,int> bmp, rmp;
    cin >> n;
    rep(i,n) {
        string s;
        cin >> s;
        bmp[s]++;
    }
    cin >> m;
    rep(i,m) {
        string s;
        cin >> s;
        rmp[s]++;
    }
    int ans = 0;
    for (auto p : bmp) chmax(ans,p.second-rmp[p.first]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int ans = 0;
    
    int b = a%500;
    
    ans = 1000*(a/500) + 5*(b/5);
    
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
//2019/12/1.
//ALL search. O(1000*n).
//Refering to exp.
#include<iostream>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
	int n;
	string s;
	cin>>n>>s;
	
	int cnt=0;
	REP(i,1000){//point.
		int c[]={i/100,(i%100)/10,i%10};
		int p=0;
		REP(i,n){
			if(s[i]-'0'==c[p]) p++;
			if(p==3) break;
		}
		if(p==3) cnt++;
	}
	
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
s = input()
n = len(s)

ans = 0

for i in range(1 << (n - 1)):
    t = ''
    for j in range(n - 1):
        t += s[j]

        if (1 & i >> j) == 1:
            t += '+'

    t += s[-1]
    ans += eval(t)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;

    vector<ll> sx(n, 0);
    vector<ll> sy(n, 0);
    vector<ll> cx(m, 0);
    vector<ll> cy(m, 0);

    REP(i, n) cin >> sx[i] >> sy[i];
    REP(j, m) cin >> cx[j] >> cy[j];

    ll best = INF;
    ll best_dist =  INF;
    REP(i, n){
        best = INF;
        best_dist =  INF;
        REP(j, m){
            if (abs(cx[j] - sx[i]) + abs(cy[j]-sy[i]) < best_dist) {
                best = j+1;
                best_dist = abs(cx[j] - sx[i]) + abs(cy[j]-sy[i]);
            }
        }
        cout << best << endl;
    }
}

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

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define fill(a,v)  memset(a, v, sizeof (a))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

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

const int N=501000;
const int MOD = 1e9 + 7 ;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int main()
{
	faster;

    int n, res = 1;
    string str;

    cin >> n;
    cin >> str;
    for(int i = 0; i < n-1; ++i){	
    	if(str[i]!=str[i+1])	res++;
    }
    cout << res;

	return 0;
}

// READ
// THINK
// CODE 
// DEBUG 
// AC	

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

int main(void){
  int n, m, p;

  cin >> n;

  long int t[n], x, sum = 0;
  for (int i = 0; i < n; i++){
    cin >> t[i];
    sum += t[i];
  }

  cin >> m;
  for (int i = 0; i < m; i++){
    cin >> p >> x;
    cout << sum - (t[p - 1] - x) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;
int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)%mod*(x)%mod);
        x = (x*x)%mod;
        n = n/2;
    }
    return res%mod;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<pair<string,ll>> ok;
    ok.pb({"AC",0});
    ok.pb({"WA",0});
    ok.pb({"TLE",0});
    ok.pb({"RE",0});
    for(ll i=0;i<n;i++)
    {
    string a;
    cin>>a;
    if(a=="AC")
        ok[0].sec++;
    else if(a=="WA")
        ok[1].sec++;
    else if(a=="TLE")
        ok[2].sec++;
    else
        ok[3].sec++;

    }
    for(ll i=0;i<4;i++)
    {
        cout<<ok[i].fs<<" x "<<ok[i].sec; br;
    }
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,c,p,i;
  cin>>n;
  vector<int> a(n);
  for (i=0;i<n;i++) {
    cin>>a.at(i);
  }
  p=1;
  c=1;
  while (a.at(p-1)!=2 && c<n) {
    p=a.at(p-1);
    c++;
  }
  if (c<n) cout<<c<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////

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

	ll a, b;

    cin >> a >> b;

    ll ans1{}, ans2{};

    rep(i, b) {
        ans1 += pow(10, i) * a;
    }
    rep(i, a) {
        ans2 += pow(10, i) * b;
    }

    if (ans1 >= ans2) {
        cout << ans1 << endl;
    }
    else {
        cout << ans2 << endl;
    }
}



Measured memory_bytes: 512
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ Classes ------ //
class Point {
public:
	long double px, py;
	Point() : px(0), py(0) {};
	Point(long double px_, long double py_) : px(px_), py(py_) {};
	friend bool operator==(const Point& p1, const Point& p2) { return p1.px == p2.px && p1.py == p2.py; }
	friend bool operator!=(const Point& p1, const Point& p2) { return p1.px != p2.px || p1.py != p2.py; }
	friend bool operator<(const Point& p1, const Point& p2) { return p1.px < p2.px ? true : (p1.px == p2.px && p1.py < p2.py); }
	friend bool operator>(const Point& p1, const Point& p2) { return p1.px > p2.px ? true : (p1.px == p2.px && p1.py > p2.py); }
	friend bool operator<=(const Point& p1, const Point& p2) { return !(p1 > p2); }
	friend bool operator>=(const Point& p1, const Point& p2) { return !(p1 < p2); }
	friend Point operator+(const Point& p1, const Point& p2) { return Point(p1.px + p2.px, p1.py + p2.py); }
	friend Point operator-(const Point& p1, const Point& p2) { return Point(p1.px - p2.px, p1.py - p2.py); }
	friend Point operator*(const Point& p1, long double d) { return Point(p1.px * d, p1.py + d); }
	friend Point operator*(long double d, const Point& p1) { return p1 * d; }
	friend Point operator/(const Point& p1, long double d) { return Point(p1.px / d, p1.py / d); }
	Point& operator+=(const Point& p1) { px += p1.px; py += p1.py; return *this; }
	Point& operator-=(const Point& p1) { px -= p1.px; py -= p1.py; return *this; }
	Point& operator*=(long double d) { px *= d; py *= d; return *this; }
	Point& operator/=(long double d) { px /= d; py /= d; return *this; }
};
// ------ Functions ------ //
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0, b = p2 - p0;
	if (crs(a, b) > 1e-10) return 1;
	if (crs(a, b) < -1e-10) return -1;
	if (dot(a, b) < -1e-10) return 2;
	if (norm(a) < norm(b)) return -2;
	return 0;
}
bool is_convex(vector<Point> v) {
	if (v.size() < 3) return false;
	int s = -3;
	for (int i = 0; i < v.size(); i++) {
		int r = ccw(v[i], v[(i + v.size() - 1) % v.size()], v[(i + 1) % v.size()]);
		if (abs(r) == 1 && s == -3) s = r;
		if (s == 1 && r == -1) return false;
		if (s == -1 && r == 1) return false;
	}
	return true;
}
// ------ Main ------ //
int n; vector<Point> v;
int main() {
	cin >> n; v.resize(n);
	for (int i = 0; i < n; i++) cin >> v[i].px >> v[i].py;
	cout << (is_convex(v) ? 1 : 0) << endl;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n';

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	string s;
	cin >> s;
	string m[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
	for (int i = 0; i < 7; i++)
		if (s == m[i]) cout << (7 - i) << endl;
	return 0;
}

Measured memory_bytes: 3608
let words str = Str.split (Str.regexp " ") str |> List.map int_of_string

let bs elem (a: int array) =
  let rec loop (i_min,i_max) =
    match i_min > i_max with
      true -> false
    | false ->
      let mid = (i_min+i_max)/2 in
      match a.(mid) = elem with
        true -> true
      | false ->
        loop (match a.(mid) < elem with true -> mid+1,i_max | false -> i_min,mid-1)
  in loop (0,(Array.length a) -1)

let () =
  let _ = read_int () in
  let s = read_line () |> words |> Array.of_list in
  let _ = read_int () in
  let t = read_line () |> words in
  List.fold_left (fun acc x -> match bs x s with true -> acc+1 | false -> acc)
    0 t
  |> Printf.printf "%d\n"

Measured memory_bytes: 16236
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

tuple<bool, double, double, double, double> calc_circles_intersections(double x0, double y0, double r0, double x1, double y1, double r1){
    // return: ok, xa, ya, xb, yb
    double dx = x1 - x0;
    double dy = y1 - y0;
    double d2 = dx*dx + dy*dy;
    assert(d2!=0.0);
    double a = (d2 + r0*r0 - r1*r1) / 2;
    double tmp = d2*r1*r1-a*a;
    if(tmp < 0){
        return make_tuple(false, 0.0, 0.0, 0.0, 0.0);
    }
    tmp = sqrt(tmp);
    double xa = (a*dx+dy*tmp)/d2 + x0;
    double xb = (a*dx-dy*tmp)/d2 + x0;
    double ya = (a*dy-dx*tmp)/d2 + y0;
    double yb = (a*dy+dx*tmp)/d2 + y0;
    return make_tuple(true, xa, ya, xb, yb);
}

bool check(int N, vector<pair<double, double>> &xy, double r){
    vector<pair<double, double>> ins;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            double x0 = xy[i].first, y0 = xy[i].second;
            double x1 = xy[j].first, y1 = xy[j].second;
            bool ok;
            double xa, ya, xb, yb;
            tie(ok, xa, ya, xb, yb) = calc_circles_intersections(x0, y0, r, x1, y1, r);
            if(!ok) return false;
            ins.push_back(make_pair(xa, ya));
            ins.push_back(make_pair(xb, yb));
        }
    }
    for(auto z : ins){
        double x = z.first, y = z.second;
        bool ok = true;
        for(int i=0; i<N; i++){
            double dx = x-xy[i].first;
            double dy = y-xy[i].second;
            double d2 = dx*dx+dy*dy;
            if(d2 > r*r + 1e-6){
                ok = false;
                break;
            }
        }
        if(ok) return true;
    }
    return false;
}

int main(){
    int N;
    cin >> N;
    vector<pair<double, double>> xy(N);
    REP(i, N) cin >> xy[i].first >> xy[i].second;
    double lb = 0.1;
    double ub = 2000.0;
    for(int i=0; i<100; i++){
        double r = (lb + ub) / 2;
        if(check(N, xy, r)) ub = r;
        else lb = r;
    }
    cout << fixed << setprecision(16) << ub << endl;
    return 0;
}

Measured memory_bytes: 408
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <cstdlib>
#include <vector>
using namespace std;

char b;



int main() {

	cin >> b;
	if (b == 'A') cout << 'T' << endl;
	if (b == 'C') cout << 'G' << endl;
	if (b == 'T') cout << 'A' << endl;
	if (b == 'G') cout << 'C' << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#define ll long long
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, b, a) for(int i = (b); i >= (a); i--)
using namespace std;
const int N = 2e5 + 9, inf = 0x3f3f3f3f;
int n, l, r, cnt, sum, minn1 = inf, minn2 = inf, maxx1, maxx2, vis[N];
struct node{
    int num, pl;
}s[N << 1];
bool cmp(node x, node y){
    return x.num == y.num ? x.pl < y.pl : x.num < y.num;
}
int main(){
    scanf("%d", &n);
    rep(i, 1, n) {
        int x, y; scanf("%d%d", &x, &y);
        if(x > y) swap(x, y);
        minn1 = min(minn1, x), minn2 = min(minn2, y), maxx1 = max(maxx1, x), maxx2 = max(maxx2, y);
        s[++cnt].pl = i, s[cnt].num = x, s[++cnt].pl = i, s[cnt].num = y;
    }
    sort(s + 1, s + 2 * n + 1, cmp);
    l = 1;
    rep(i, 1, 2 * n) {
        if(!vis[s[i].pl]) sum++;
        vis[s[i].pl]++;
        if(sum == n) { r = i; break; }
    }
    int ans = s[r].num - s[l].num;
    while(r < n * 2){
        if(vis[s[l].pl] == 1) sum--;
        vis[s[l].pl]--, l++;
        if(sum != n) rep(i, r + 1, 2 * n) {
            vis[s[i].pl]++;
            if(vis[s[i].pl] == 1) {
                sum++, r = i;
                break;
            }
        }
        if(sum != n) break;
        ans = min(ans, s[r].num - s[l].num);
        //cout << l << " " << ans << endl;
    }
    //cout << ans << endl;
    printf("%lld", min(1ll * ans * (maxx2 - minn1), 1ll * (maxx1 - minn1) * (maxx2 - minn2)));
    return 0;
}

Measured memory_bytes: 4096
#include<iostream>//????????????????????§??????????????????
using namespace std;
int main(){
    int a[5005];
    int n;
    int i,j,k;
    int s,b,c;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    s=0,b=0,c=0;
    for(i=3;i>0;i--){
        for(j=0;j<n;j++){
            if(a[j]==i){
                if(c==0)b=j;
                c++;
            }else if(c!=0){
                if(b==0 || c%2==0)s+=c;
                else{
                    if(a[j]>a[b-1])a[j]=(a[j]>0?a[j]-1:0);
                    else a[b-1]=(a[b-1]>0?a[b-1]-1:0);
                    s+=c+1;
                }
                for(k=b;k<b+c;k++){
                    a[k]--;
                }
                b=0,c=0;
            }
        }
        s+=c;
        for(j=b;j<b+c;j++){
            a[j]--;
        }
        b=0,c=0;
    }
    cout<<s<<endl;
    return 0;
}
    

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  string s;
  int a[26];
  rep(i,26) a[i]=0;
  cin>>s;
  rep(i,s.size() ){
    a[s[i]-97]=1;
  }
  rep(i,26){
    if(a[i]==0){cout<<(char)(i+97)<<endl;return 0;}
  }
  cout<<"None"<<endl;

  return 0;
}



Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

// ----------------------------------------------------------------

func main() {
	var s string
	fmt.Scan(&s)

	y, _ := strconv.Atoi(string(s[:2]))
	m, _ := strconv.Atoi(string(s[2:]))

	if (y >= 1 && y <= 12) && (m >= 1 && m <= 12) {
		fmt.Println("AMBIGUOUS")
	}
	if (y >= 1 && y <= 12) && (m < 1 || m > 12) {
		fmt.Println("MMYY")
	}
	if (y < 1 || y > 12) && (m >= 1 && m <= 12) {
		fmt.Println("YYMM")
	}
	if (y < 1 || y > 12) && (m < 1 || m > 12) {
		fmt.Println("NA")
	}

}

// ----------------------------------------------------------------

var dx = []int{0, 1, 0, -1, 0}
var dy = []int{1, 0, -1, 0, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

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

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

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

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}

func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}

func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;

struct UnionFind {
    vector<int> par, rank, sz;
    
    UnionFind(int n) : par(n), rank(n, 0), sz(n, 1) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    void init(int n) {
        par.resize(n); rank.resize(n); sz.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, sz[i] = 1;
    }

    int root(int n)
    {
      if(par[n] == n) return n;
      else {
        return par[n] = root(par[n]);
      }
    }

    bool is_same(int a, int b)
    {
      return root(a) == root (b); 
    }

    int size(int n)
    {
      return sz[root(n)];
    }

    bool merge(int a, int b)
    {
      int rt_a = root(a);
      int rt_b = root(b);
      if(rt_a == rt_b) return false;
      if (rank[rt_a] < rank[rt_b]) swap(rt_a, rt_b);
      if (rank[rt_a] == rank[rt_b]) ++rank[rt_a];
      par[rt_b] = rt_a;
      sz[rt_a] += sz[rt_b];
      return true;
    }

};

int 
main() {
  int N, K, L;
  cin >> N >> K >> L;
  UnionFind road(N + 1);

  int p, q;
  rep(i, 1, K + 1){
      cin >> p >> q;
      road.merge(p, q);
  }

  UnionFind rail(N + 1);
  int r, s;
  rep(i, 1, L + 1){
    cin >> r >> s;
    rail.merge(r,s);
  }

  map<pair<int, int>, int> group;
  rep(i, 1, N + 1){
    group[make_pair(road.root(i), rail.root(i))]++;
  }

  rep(i, 1, N + 1){
    cout << group[make_pair(road.root(i), rail.root(i))] << " ";
  }
  cout << endl;
}




Measured memory_bytes: 16640
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}

import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Control.Monad.Primitive
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Bits
import Data.Int
import Debug.Trace


main = do
  [n,q] <- map read . words <$> getLine :: IO [Int]
  queries <- replicateM q $ map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine :: IO [[Int]]

  seg <- newSegmentTree n (0::Int) (+) :: IO (IOUSegmentTree Int)

  forM_ queries $ \[com,x,y] -> do
    when (com == 0) $ do
      stToIO $ modifySegmentTree seg (x-1) (+y)
    when (com == 1) $ do
      print =<< (stToIO $ findSegmentTree seg (x-1) y)

type MSegmentTree v s a = (v s a, a, (a -> a -> a)) -- (セグメント木, 単位元, 二項演算)

type STSegmentTree s a = MSegmentTree VM.MVector s a
type IOSegmentTree a = STSegmentTree RealWorld a
type STUSegmentTree s a = MSegmentTree VUM.MVector s a
type IOUSegmentTree a = STUSegmentTree RealWorld a

newSegmentTree :: (PrimMonad m, VGM.MVector v a) => Int -> a -> (a -> a -> a) -> m (MSegmentTree v (PrimState m) a)
newSegmentTree n e f = return . (,e,f) =<< (VGM.replicate m e)
  where m = 2 * (2 ^ (ceiling $ logBase 2 (fromIntegral n))) - 1


modifySegmentTree :: (PrimMonad m, VGM.MVector v a) => MSegmentTree v (PrimState m) a -> Int -> (a -> a) -> m ()
modifySegmentTree (tree,e,f) i g = do
  return ()
  VGM.write tree j =<< return . g =<< VGM.read tree j
  aux ((j-1)`div`2)
  where
    n = (VGM.length tree + 1) `div` 2
    j = i + n - 1
    aux i = do
      when (i >= 0) $ do
        VGM.read tree (i*2+1) >>= \a -> VGM.read tree (i*2+2) >>= \b -> VGM.write tree i (f a b)
        aux ((i-1)`div`2)
        
findSegmentTree :: (PrimMonad m, VGM.MVector v a) => MSegmentTree v (PrimState m) a -> Int -> Int -> m a
findSegmentTree (tree,e,f) x y = do
  aux 0 0 n
  where
    n = (VGM.length tree) `div` 2 + 1
    aux i l r
      | r <= x || y <= l = return e
      | x <= l && r <= y = VGM.read tree i
      | otherwise = aux (i*2+1) l ((l+r)`div`2) >>= \a -> aux (i*2+2) ((l+r)`div`2) r >>= \b -> return (f a b)



Measured memory_bytes: 38792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
//#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll M[5] = {1000000007, 1000000009, 1000000021, 1000000033, 1000000087};
int n,m;
vector<P>edge[100005];
vector<P>redge[100005];
ll v[100005];
ll modpow(ll a,ll n,ll mod){
    ll ret = 1;
    while(n){
        if(n&1) ret=ret*a%mod;
        a = a*a%mod;
        n /= 2;
    }
    return ret;
}
void dfs(int x,ll val,ll mod){
    v[x] = val;
    for(int i=0;i<edge[x].size();i++){
        if(v[edge[x][i].fi]) continue;
        ll nxt = val*edge[x][i].sc%mod;
        dfs(edge[x][i].fi,nxt,mod);
    }
    for(int i=0;i<redge[x].size();i++){
        if(v[redge[x][i].fi]) continue;
        ll nxt = val*modpow(redge[x][i].sc,mod-2,mod)%mod;
        dfs(redge[x][i].fi,nxt,mod);
    }
}
bool check(int r){
    ll mod = M[r];
    memset(v,0,sizeof(v));
    repn(i,n){
        if(v[i] > 0) continue;
        dfs(i,1,mod);
    }
    repn(i,n) rep(j,edge[i].size()) if( v[edge[i][j].fi] == (v[i]*edge[i][j].sc%mod) ); else return 0;
    return 1;
}
int main(){
    cin >> n >> m;
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        edge[a].pb(mp(b,c));
        redge[b].pb(mp(a,c));
    }
    bool flag = 1;
    rep(i,5){
        flag &= check(i);
    }
    puts(flag?"Yes":"No");
}


Measured memory_bytes: 21040
/*
    Author: aksayushx
*/

#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mod 998244353
using namespace std;
typedef long long ll;
typedef long double ld;

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
}
ll power(ll x, ll y)  
{  
    ll res = 1; 
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x)%mod;  
        y = y>>1; 
        x = (x*x)%mod;  
    }  
    return res;  
} 

ll n;
vector<ll> a,b,c;

void aksayushx()
{
    cin>>n;
    a.resize(n);
    b.resize(n);
    c.resize(n);
    
    for(ll i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
    ll dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(ll i=1;i<n;i++)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});

    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    while(test--)
        aksayushx();
    return 0;
}


Measured memory_bytes: 7968
N = int(input())
S = input()

n_R, n_G, n_B, n_total = 0, 0, 0, 0
for i in range(N):
  if S[i] == 'R':
    n_R+=1
  elif S[i] == 'G':
    n_G+=1
  else:
    n_B+=1
n_total += (n_R*n_G*n_B)
for j in range(1,N-1):
  i = j-1
  k = j+1
  while 1:
    if 0 <= i and k < N:
      if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
        #print(i,j,k, S[i], S[j], S[k])
        n_total-=1
    else:
      break
    i -= 1
    k += 1
print(n_total)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[111];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	ll cost=ll(1e18);
	for(int i=-100;i<=100;i++)
	{
		ll c=0;
		for(int j=0;j<n;j++)
		{
			c+=(i-a[j])*(i-a[j]);
		}
		cost=min(cost,c);
	}
	cout<<cost<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
vector<int> visited,dist,ans;
const int INF = 1001001001;
int main()
{
    int n,x,y;
    cin >> n >> x >> y;
    queue<int> q;
    x--;y--;
    visited.resize(n);
    ans.resize(n);
    dist.resize(n,INF);
    rep(sv,n){
        q.push(sv);
        dist[sv] = 0;
        while(!q.empty()){
            int now = q.front();q.pop();
            visited[now] = 1;
            if(now+1 <n && !visited[now+1]){
                q.push(now+1);
                dist[now+1] = min(dist[now+1],dist[now]+1);
            }
            if(now-1>=0 && !visited[now-1]){
                q.push(now-1);
                dist[now-1] = min(dist[now-1],dist[now] +1);
            }
            if(now == x && !visited[y]){
                q.push(y);
                dist[y] = min(dist[y],dist[now]+1);
            }
            if(now == y && !visited[x]){
                q.push(x);
                dist[x] = min(dist[x],dist[now]+1);
            }

        }
        rep(i,n)ans[dist[i]]++;
        visited = vector<int>(n,0);
        dist = vector<int>(n,INF);

    }
    rep(i,n-1){
        ans[i+1]/=2;
        cout << ans[i+1] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int D, N;
    cin >> D >> N;
    if( N == 100 ) N = 101;
    cout << ( D == 1 ? 100 * N : D == 2 ? 10000 * N : N ) << endl;
    return 0;
}

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

int main(void) {
  int i, n;
  char str[21];

  scanf("%s", str);
  n = strlen(str);

  for (i = n - 1; i >= 0; i--) {
    putchar(str[i]);
  }

  putchar('\n');

  return EXIT_SUCCESS;
}

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

ll bit[20];
void make_bit(ll n){
    for(int i=0; i<20; i++){
        bit[i]=n%2;
        n /=2;
    }
}

bool comp(P &a, P &b){
    if(a.first !=b.first) return a.first < b.first;
    return a.second > b.second;
}
vector<P> Fir,Sec;

int main(){
    ll N; ll W;
    cin >> N >> W;
    ll v[40], w[40];
    for(ll i=0; i<N; i++){
        cin >> v[i] >> w[i];
    }
    for(ll i=0; i< pow(2,N/2); i++){
        make_bit(i);
        ll sum_v=0, sum_w=0;
        for(int j=0; j<20; j++){
            sum_v +=bit[j]*v[j];
            sum_w +=bit[j]*w[j];
        }
        Fir.push_back(P(sum_w, sum_v));
    }
    for(ll i=0; i< pow(2,(N+1)/2); i++){
        make_bit(i);
        ll sum_v=0, sum_w=0;
        for(int j=0; j<20; j++){
            sum_v +=bit[j]*v[j+N/2];
            sum_w +=bit[j]*w[j+N/2];
        }
        Sec.push_back(P(sum_w, sum_v));
    }
    
    sort(Sec.begin(),Sec.end()); //重み,価値の順
/*
    for(auto a:Fir){
        cout << a.first << " " << a.second << endl;
    }
    cout << 'a' << endl;

    for(auto a:Sec){
        cout << a.first << " " << a.second << endl;
    }
*/

    ll Max=0;
    for(P &a : Sec){
        Max=max(Max,a.second);
        a.second = Max;
    }
    reverse(Sec.begin(),Sec.end());
    sort(Fir.begin(),Fir.end()); //大きい順のFir



    ll Max_v=0;

    ll t=0;
    for(P b :Fir){
        ll v=b.second;
        ll w=b.first;
        while(t<Sec.size() && Sec.at(t).first + w > W) t++;
        if(t>=Sec.size()) break;
        Max_v = max(Max_v, Sec.at(t).second+v);
    }
/*    for(P b :Fir){
        auto itr = upper_bound(Sec.begin(), Sec.end(), W-b.first);
        ll c =(itr-1).second + b.second;
        Max_v = max(Max_v , c);
    }
*/
    cout << Max_v << endl;
}


Measured memory_bytes: 44004
//ΔARC086C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
int s[222222];
int main()
{
	int n,k,i,x;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i=i+1)
		scanf("%d",&x),s[x]++;
	sort(s+1,s+200001);
	reverse(s+1,s+200001);
	x=0;
	for(i=1;i<=k;i=i+1)
		x+=s[i];
	cout<<n-x<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int n;
int A[20];
int flg[200000];

int check( int x , int sum ){
    if ( x == n ){
        flg[sum] = 1;
        return;
    }
    check(x+1,sum);
    check(x+1,sum+A[x]);
}


int main(){
    
    scanf("%d\n",&n);
    for ( int ix = 0 ; ix < n ; ix++){
        if ( ix == n-1 ) scanf("%d\n",&A[ix]);
        else scanf("%d",&A[ix]);
    }
    check(0,0);
    int q, M;
    scanf("%d\n",&q);
    for ( int ix = 0 ; ix < q ; ix++){
        if ( ix == q-1 ) scanf("%d\n",&M);
        else scanf("%d ",&M);
        if ( flg[M] == 1 ) printf("yes\n");
        else printf("no\n");
    }
    
    
    return EXIT_SUCCESS;
}


Measured memory_bytes: 2108
#include <stdio.h>
#include <string.h>
constexpr int MAX_SIZE = 1e5+1;
char str[MAX_SIZE];
int A[] = {0, 0};

int main(void){
    scanf("%s", str);
    const int n = strlen(str);
    for(int i = 0; i < n; ++i) A[str[i] - '0']++;
    printf("%d\n", 2 * ((A[0] > A[1]) ? A[1] : A[0]));
    return 0;
}

Measured memory_bytes: 888
area :: Int -> Int -> Int
area a b = a * b

rlength :: Int -> Int -> Int
rlength a b = 2 * (a + b)

rInt :: String -> Int
rInt str = read str :: Int

main :: IO ()
main = do
  input <- getLine
  let doubleInt = map rInt $ words input
  let a = head doubleInt
  let b = last doubleInt
  putStrLn $ show (area a b) ++ " " ++ show (rlength a b)

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) (int)s.size()
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
const int MOD=1e9+7;
void solve()
{
fastio
int n,m;
cin>>n>>m;
int danger[m];
for(auto &x:danger)
cin>>x;
int dp[n+1];
for(auto &x:dp)
x=0;
dp[0]=0;
if(count(danger,danger+m,1))
dp[1]=0;
else
dp[1]=1;
if(count(danger,danger+m,2))
dp[2]=dp[1];
else
dp[2]=1+dp[1];
for(int i=3;i<=n;i++)
{
	if(!binary_search(danger,danger+m,i-1))
	dp[i]=(dp[i]+dp[i-1])%MOD;
	if(!binary_search(danger,danger+m,i-2))
	dp[i]=(dp[i]+dp[i-2])%MOD;
}
cout<<dp[n];
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 4300