akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N;
bool dp[1<<24];

void solve(){
    vector<int> x(N),y(N),r(N),c(N);
    rep(i,N){
        cin>>x[i]>>y[i]>>r[i]>>c[i];
        c[i]--;
    }

    bool on[24][24]={};
    rep(i,N){
        for(int j=0;j<i;j++){
            // i?????????j?????????????
            double d = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
            if(d >= r[i]+r[j]) on[i][j]=false;
            else on[i][j]=true;
        }
    }



    rep(i,1<<24) dp[i]=false;
    dp[0]=true;
    rep(mask,(1<<N)){
        if(!dp[mask]) continue;
        //cout << "mask : " << static_cast<bitset<4>>(mask) << endl;

        for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
            if(c[i]!=c[j]) continue;
            if(((mask>>i)&1) or ((mask>>j)&1)) continue;
            bool oki = [=](){
                for(int k=0;k<i;k++){
                    if(on[i][k] && ((mask>>k)&1)==0) return false;
                }
                return true;
            }();

            bool okj = [=](){
                for(int k=0;k<j;k++){
                    if(on[j][k] && ((mask>>k)&1)==0) return false;
                }
                return true;
            }();
            if(!oki or !okj) continue;
            int nxt = mask | (1<<i) | (1<<j);
            dp[nxt] = true;
            //cout << "\tnext : " << static_cast<bitset<4>>(nxt) << endl;
        }
    }

    //rep(i,(1<<N)){
    //    cout << static_cast<bitset<8>>(i) << " : " << dp[i] << endl;
    //}

    int ans = 0;
    rep(i,(1<<N)){
        if(dp[i])
            ans = max(ans,__builtin_popcount(i));
    }
    cout << ans << endl;
}

int main(){
    while(cin>>N){
        if(N==0) break;
        solve();
    }
}

Measured memory_bytes: 19480
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define read_input         freopen("in.txt","r", stdin)
#define print_output       freopen("out.txt","w", stdout)
typedef long long ll;
typedef long double ld;
using namespace std;
 
int main() {
    int a[200005];
    ll ans = 0;
    int n, t;
 
    cin >> n >> t;
    for(int i = 1; i <= n; i++) cin >> a[i];
    a[n+1] = 2e9+7;
 
    ll lo = a[1], hi = lo+t;
    for(int i = 2; i <= n+1; i++) {
        if(a[i] <= hi) hi = a[i]+t;
        else ans += (hi-lo), lo = a[i], hi = a[i]+t;
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    unsigned long long price=0.0,a,b,sum=0,t,y,i,n,m;cin>>n>>m;
    vector<pair<unsigned long long,unsigned long long>> ve;
    for(i=0;i<n;i++){
        cin>>a>>b;
        ve.push_back(make_pair(a,b));
    }
    sort(ve.begin(),ve.end());
    for(i=0;i<n;i++){
        for(y=0;y<ve[i].second;y++){
            sum++;
            price+=ve[i].first;
            if(sum>=m){
                cout<<price<<endl;
                return 0;
            }
        }
    }
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e3 + 1;
const int maxW = 1e5 + 1;

int n, W;
int w[maxN];
ll v[maxN];

ll dp[maxN][maxW];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> W;
    for1(i, n)
    {
        cin >> w[i] >> v[i];
    }
    for1(i, n)
    {
        for1(j, W)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i])
            {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[n][W];
    return 0;
}


Measured memory_bytes: 79360
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	
	cout << (int)(c/a) * b;
	
	
	
	
	
	
	return 0;
}



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

A=[]
B=[]
for k in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
    
if N%2==1:
    mA=A[(N-1)//2]
    mB=B[(N-1)//2]
    print(mB-mA+1)
else:
    nA=A[N//2]+A[N//2-1]
    nB=B[N//2]+B[N//2-1]
    print(nB-nA+1)


Measured memory_bytes: 99008
/****************************************

	LostMartian

****************************************/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define LOCAL #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
	clock_t z = clock();
	FAST
	//LOCAL
	char x;
	cin>>x;
	if(x>90) {
		cout<<"a\n";
	}
	else {
		cout<<"A\n";
	}


	

	debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

ll n, k, r, s, p;
string t;

// グー : 0, チョキ : 1, パー : 2 とする 

ll f(ll i, ll j) {  // i回目にjを出したときの得点
    if(t[i] == 'r') {
        if(j == 2) {
            return p;
        }
        else {
            return 0;
        }
    }
    else if(t[i] == 's') {
        if(j == 0) {
            return r;
        }
        else {
            return 0;
        }
    }
    else if(t[i] == 'p') {
        if(j == 1) {
            return s;
        }
        else {
            return 0;
        }
    }
}

int main() {
    
    cin >> n >> k >> r >> s >> p >> t;

    vvl dp(n, vl(3));  // dp[i][j] : i回目にjを出したときのi回目までの合計点の最大値
    rep(i, k) {
        rep(j, 3) {
            dp[i][j] = f(i, j);
        }
    }

    rep(i, n) {
        rep(j, 3) {  // i回目にjを出したとする
            rep(x, 3) {  // i+k回目にxを出すとする
                if(i+k < n && j != x) {
                    chmax(dp[i+k][x], dp[i][j] + f(i+k, x));
                }
            }
        }
    }

    ll ans = 0;
    exrep(i, n-k, n-1) {
        ll x = 0;
        rep(j, 3) {
            chmax(x, dp[i][j]);
        }
        ans += x;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 8780
class Main{
    public static void main(String[] a){
        int[] b = {1,2,3,4,5,6,7,8,9};
        int sum=0;

        for(int i=0; i<b.length; i++){
           for(int n=0; n<b.length; n++){
             sum = b[i] * b[n];
             System.out.println(b[i]+"x"+b[n]+"="+sum);
           }
        }
    }
}

Measured memory_bytes: 16852
H, W, K = map(int, input().split())

M = [input() for i in range(H)]

# O(36)
def count(rows, columns):

  M2 = [[M[i][j] for j in range(W)] for i in range(H)]

  for i in range(H):
    if ((1 << i) & rows):
      for j in range(W):
        M2[i][j] = 'r'
  
  for i in range(W):
    if ((1 << i) & columns):
      for j in range(H):
        M2[j][i] = 'r'

  c = 0
  for i in range(H):
    for j in range(W):
      if M2[i][j] == '#':
        c += 1
  return c

res = 0
for i in range(1 << H):
  for j in range(1 << W):
    if (count(i, j) == K):
      res += 1

print(res)

Measured memory_bytes: 9104
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] NN = new int[N];
        int max = 0;
        int sum = 0;
        for (int i = 0; i < NN.length; i++) {
            NN[i] = sc.nextInt();
        }
        for (int i = 0; i < NN.length; i++) {
            if (NN[i] > max) {
                max = NN[i];
            }else{
            }
        }
        for (int i = 0; i < NN.length; i++) {
            sum += NN[i];
        }
        System.out.println(sum - max / 2);

    }

}

Measured memory_bytes: 23252
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var c = parseInt(input[2], 10);
	var d = parseInt(input[3], 10);
	//出力
   if (a>=b) {
     var e = b
   } else {
     var e = a
   }
     if (c>=d) {
     var f = d
   } else {
     var f = c
   }
	console.log(e + f);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(a,b);
    int aa = max(a,b);
    int bb = min(a,b);
    cout << aa + max(aa-1,bb) << nn;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n,m;
vector<P> ps;

bool sorter(const P& a,const P& b){
  return a.se < b.se;
}

int main(){
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    ps.push_back(P(a,b));
  }
  sort(all(ps),sorter);
  int res=0,crt=0;
  rep(i,m){
    if(ps[i].fi<crt)continue;
    crt=ps[i].se;
    res++;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 2420
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    n = II()
    hina = IS().split()
    t = len(set(hina))
    if t == 3: print('Three')
    else: print('Four')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = int(input())
S = list(map(int, input().split()))
s = sorted(S, reverse=True)

if n %2 ==0:
  l = n/2
  m = s[0]
  s = s[1:int(l)]
  p = sum(s)
  o = p*2 + m 
  print(o)
else:
  l = (n+1)/2
  m = s[0]
  q = s[int(l)-1]
  s = s[1:int(l-1)]
  p = sum(s)
  o = p*2 + m +q
  print(o)
  

Measured memory_bytes: 31444
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define debug(x) cerr << #x << ": " << x << "\n";
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=(int) 1e5;
static const int MOD=(int) 1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
int a[3],cost=INF;

void solve(){
    int sum=0;
    for(int i=0;i<3;i++){
        sum=0;
        for(int j=0;j<3;j++) sum += abs(a[i]-a[j]);
        cost = min(cost,sum);
    }
    cout<<cost<<"\n";
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    for(int i=0;i<3;i++) cin >> a[i];

    solve();
    
    return 0;
}


Measured memory_bytes: 256
import numpy as np
n, d = map(int, input().split())

x = np.zeros((n,d))

for i in range(n):
    x[i,:] = list(map(int, input().split()))

count = 0
for i in range(0,n-1):
    for j in range(i+1,n):
        d = np.linalg.norm(x[i,:]-x[j,:])
        if d == int(d):
            count += 1

print(count)

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

fn solve() -> u32{
    0
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut a: Vec<i64> = (0..n)
        .map(|_| {
            iter.next().unwrap().parse().unwrap()
        }).collect();
    a.sort();
    let mut result: i64 = 0;
    let mut i: usize = 0;
    while i < n {
        if i == n - 1 {
            result += a[i];
            break;
        }
        let tmp = a[i]+a[i+1];
        if tmp < 0 {
            result -= tmp;
        } else {
            result += tmp;
        }
        i += 2;
    }
    println!("{}", result);
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int A, B;
	cin >> A >> B;

	int res;
	if(A == B) res = A + B;
	else res = max(A, B) * 2 - 1;

	cout << res << '\n';

	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    long long a[n];
    std::vector<long long> v;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        v.push_back(a[i]);
    }
/*
    for (int i = 0; i < m; ++i) {
        sort(v.begin(), v.end());
        v[v.size()-1] /= 2;
    }
*/
    make_heap(v.begin(),v.end());
    for(int i = 0 ; i < m; i++) {
        long long a=v.front();
        pop_heap(v.begin(),v.end());
        v.pop_back();
        a=a/2;
        v.push_back(a);
        push_heap(v.begin(),v.end());
    }
    cout << accumulate(v.begin(), v.end(), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 1912
// 解説閲覧後
#include<iostream>
#include<vector>
#include<string>
using namespace std;
#define df 0
typedef long int li;
#define rep(i,a,n) for(int i=(a);i<(n);i++)

void print(const vector<vector<int>>& v,int n,int m){
  rep(i,0,n){
    rep(j,0,m) printf("%2d",v.at(i).at(j));
    printf("\n");
  }
}

int dp(const vector<vector<int>>& v,int x,int y,int z,int w){
  x--;y--;
  return v[z][w]-v[z][y]-v[x][w]+v[x][y];
}

int main(){
  if(df) printf("*debug mode*\n");
  int n,m,q; cin >>n >>m >>q;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s.at(i);
  }

  vector<vector<int>>
    v(n+1,vector<int>(m+1,0)),
    ev(n,vector<int>(m+1,0)),
    eh(n+1,vector<int>(m,0));
  for(int i=1;i<n+1;i++){
    for(int j=1;j<m+1;j++){
      if(s.at(i-1).at(j-1)=='1'){
	v.at(i).at(j)=1;
	if(i<n and s.at(i).at(j-1)=='1'){
	  ev.at(i).at(j)=1;
	}
	if(j<m and s.at(i-1).at(j)=='1'){
	  eh.at(i).at(j)=1;
	}
      }
    }
  }
  rep(i,1,n+1)rep(j,1,m+1) v.at(i).at(j)+=v.at(i-1).at(j);
  rep(i,1,n+1)rep(j,1,m+1) v.at(i).at(j)+=v.at(i).at(j-1);
  rep(i,1,n)rep(j,1,m+1) ev.at(i).at(j)+=ev.at(i-1).at(j);
  rep(i,1,n)rep(j,1,m+1) ev.at(i).at(j)+=ev.at(i).at(j-1);
  rep(i,1,n+1)rep(j,1,m) eh.at(i).at(j)+=eh.at(i-1).at(j);
  rep(i,1,n+1)rep(j,1,m) eh.at(i).at(j)+=eh.at(i).at(j-1);

  if(df){
    print(v,n+1,m+1);
    print(ev,n,m+1);
    print(eh,n+1,m);
  }
  for(int k=0;k<q;k++){
    int x,y,z,w; cin >>x >>y >>z >>w;
    int ret=dp(v,x,y,z,w)-dp(ev,x,y,z-1,w)-dp(eh,x,y,z,w-1);
    printf("%d\n",ret);
  }
}

/// confirm df==0 ///

Measured memory_bytes: 54400
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import Control.Monad
import Control.Monad.Trans.State
import qualified Data.ByteString.Unsafe as B
import qualified Data.ByteString.Char8 as C8
import Data.Array
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = do
  [n,m] <- readInts
  hs <- readInts
  replicateM m readPair >>= output . solve n hs

solve :: Int -> [Int] -> _ -> _
solve n hs = length . filter (/=0) . elems . (arr//) . flip zip [0,0..] . go
  where
    arr = listArray (1,n) hs

    go [] = []
    go ((a,b):xs)
      | arr!a < arr!b = a : go xs
      | arr!a > arr!b = b : go xs
      | otherwise = a : b : go xs

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

readPair :: IO (Int, Int)
readPair = head . L.unfoldr readT <$> C8.getLine
  where
    readT = runStateT $
      (,) <$> StateT (C8.readInt . C8.dropWhile C.isSpace)
          <*> StateT (C8.readInt . B.unsafeTail)


Measured memory_bytes: 34760
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC106C
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var K = ReadLong;

            int ans = 1;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] != '1')
                {
                    ans = int.Parse(S[i].ToString());
                    break;
                }
            }

            bool ok = true;
            for (int i = 0; i < Math.Min(K, S.Length); i++)
            {
                if (S[i] != '1') ok = false;
            }
            if (ok) ans = 1;

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>

int G[100][100], num[100], width[100];

void depth(int u, int t){
	int i;
	width[u] = t;
	for (i = 1; i <= num[u]; i++){
		if (width[G[u][i]] > t)
		{
			depth(G[u][i], t + 1);
		}
	}
}

int main(void)
{
	int i, j, n;
	int u;

	scanf("%d", &n);

	//?????????
	for (i = 1; i <= n; i++){
		width[i] = 10000;
		for (j = 1; j <= n; j++){
			G[i][j] = 0;
		}
	}

	//??£??\???????????¨???
	for (i = 1; i <= n; i++){
		scanf("%d", &u);
		scanf("%d", &num[u]);
		for (j = 1; j <= num[u]; j++){
			scanf("%d", &G[u][j]);
		}
	}

	depth(1, 0);

	for (i = 1; i <= n; i++){
		if (width[i] == 10000)
		{
			width[i] = -1;
		}
		printf("%d %d\n", i, width[i]);
	}

	return 0;
}

Measured memory_bytes: 636
#include <cstdio>
#include <cmath>

int main(){
  while(1){
    int n;
    scanf("%d", &n);
    if(n == 0) break;
    int points[n];
    for ( int i = 0; i < n; i++ ){
      scanf( "%d", &points[i] );
    }
    int sum = 0;
    for (int i = 0; i < n ; i++ ){
      sum += points[i];
    }
    double avg;
    avg = 1.0*sum / n;
    double devpoints[n];
    for (int i = 0; i < n; i++ ){
      devpoints[i] = (points[i] - avg)*(points[i] - avg);
    }
    double a2 = 0.0;
    for ( int i = 0; i < n; i++ ){
      a2 += devpoints[i];
    }
    double a;
    a = sqrt(a2/n);


    printf("%lf\n", a);
  }
  return 0;
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[10][10];
int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		ll now=i;
		ll d=now%10;
		while(now/10!=0){
			now/=10;
		}
		ll u=now;
		a[u][d]++;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ll now=i;
		ll d=now%10;
		while(now/10!=0){
			now/=10;
		}
		ll u=now;
		ans+=a[d][u];
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int D, G;
vector<pair<int, int> >NtoS;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin >> D >> G;
    G /= 100;
    int p, c;
    for(int i=1; i<=D; i++){
        cin >> p >> c;
        c/=100;
        NtoS.push_back(make_pair(p, c+i*p));
        // cout << p << c+i*p << endl;
    }
    int ans = 1e6;
    for(int i=0; i< 1<<D; i++){
        int g = G;
        int n = 0;
        for(int j=D-1; j>=0; j--){
            if(i>>j&1){
                g-=NtoS[D-j-1].second;
                n+=NtoS[D-j-1].first;
                if(g<0) break;
            }
        }
        // if(n==1) cout << " n==1 " << i << endl;
        if(g>0){
            for(int j=0; j<D; j++){
                if(!(i>>j&1)){
                    // cout << "NtoS: " << NtoS[D-j-1].first << " g/(D-j): " << g/(D-j) << "bool" << (NtoS[D-j-1].first >= g/(D-j) )<< endl;
                    if(g%(D-j) != 0 && NtoS[D-j-1].first >= g/(D-j)+1){
                        n = n + g/(D-j) +1;
                        g = -1;
                        // cout << "true" <<n << endl;
                    }else if(g%(D-j)==0 && NtoS[D-j-1].first >= g/(D-j)){
                        n = n + g/(D-j);
                        g = -1;
                        // cout << "true" << n  << endl;
                    }
                    // cout << "n: " << n << "j: " << j <<  endl;
                    break;
                }
            }
        }
        if(n != 0 && g<=0) ans = min(n, ans);
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    int N; cin >> N;
    map<string, int> Map;
    int Command, Val;
    string Color;
    
    for(int i = 0; i < N; ++i)
    {
        cin >> Command;
        cin >> Color;
        
        if(Command == 0)
        {
            cin >> Val;
            Map[Color] = Val;
        }
        else if(Command == 1)
            cout << Map[Color] << endl;
        else if(Command == 2)
            Map.erase(Color);
        
    }
}


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

int main() {
	long long a, b, c, k;
	cin >> a >> b >> c >> k;

	if (abs(a - b) > 10e18) cout << "Unfair" << endl;
	else if (k % 2 == 0) cout << a - b << endl;
	else cout << -a + b << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
if sys.platform in ['ios', 'win32', 'darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(x) for x in input().split()]

X = INT()

# (1+n)*n = 2*X
print(round((X*2)**0.5))


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

main :: IO ()
main = do
  getLine
  solve <$> getl (wrds toInt) >>= print

solve :: [Int] -> Int
solve xs = minimum $ map f [mi..mx]
  where
    f x = sum [(x - i) ^ 2|i <- xs]
    mi = minimum xs
    mx = maximum xs

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

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


Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

signed main() {
	int a, b; cin >> a >> b;
	if (a == b) { puts("1"); return 0; }
	int r = 62, k = 62;
	for (; r >= 0; r--) {
		if ((a&(1ll << r)) ^ (b&(1ll << r))) {
			for (k = r; k > 0; k--) {
				if ((b&(1ll << (k-1ll)))) {
					break;
				}
			}
			break;
		}
	}
	r++;
	a = a % (1ll << r);
	b = b % (1ll << r);
	int ans = (1ll << (r - 1ll)) - a;
	int x = (1ll << (r - 1ll)), y = (1ll << (r - 1ll)) + (1ll << k) - 1ll;//(x,y)
	int S = ((1ll << (r - 1)) + a), G = (1ll << r) - 1;
	ans += y - x + 1; ans += G - S + 1;
	int n = max(x, S), m = min(y, G);
	ans -= max(0ll, m - n + 1);
	cout << ans << endl;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 + y1 - y2
y3 = y2 + x2 - x1
x4 = x3 + x1 - x2
y4 = y3 + y1 - y2
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), 0)
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	i, _ := strconv.Atoi(readString())
	return i
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

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

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}
func main() {
	N := readInt()
	M := readInt()
	Q := readInt()
	var data [510][510]int
	for i := 0; i < M; i++ {
		l, r := readInt(), readInt()
		data[l][r]++
	}

	for i := N; i >= 1; i-- {
		for j := 1; j <= N; j++ {
			data[i][j] += data[i+1][j]
			data[i][j] += data[i][j-1]
			data[i][j] -= data[i+1][j-1]
		}
	}
	var bb = bytes.NewBuffer(make([]byte, 0, 100))
	for i := 0; i < Q; i++ {
		p, q := readInt(), readInt()
		bb.WriteString(strconv.Itoa(data[p][q]))
		bb.WriteString("\n")
	}
	fmt.Println(bb.String())
}

Measured memory_bytes: 8320
def main():
    from itertools import product

    N = int(input())
    s = input()

    def is_ok(t):
        # 文字列tの構築に必要なsだけ使用し、後で検算にs[0]とs[-1]を用いる
        for i, c in enumerate(s[1:-1], start=1):
            if t[i]:  # S
                if c == 'o':
                    t[i + 1] = t[i - 1]
                else:
                    t[i + 1] = t[i - 1] ^ 1
            else:
                if c == 'o':
                    t[i + 1] = t[i - 1] ^ 1
                else:
                    t[i + 1] = t[i - 1]

        ret = True
        if t[0]:
            if s[0] == 'o':
                ret &= t[-1] == t[1]
            else:
                ret &= t[-1] != t[1]
        else:
            if s[0] == 'o':
                ret &= t[-1] != t[1]
            else:
                ret &= t[-1] == t[1]

        if t[-1]:
            if s[-1] == 'o':
                ret &= t[-2] == t[0]
            else:
                ret &= t[-2] != t[0]
        else:
            if s[-1] == 'o':
                ret &= t[-2] != t[0]
            else:
                ret &= t[-2] == t[0]
        return ret

    for prd in product([0, 1], repeat=2):
        # 最初の二匹を決め打ちし、以後矛盾なく構築できればよい
        t = [''] * N
        t[:2] = prd
        if is_ok(t):
            print(*map(lambda x: 'WS'[x], t), sep='')
            return

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7384
import sys
N = int(input())

tasks = []
for i in range(N) : 
  tasks.append([int(n) for n in input().split()])

tasks.sort(key=lambda x:x[1])
costs = [a[0] for a in tasks]
deadLines = [b[1] for b in tasks]
sumCost = 0

for n in range(len(costs)) :
  sumCost += costs[n]
  dead = deadLines[n]
  if sumCost > dead :
    print("No")
    sys.exit()

print("Yes")

Measured memory_bytes: 41172
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
    int N; cin>>N;
    vector <int> p(N);
    for(int i=0;i<N;i++){
        cin>>p[i];
    }

    vector<int>q(N);
    q=p;
    sort(q.begin(),q.end());

    if(p==q){
        cout<<"YES";
        return 0;
    }

    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            swap(p[i],p[j]);
            if(p==q){
                cout<<"YES";
                return 0;
            }
            swap(p[i],p[j]);
        }
    }

        cout<<"NO";

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int ans = 0;
            for (int i = 1; i < s.Length; i++)
            {
                if ( s[i-1] != s[i])
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13116
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int c[4], n;
    for (auto& x : c) cin >> x; cin >> n;

    int t[4];
    for (int i = 0; i < 4; i++) t[i] = (1 << (3 - i)) * c[i];

    long long ans = n % 2 ? min({t[0], t[1], t[2]}) / 2 : 0;

    sort(t, t + 4);

    while (n >= 2) {
        ans += t[0];
        n -= 2;
    }

    cout << ans << endl;

    return 0;
}


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

int32_t   main(){
    int n;
    cin>>n;
    int a[n];
    int sum = 0 ; 
    int prev,temp;
    cin>>prev ;
    n--;
    while(n--){
        cin>>temp;
        if(temp<prev){
             sum+=(prev-temp);
            //  cout<<"add "<<prev-temp;
        }
        prev = max( temp,prev);

    }   
    cout<<sum;
    return 0;

}


Measured memory_bytes: 3588
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  REP(i, n) scanf("%d", &a[i]);

  int x = *min_element(a.begin(), a.end());
  int y = *max_element(a.begin(), a.end());

  int cx = 0, cy = 0;
  REP(i, n) {
    if (a[i] == x) cx++;
    if (a[i] == y) cy++;
  }


  if (x == y) {
    assert(cx == n);

    if (x == n-1 || 2*x <= n) {
      puts("Yes");
    } else {
      puts("No");
    }
    return 0;
  }

  if (x + 1 != y) {
    puts("No");
    return 0;
  }

  if (cx < y && 2*(y - cx) <= cy) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

ll n;

ll cnt_digits(ll n) {
  ll cnt = 0;
  while(n) {
    n /= 10;
    cnt++;
  }

  return cnt;
}

int main() {
  cin >> n;

  ll ans = INFLL;
  for (ll i = 1; i*i <= n; ++i) {
    if (n % i == 0) {
      ans = cnt_digits(n / i);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		System.out.println(b-a+1 - div(a,b,c) - div(a,b,d) + div(a,b,c*d/gcd(c,d)));
	}
	static long div(long x, long y, long z){
		return y / z - (x-1) / z;
	}
	static long gcd(long a, long b){
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		else return gcd(b, a % b);
	}
}


Measured memory_bytes: 25044
#include <iostream>
#include <vector>
#include<utility>

using namespace std;

int getMax(vector<int> s, int Max, int &index, int N){
  int tmp = 0;
  bool flag = false;
  for(int i = index; i < s.size(); i++){
    tmp = Max - s[i];
    if(tmp % 10 != 0){
      flag = true;
      break;
    }
  }
  if(flag) return tmp;
  else if(index != N){
    index++;
    tmp = getMax(s, Max - s[index], index, N);
    return tmp;
  }
  else{
    return 0;
  }
  
}

int main(){
  int N;
  vector<int> s;
  cin >> N;
  int Max = 0;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    s.push_back(tmp);
    Max += tmp;
  }
  sort(s.begin(), s.end());
  if(Max % 10 != 0) cout << Max << endl;
  else{
    int index = 0;
    int ans = getMax(s, Max, index, N);
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 256
<?php

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
$d = trim(fgets(STDIN));
$e = trim(fgets(STDIN));

$a1 = ceil( $a / 10 ) * 10;
$b1 = ceil( $b / 10 ) * 10;
$c1 = ceil( $c / 10 ) * 10;
$d1 = ceil( $d / 10 ) * 10;
$e1 = ceil( $e / 10 ) * 10;

$a2 = $a % 10 + ($a % 10 == 0 ? 10 : 0);
$b2 = $b % 10 + ($b % 10 == 0 ? 10 : 0);
$c2 = $c % 10 + ($c % 10 == 0 ? 10 : 0);
$d2 = $d % 10 + ($d % 10 == 0 ? 10 : 0);
$e2 = $e % 10 + ($e % 10 == 0 ? 10 : 0);


$min = min($a2,$b2,$c2,$d2,$e2);
$temp = $a1+$b1+$c1+$d1+$e1;

if ( $min == $a2 ) {
    $temp = $temp - $a1 + $a;

} else if ( $min == $b2) {
    $temp = $temp - $b1 + $b;

} else if ( $min == $c2) {
    $temp = $temp - $c1 + $c;

} else if ( $min == $d2) {
    $temp = $temp - $d1 + $d;

} else if ( $min == $e2) {
    $temp = $temp - $e1 + $e;

} else {
    $temp = $temp - $a1 + $a;
    
}

echo $temp;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  ll x,k,d;
  cin>>x>>k>>d;

  if(x/k>=d) {
    cout << x-k*d << endl;
    return 0;
  }
  if(d<=(-x)/k) {
    cout << 0-(x+k*d) << endl;
    return 0;
  }

  if(x==0){
    if(k%2==0) cout << 0 << endl;
    else cout << d << endl;
    return 0;
  }

  if(x<0) x*=-1;
    ll y=x%d;
    ll ykai=x/d;
    ll z=d-y;
    if(ykai%2==k%2) cout << y << endl;
    else cout << z << endl;
    return 0;

}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
        int N;
        string S;
        cin >> N >> S;
        int ans = 0;
        rep(i, N)
        {
                if (S.substr(i, 3) == "ABC")
                        ans++;
        }

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


Measured memory_bytes: 256
#![allow(unused_imports)]
use num::Integer;
use proconio::*;
use std::collections::VecDeque;
use std::ops::*;

fn main() {
   input! {
      n: usize,
      s: String
   }
   let r = s.match_indices("R").count();
   let g = s.match_indices("G").count();
   let b = s.match_indices("B").count();
   let mut ans = r*g*b;
   let v = s.as_bytes();
   for i in 0..n {
      for j in 1..=(n-i-1)/2 {
         if v[i] == v[i+j] || v[i] == v[i+2*j] || v[i+j] == v[i+2*j] {
            continue;
         }
         ans-=1;
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 2152
using System;
using System.Linq;
using static System.Console;
using static ConsoleApp.Util;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            //dpテーブル
            long[,] dp = new long[100010,3];
            //幸福値リスト
            long[,] a = new long[100010,3];

            long n = long.Parse(ReadLine());
            for(long i = 0;i < n;i ++){
                var array = ReadLine().Split(' ').Select(x=>long.Parse(x)).ToArray();
                for(int j = 0;j < 3;j++)
                    a[i,j] = array[j];
            }
            
            //初期条件
            dp[0,0] = 0; dp[0,1] = 0; dp[0,2] = 0;
            for(int i = 0;i < n;i++){
                //i日目にそれぞれの選択肢を選んだときのi+1日目に得られる最大値
                for(int k = 0;k < 3;k++ )
                {
                    for(int j = 0;j < 3;j++)
                    {
                        if(k==j)continue;
                        ChMax(ref dp[i+1,k],dp[i,j]+a[i,k]);
                    }
                }
            }
            long max = 0;
            for(int i = 0;i < 3;i++){
                if(max < dp[n,i])
                    max = dp[n,i];
            }

            WriteLine(max);
        }
    }


    static class Util{
        public static void ChMin(ref long a,long b){
            
            if(a > b){
                a = b;
            }
        }

        public static void ChMax(ref long a,long b){
            if(a < b){
                a = b;
            }
        }
    }
}


Measured memory_bytes: 21936
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n;
    cin >> n;
    vector<li> as(n);
    for (int i = 0; i < n; ++i) {
        cin >> as[i];
    }

    li sum = accumulate(as.begin(), as.end(), 0LL);
    li ans = 1e17;
    li head = 0;
    for (int i = 0; i < n - 1; ++i) {
        head += as[i];
        li tail = sum - head;
        
        ans = min(ans, abs(head - tail));
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b,c,d,e,f;
	double no=0;
	ll ans1=0,ans2=0;
	cin>>a>>b>>c>>d>>e>>f;
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			for(int k=0;k<=100;k++){
				for(int l=0;l<=100;l++){
					if(i==0&&j==0&&k==0&&l==0){
						continue;
					}
					double noww=i*a*100+b*j*100;
					double nows=c*k+d*l;
					if(noww+nows>f){
						continue;
					}
					ll maxs=noww/100*e;
					if(maxs<nows){
						continue;
					}
					double nowno=100*nows/(noww+nows);
					if(no<=nowno){
						no=nowno;
						ans1=noww;ans2=nows;
					}
				}
			}
		}
	}
	cout << ans1+ans2 << " "<<ans2;
	return 0;
}

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

int main(){
  int N,K; cin>>N>>K;
  int d[K]; for(int i=0;i<K;++i){cin>>d[i];}
  for(int n=N;n<N*100;++n){
    int t = n;
    int c[10] = {0}; while(t>0){c[t%10]=1;t/=10;}
    bool ok = true;
    for(int i=0;i<K;++i){
      if(c[d[i]]){ ok=false;break;}
    }
    if(ok){ cout << n <<"\n"; break;}
  }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

flag = 0
ans = 1
cnt = 0
for i in range(n-1):
    if a[i+1] - a[i] > 0 and flag == -1 and cnt > 0:
        flag = 1
        ans += 1
        cnt = 0
    elif a[i+1] - a[i] < 0 and flag == 1 and cnt > 0: 
        flag = -1
        ans += 1
        cnt = 0
    elif a[i+1] - a[i] == 0:
        pass
    elif cnt == 0 and a[i+1] - a[i] > 0:
        flag = 1
        cnt += 1
    elif cnt == 0 and a[i+1] - a[i] < 0:
        flag = -1
        cnt += 1
print(ans)

Measured memory_bytes: 14484
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	aa := make([]int, n)
	bb := make([]int, m)
	for i := 0; i < n; i++ {
		aa[i] = -getNextInt(scanner)
	}
	for i := 0; i < m; i++ {
		bb[i] = -getNextInt(scanner)
	}

	sort.Ints(aa)
	sort.Ints(bb)
	for i := 1; i < n; i++ {
		if aa[i] == aa[i-1] {
			fmt.Fprintln(writer, 0)
			return
		}
	}
	for i := 1; i < m; i++ {
		if bb[i] == bb[i-1] {
			fmt.Fprintln(writer, 0)
			return
		}
	}
	mod := int64(1e9 + 7)
	ai := 0
	bi := 0
	var ans int64
	ans = 1
	for i := n*m - 1; i >= 0; i-- {
		for ai < n && -aa[ai] > i+1 {
			ai++
		}
		for bi < m && -bb[bi] > i+1 {
			bi++
		}
		p := ai*bi - (n*m - 1 - i)
		if ai < n && -aa[ai] == i+1 {
			if bi < m && -bb[bi] == i+1 {
				continue
			}
			p = bi
		} else if bi < m && -bb[bi] == i+1 {
			p = ai
		}
		if p <= 0 {
			fmt.Fprintln(writer, 0)
			return
		}
		ans *= int64(p)
		ans %= mod
	}

	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 640