akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint k;

int main() {
    cin >> k;
    lint n = (k + 49) / 50 + 49;
    lint ex = (n - 49) * 50 - k;
    vector<lint> a(50, n);
    while (ex--) {
        auto m = max_element(a.begin(), a.end());
        for (auto itr = a.begin(); itr != a.end(); itr++) {
            if (itr == m) {
                (*itr) -= 50;
            } else {
                (*itr)++;
            }
        }
    }
    cout << 50 << endl;
    for (auto e : a) {
        cout << e << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define int long long
using namespace std;

int n, d;	//1 <= n <= 2*10^5, 0 <= d <= 10^9
struct Star {
	int x, y, b;
}star[200000];

signed compare(const void *s1, const void *s2) {
	int t1 = ((Star*)s1)->b;
	int t2 = ((Star*)s2)->b;
	return t1 - t2;
}
signed main() {
	int i;
	cin >> n >> d;
	for( i = 0; i < n; i++ )
		cin >> star[i].x >> star[i].y >> star[i].b;
	qsort(star, n, sizeof(star[0]), compare);

	static multiset<int> X;
	static multiset<int> Y;
	multiset<int>::iterator it;
	multiset<int>::reverse_iterator rit;
	int ins = 0;
	int del = 0;
	int j;
	int ans = 0;

	/*for( i = 0; i < n; i++ ) {
		printf("index = %d x = %d y = %d b = %d\n", i, star[i].x, star[i].y, star[i].b);
	}*/

	for( i = 0; i < n; i++ ) {
		ins = i;
		X.insert( star[ins].x );
		Y.insert( star[ins].y );
		for(; del < n; del++ ) {
			if( star[del].b < star[i].b - d ) {
				it = X.find( star[del].x );
				X.erase( it );
				it = Y.find( star[del].y );
				Y.erase( it );
			} else {
				break;
			}
		}

		it = X.begin();
		int minx = *it;
		rit = X.rbegin();
		int maxx = *rit;
		it = Y.begin();
		int miny = *it;
		rit = Y.rbegin();
		int maxy = *rit;
		ans = max( ans, (maxx - minx) * (maxy - miny) );

		//printf("ins = %d, del = %d, x[%d, %d], y[%d, %d]\n", ins, del, minx, maxx, miny, maxy);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 24704
n,k = map(int,input().split())
kli = [k]
kch = k
while True:
  if kch == 1:
    break
  kch = (kch-1)//2 + 1
  kli.append(kch)
kli.reverse()
qli = []
def f(x):
  if x > 0:
    return x
  else:
    return 0
le = len(kli)
for i in range(le-1):
  p = min(n+1,kli[i+1])
  q = p - kli[i]
  qli.append(f(q))
qli.append(f(n+1-kli[-1]))
qli.reverse()
b = 1
son = 0
for i in range(le):
  son += b * qli[i]
  b /= 2
print(son/n)

Measured memory_bytes: 3064
N = int(input())
tmp = [i for i in range(1, 10)]
ans = list(tmp)
for i in range(10):
    tmp2 = []
    for x in tmp:
        k = int(str(x)[-1])
        if k != 0:
            ans.append(10*x-1 + k)
            tmp2.append(10*x-1 + k)
        if k != 9:
            tmp2.append(10*x+1 + k)
            ans.append(10*x+1 + k)
        tmp2.append(10*x + k)
        ans.append(10*x + k)
    tmp = list(tmp2)

ans.sort()
print(ans[N-1])


Measured memory_bytes: 62196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      out("Draw");
      return 0;
    }
    if (a == 1) out("Alice");
    else if (b == 1) out("Bob");
    else {
        if (a < b) out("Bob");
        else out("Alice");
    }
}



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

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

    int tmp_A_min = (int)round((A-1) / 0.08);
    int tmp_A_max = (int)round((A+1) / 0.08);
    int tmp_B_min = (int)round((B-1) / 0.1);
    int tmp_B_max = (int)round((B+1) / 0.1);

    int min_int = min({tmp_A_min, tmp_A_max, tmp_B_min, tmp_B_max});
    int max_int = max({tmp_A_min, tmp_A_max, tmp_B_min, tmp_B_max});

    for(int i=min_int; i<=max_int; i++){
        if((int)(i*0.08)==A && (int)(i*0.1)==B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;

}

Measured memory_bytes: 3672
N, K=map(int, input().split())
x=list(map(int, input().split()))
ans=2*(abs(x[0])+abs(x[-1]))
for i in range(N-K+1):
  temp=[abs(x[i]), abs(x[i+K-1])]
  if x[i+K-1]<=0 or x[i]>=0:
    s=max(temp)
  else:
    s=max(temp)+2*min(temp)
    
  if ans>s:
    ans=s
    
print(ans)

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

int main(){
	int N;
	cin >> N;
	vector<int> V(N);
	vector<int> C(N);
	for(int i = 0; i < N; ++i) cin >> V[i];
	for(int i = 0; i < N; ++i) cin >> C[i];

	// すべてのV-Cの計算結果を格納するvectorを用意する
	vector<int> res(N);
	for(int i = 0; i < N; ++i) {
		res[i] = V[i] - C[i];
	}

	int cnt = 0;

	for(int i = 0; i < N; ++i) {
		if(res[i] > 0) {
			cnt += res[i];
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{

    std::string S;
    std::cin >> S;

    size_t mincount = 10000;
    for (char c = 'a'; c <= 'z'; ++c) {
        auto SS = S;
        size_t count = 0;
        for (;;) {
            bool fin = true;
            for (auto r: SS) {
                if (r != c) {
                    fin = false;
                    break;
                }
            }
            if (fin) {
                mincount = std::min(mincount, count);
                break;
            }

            std::string sn;
            for (size_t j = 0; j < SS.size() - 1; ++j) {
                if (SS[j] == c || SS[j+1] == c) {
                    sn += c;
                }
                else {
                    sn += SS[j];
                }
            }
            SS = sn;
            count++;
        }
    }
    std::cout << mincount << std::endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class main
{
    public static int Main()
    {
        string xx = Console.ReadLine();
        string[] str = xx.Split(' ');
        int w = int.Parse(str[0]);
        int h = int.Parse(str[1]);
        int x = int.Parse(str[2]);
        int y = int.Parse(str[3]);
        int r = int.Parse(str[4]);

        if (0 <= (x - r) && (x + r) <= w && 0 <= (y - r) && (y + r) <= h)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

        return 0;

    }
}

Measured memory_bytes: 9036
A = []

A.append(list(map(int, input().split(' '))))
A.append(list(map(int, input().split(' '))))
A.append(list(map(int, input().split(' '))))

N = int(input())

for n in range(N):
  a = int(input())
  for i in range(3):
    for j in range(3):
      if A[i][j] == a:
        A[i][j] = -1
      
for i in range(3):
  if all(a == -1 for a in A[i]):
    print('Yes')
    exit()
        
for j in range(3):
  if all(a[j] == -1 for a in A):
    print('Yes')
    exit()

if all(a == -1 for a in [A[0][0], A[1][1], A[2][2]]):
  print('Yes')
  exit()

if all(a == -1 for a in [A[0][2], A[1][1], A[2][0]]):
  print('Yes')
  exit()

print('No')


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

const int MAX_DIGIT = 50;
ll dp[100][2]; // 上からi桁目まで

int main(){
    //　入力
    ll N, K; cin >> N >> K;
    vector<ll> A(N);
    ll dp[100][2];
    for(int i = 0; i < N; i++) cin >> A[i];

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for(int d = 0; d < MAX_DIGIT; d++){
        ll mask = 1LL << (MAX_DIGIT - d - 1);

        // Aでもともとd桁目にビットが立っているものの個数
        int num = 0;
        for(int i = 0; i < N; i++) if(A[i] & mask) num++;

        // Xのd桁目を0,1にした時に得られる値
        ll cost0 = mask * num;
        ll cost1 = mask * (N - num);

        if(dp[d][1] != -1) dp[d+1][1] = dp[d][1] + max(cost0, cost1);
        if(mask & K){
            dp[d+1][1] = max(dp[d+1][1], dp[d][0] + cost0);
            dp[d+1][0] = dp[d][0] + cost1;
        }
        else dp[d+1][0] = dp[d][0] + cost0;
    }
    cout << max(dp[MAX_DIGIT][1], dp[MAX_DIGIT][0]) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define w(t) int t;cin>>t;while(t--)
#define pb   push_back
#define mk   make_pair
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
typedef long long ll;
const ll mod=1e9+7;
string solve(vector<int>&v,int k){
	bool dp[k+1];
	memset(dp,0,sizeof dp);
	for(int i=1;i<=k;i++){
		for(int move: v){
			if(move >i)continue;
			if(dp[i-move]==0)
				dp[i]=1;
		}
	}
	return dp[k] ? "First" : "Second";
}
int main()
{

	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr);
    int n;cin>>n;
    int k;cin>>k;
    vector<int>A(n);
    for(int i=0;i<n;i++)cin>>A[i];
    	cout<<solve(A,k);
    return 0; 
}




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

int  main()
{
	int n; cin >> n;
	vector <int> a(n);
	rep(i, n) cin >> a[i];

	int ans;
	priority_queue <int, vector<int>, greater<int> > pq;
	for (int i = -100; i <= 100; i++)
	{
		ans = 0;
		for (int j = 0; j < n; j++)
		{
			ans += abs(i-a[j]) * abs(i-a[j]);
		}
		pq.push(ans);
	}
	cout << pq.top() << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	string s;
	cin>>s;
	int a=(s[0]-48)*10+s[1]-48;
	int b=(s[2]-48)*10+s[3]-48;
	if(a>0&&a<=12){
		if(b>0&&b<=12){
			cout<<"AMBIGUOUS"<<endl;
		}
		else{
			cout<<"MMYY"<<endl;
		}		
	}
	else{
		if(b>0&&b<=12){
			cout<<"YYMM"<<endl;
		}
		else{
			cout<<"NA"<<endl;
		}
	}
}	


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
 public static void main(String args[]){
  int w,h,i,j;
  Scanner sc = new Scanner(System.in);
  while(true)
  {
   h=sc.nextInt();
   w=sc.nextInt();
   if(h==0 && w==0)
    break;
   for(i=0;i<h;i++)
   {
    for(j=0;j<w;j++)
     System.out.print("#");
   System.out.println();
   }
  System.out.println();
  }
 }
}


Measured memory_bytes: 35168
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	long long int a;
    long long int b;
    long long int c;

	cin >> a >> b >> c ;

    if(a+b>c){
        cout << "No";
    }else{
        c -= a+b;
        if(c*c > a*b*4){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }
	
	return 0;
}

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

int main(void) {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  string ans;
  
  while(A >= 0 || C >= 0){
    C -= B;
    if(C <= 0){
      ans = "Yes";
      break;
    }
    A -= D;
    if(A <= 0){
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define maxn 200005

using namespace std;

int n,m,ans[maxn][3];
struct node
{
    int x,y;
    bool operator <(const node &a)const
    {
        return x<a.x;
    }
}d[maxn/2];

int main()
{

    scanf("%d%d",&n,&m);
    for (int i=0;i<m;i++) scanf("%d%d",&d[i].x,&d[i].y);
    sort(d,d+m);
    for (int i=1;i<=n;i++) ans[i][1]=1;
    for (int i=0;i<m;i++)
    {
      
        int p=d[i].y,t1=ans[p][1],t2=ans[p+1][1];
        ans[p][1]+=t2-ans[p][2];
        ans[p+1][1]+=t1-ans[p+1][0];

        ans[p][2]=ans[p+1][1];
        ans[p+1][0]=ans[p][1];
    }
    for (int i=1;i<n;i++) printf("%d ",ans[i][1]);
    printf("%d\n",ans[n][1]);
    return 0;
}

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

int main() {
    int a;
    cin >> a;
    for(int i = 3;i <= a;i++){
        if(i % 3 == 0){
            cout << " " << i;
        }
        else{
          	int x = i;
          	while(x > 0){
            	if(x % 10 == 3){
                  cout << " " << i;
                  break;
                }
              	x /= 10;
          	}
        }
    }
    cout << endl;
}


Measured memory_bytes: 3116
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let [a,b,c]=nrin(3)
  out(a<=c&&a+b>=c?'YES':'NO')
}
main()

Measured memory_bytes: 7372
{-# LANGUAGE MultiWayIf #-}

import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    [k, s] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
    let [a, b] = if | s <= k -> [0, s]
                    | s <= k * 2 -> [0, k]
                    | otherwise -> [s - k * 2, k]
    let solve x i = let t = s - i
                    in x + (if t <= k then t + 1 else k * 2 - t + 1)
    print $ foldl solve 0 [a..b]


Measured memory_bytes: 380
fn main() {
    let n = rv::<usize>()[0];
    let mut a = Vec::with_capacity(n);
    for _ in 0..n {
        a.push(rv::<i64>());
    }
    let f=||{
        let mut t=0;
        for i in 0..n { for j in i+1..n {
            let mut e=true;
            for k in 0..n { if k!=i && k!=j {
                let d=a[i][k]+a[k][j];
                if a[i][j]==d {
                    e=false;
                }
                else if a[i][j]>d {
                    return -1;
                }
            }}
            if e {
                t += a[i][j];
            }
        }}
        t
    };
    println!("{}",f());
}
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T>
  where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 4352
def gcd(x, y): 
    while(y): 
        x, y = y, x % y 
    return x 

n = int(input())
A = [int(i) for i in input().split()]

R = [0] + list(A) + [0]
L = [0] + list(A) + [0]
M = [0] * (n+2)


for i in range(n, 0, -1):
    R[i] = gcd(R[i], R[i+1])


for i in range(1,n+1):
    L[i] = gcd(L[i], L[i-1])

for i in range(1,n+1):
    M[i] = gcd(L[i-1], R[i+1])


print(max(M))



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//     cout << fixed << setprecision(15);

    ll n; cin >> n;
    vll a(n); rep(i,n) cin >> a[i];

    map<ll, ll> nums;
    for(auto aa : a) ++nums[aa];

    ll cnt = 0;
    for(auto p : nums) {
        cnt += (p.second)*(p.second-1)/2;
    }

    ll out;
    for(int i = 0; i < n; ++i) {
        out = cnt - nums[a[i]] + 1;
        cout << out << '\n';
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 11136
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

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

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	S := sc.nextStr()
	ans := 0
	for i, r := range S {
		if r == 'A' && i+2 < N && S[i:i+3] == "ABC" {
			ans++
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

int main(){
    int N;
    cin>>N;
    long long sumT,sum3,sum5,sum15;
    int nt,n5,n3,n15;
    

    nt=N;
    n3=N/3;
    n5=N/5;
    n15=N/15;

    sumT=(1LL+N)*N/2LL;
    sum3=(3LL+N/3LL*3LL)*n3/2LL;
    sum5=(5LL+N/5LL*5LL)*n5/2LL;
    sum15=(15LL+N/15LL*15LL)*n15/2LL;
    
    cout<<sumT-sum3-sum5+sum15<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    string s;
    cin >> s;
    ll i;
    
    for(i=0; i<(ll)s.size()-1; i++) {
        if(s[i]==s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    
    for(i=0; i<(ll)s.size()-2; i++) {
        if(s[i]==s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    
    cout << "-1 -1" << endl;
}

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

using namespace std;

int main() {
  int n, m, x, ans, count, midx;

  cin >> n >> m;
  /// j番目のゲームが実施されるか
  vector<bool> h(m);
  /// j番目のゲームが何人にプレイされるか
  vector<int> p(m);
  /// i番目の参加者の優先順
  vector<int> a[n];

  for (int j = 0; j < n; j++) {
    vector<int> y(m);
    for (int i = 0; i < m; i++) {
      cin >> y[i];
      y[i]--;
    }
    a[j] = y;
  }

  /// 全部実施するとき
  count = 0;
  fill(p.begin(), p.end(), 0);
  for (int i = 0; i < n; i++) {
    p[a[i][0]]++;
    if (p[a[i][0]] > count) {
      midx = a[i][0];
      count++;
    }
  }

  ans = count;

  /// 前回の最大を実施しない
  fill(h.begin(), h.end(), true);
  for (int k = 0; k < m-1; k++) {
    fill(p.begin(), p.end(), 0);
    h[midx] = false;
    count = 0;
    for (int j = 0; j < n; j++) {
      for (int i = 0; i < m; i++) {
        if (h[a[j][i]]) {
          p[a[j][i]]++;
          if (p[a[j][i]] > count) {
            midx = a[j][i];
            count++;
          }
          break;
        }
      }
    }

    if (count < ans) ans = count;
  }

  cout << ans << endl;
}


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

struct Node1{
  int key1;
  struct Node1 *left,*right,*parent;
};

struct Node1 *root,*NIL;
struct Node1 *treeMinimum(struct Node1 *);
struct Node1 *treeSuccessor(struct Node1 *);
void treeDelete(struct Node1 *z);
struct Node1 *find(struct Node1 *,int);
void insert (int);
void ins_order(struct Node1 *);
void pri_order(struct Node1 *);
int main(){
  int n,i,x,y;
  char order[7];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",order);
    if(strcmp(order,"find")==0){
      scanf("%d",&x);
      struct Node1 *t=find(root,x);
      if(t!=NIL){
	printf("yes\n");
      } else printf("no\n");
    }else if(strcmp(order,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }else if(strcmp(order,"print")==0){
      ins_order(root);
      printf("\n");
      pri_order(root);
      printf("\n");
    }else if(strcmp(order,"delete")==0){
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}

void insert(int a){
  struct  Node1 *x=root;
  struct Node1 *y=NIL;
  struct  Node1 *z;

  z=(struct Node1 *)malloc(sizeof(struct Node1));
  z->key1=a;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key1 < x->key1){
      x= x->left;
    }else{
      x= x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key1<y->key1){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}
void ins_order(struct Node1 *u){
  if(u==NIL)return ;
  ins_order(u->left);
  printf(" %d",u->key1);
  ins_order(u->right);
}
void pri_order(struct Node1 *u){
  if(u==NIL)return ;
  printf(" %d",u->key1);
  pri_order(u->left);
  pri_order(u->right);
}
struct Node1 *find(struct Node1 *u,int k){
  while(u!=NIL && k!=u->key1){
    if(k<u->key1) u=u->left;
    else u=u->right;
  }
  return u;
}
struct Node1 *treeMinimum(struct Node1 *x){
  while(x->left!=NIL)x=x->left;
  return x;
}
struct Node1 *treeSuccessor(struct Node1 *x){
  if(x->right!=NIL)return treeMinimum(x->right);
  struct Node1 *y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
void treeDelete(struct Node1 *z){
  struct Node1 *y;
  struct Node1 *x;
  if(z->left==NIL||z->right==NIL)y=z;
  else y=treeSuccessor(z);
  if(y->left!=NIL){
    x=y->left;
  }else{
    x=y->right;
  }
  if(x!=NIL){
    x->parent=y->parent;
  }
  if(y->parent==NIL){
    root=x;
  }else{
    if(y==y->parent->left){
      y->parent->left=x;
    }else{
      y->parent->right=x;
    }
  }
  if(y!=z){
    z->key1=y->key1;
  }
  free(y);
}

Measured memory_bytes: 19364
#include<cstdio>
#include<queue>

using namespace std;

int n;
double v, a, b;
priority_queue<double> PQ;

int main(){
  scanf("%d", &n);
  for (int i=0; i<n; i++){
    scanf("%lf", &v);
    PQ.push(-v);
  }
  for(int i=1; i<n; i++){
    a=PQ.top();
    PQ.pop();
    b=PQ.top();
    PQ.pop();
    PQ.push((a+b)/2.0);
  }
  printf("%lf", -PQ.top());
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,ab[1100000],c,d[10000000];
string s;
signed main()
{
	cin>>s;
	rep(i,s.size()){
		if((i%2==0&&s[i]=='L')||(i%2==1&&s[i]=='R')){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <string>
    #include <algorithm>
    #include<set>
    #include <unordered_map> 
    #include <cmath>
    using namespace std;
   #define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void){

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

    unsigned long x;
    cin >> x;

    unsigned long shoji = 100;

    for(int i = 0;;i++){
        shoji += long(shoji *0.01);
        if(shoji >= x){
            cout << i+1 <<endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 3640
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        xai:[(usize,usize);n]
    }

    let mut yes = false;
    for i in 0..n - 2 {
        if xai[i].0 == xai[i].1 {
            //print!("{:?}", xai[i]);
            if xai[i + 1].0 == xai[i + 1].1 {
                if xai[i + 2].0 == xai[i + 2].1 {
                    yes = true;
                }
            }
        }
    }

    if yes {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2260
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int ans = 700;
    REP(i,3){
        char a; cin >> a;
        if(a=='o') ans+=100;
    }
    out(ans);

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const long long MOD = (long long)1e9 + 7;

int n, m, a[20], b[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 }, c[10], ans[5];
pair<int, int> part[10009];
vector<int> vec, vec2;
bool del[10], got[10];
bool comp(int &a, int &b)
{
	if (c[a] < c[b]) return true;
	else return false;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> a[i];
		c[b[a[i]]] = max(c[b[a[i]]], a[i]);
		if (!got[b[a[i]]]) {
			vec.push_back(b[a[i]]);
			got[b[a[i]]] = true;
		}
	}
	sort(vec.begin(), vec.end());
	for (int i = (int)vec.size() - 1; i >= 0; i--) {
		if (del[vec[i]]) continue;
		for (int j = 0; j < i; j++) {
			if (vec[i] % vec[j] == 0) {
				del[vec[i]] = true;
				break;
			}
		}
		if (del[vec[i]]) continue;
		for (int j = 0; j < i - 1; j++) {
			for (int k = j + 1; k < i; k++) {
				if (vec[i] == vec[j] + vec[k]) {
					del[vec[i]] = true;
					break;
				}
			}
			if (del[vec[i]]) break;
		}
		if (del[vec[i]]) continue;
		vec2.push_back(vec[i]);
	}
	sort(vec2.begin(), vec2.end(), comp);
	if (vec2.size() == 1) {
		for (int i = 0; i < n / vec2[0]; i++) cout << c[vec2[0]];
		cout << "\n";
	}
	else {
		for (int j = 0; j*vec2[1] <= n; j++) {
			for (int i = 0; i*vec2[0] <= n; i++) {
				int tmp = i * vec2[0] + j * vec2[1];
				if (tmp > n) break;
				int tmpsum = part[tmp].fi + part[tmp].se;
				if (tmpsum <= i + j) {
					part[tmp].fi = i;
					part[tmp].se = j;
				}
			}
		}
		if (vec2.size() == 2) {
			for (int i = 0; i < part[n].se; i++)
				cout << c[vec2[1]];
			for (int i = 0; i < part[n].fi; i++)
				cout << c[vec2[0]];
			cout << "\n";
		}
		else if (vec2.size() == 3) {
			for (int k = 0; k*vec2[2] <= n; k++) {
				int tmp = n - k * vec2[2];
				if (tmp && part[tmp].fi == 0 && part[tmp].se == 0) continue;
				int tmpsum = part[tmp].fi + part[tmp].se + k;
				if (tmpsum >= ans[0] + ans[1] + ans[2]) {
					ans[0] = part[tmp].fi;
					ans[1] = part[tmp].se;
					ans[2] = k;
				}
			}
			for (int i = 0; i < ans[2]; i++)
				cout << c[vec2[2]];
			for (int i = 0; i < ans[1]; i++)
				cout << c[vec2[1]];
			for (int i = 0; i < ans[0]; i++)
				cout << c[vec2[0]];
			cout << "\n";
		}
		else {
			for (int r = 0; r*vec2[3] <= n; r++) {
				for (int k = 0; k*vec2[2] <= n; k++) {
					int tmp = n - r * vec2[3] - k * vec2[2];
					if (tmp < 0) continue;
					if (tmp && part[tmp].fi == 0 && part[tmp].se == 0) continue;
					int tmpsum = part[tmp].fi + part[tmp].se + k + r;
					if (tmpsum >= ans[0] + ans[1] + ans[2] + ans[3]) {
						ans[0] = part[tmp].fi;
						ans[1] = part[tmp].se;
						ans[2] = k;
						ans[3] = r;
					}
				}
			}
			for (int i = 0; i < ans[3]; i++)
				cout << c[vec2[3]];
			for (int i = 0; i < ans[2]; i++)
				cout << c[vec2[2]];
			for (int i = 0; i < ans[1]; i++)
				cout << c[vec2[1]];
			for (int i = 0; i < ans[0]; i++)
				cout << c[vec2[0]];
			cout << "\n";
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
 
int main()
{
  int p, q, r;
  cin >> p >> q >> r;
  int x = max(p, max(q, r));
  cout << q+p+r-x << endl;
  return 0;
}

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


int main()
{
  int n;
  cin>>n;
  
  vector<vector<int> > dp( n , vector<int> (3, -1));  
  
  int i;
  vector<int>a(n);
  vector<int>b(n);
  vector<int>c(n);
  for(i=0;i<n;i++)
  {
     cin>>a[i];
     cin>>b[i];
     cin>>c[i];
  }
  
  dp[n-1][0]=a[n-1];
  dp[n-1][1]=b[n-1];
  dp[n-1][2]=c[n-1];
  
  for(i=n-2;i>=0;i--)
  {
      dp[i][0]=max(a[i] + dp[i+1][1],a[i] + dp[i+1][2]);
      dp[i][1]=max(b[i] + dp[i+1][0],b[i] + dp[i+1][2]);
      dp[i][2]=max(c[i] + dp[i+1][0],c[i] + dp[i+1][1]);
  }
  
  int res=max({dp[0][0],dp[0][1],dp[0][2]});
  cout<<res;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////

bool comx(l_l a, l_l b){
    return a.first<b.first;
}
bool comy(l_l a, l_l b){
    return a.second<b.second;
}

int main(){
    ll n,k;cin>>n>>k;
    ll a[n],b[n];
    vector<l_l> p;
    rep(i,0,n-1){
        cin>>a[i]>>b[i];
        p.pb(make_pair(a[i],b[i]));
    }
    sort(p.begin(),p.end(),comy);
    vector<l_l> v;
    ll ans=1E18*5;
    rep(i,0,n-1){
        v.clear();
        rep(j,i,n-1){
            v.pb(p[j]);
            if(v.size()<k)continue;
            sort(v.begin(),v.end(),comx);
            rep(l,0,v.size()-k){
                ans=min(ans,(p[j].second-p[i].second)*(v[l+k-1].first-v[l].first));
            }
            
        }
    }
    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);
        int n = sc.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        int total = 0;
        for(int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        for(int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        for(int i = 0; i < n; i++) {
            if(v[i] - c[i] > 0) {
                total += (v[i] - c[i]);
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

const string v = "Vacant";
const string m = "Male";
const string f = "Female";

int main(){
  int n;
  cin >> n;
  cout << 0 << endl;
  string sl;
  cin >> sl;
  if(sl == v) return 0;
  string sr;
  cout << n-1 << endl;
  cin >> sr;
  if(sr == v) return 0;
  int l = 0, r = n-1;
  rep(i, 20){
    int m = (l+r)/2;
    cerr << l << " " << m << " " << r << endl;
    int dl = m - l, dr = r - m;
    cout << m << endl;
    string sm;
    cin >> sm;
    if(sm == v) return 0;
    if(dl % 2 == 0){
      if(sl == sm){
        l = m;
      }else{
        sr = sm;
        r = m;
      }
    }else{
      if(sl != sm){
        sl = sm;
        l = m;
      }else{
        sr = sm;
        r = m;
      }
    }
  }
  return 1;
}

Measured memory_bytes: 3700
#include <stdio.h>
#include <math.h>
int main (void){
        char S[3001];
        int w,x=0;
        for (int i = 0; i < 3001; i++) {
          S[i]='0';
        }
        scanf("%s\n",S);
        scanf("%d",&w);
  while (S[x]!='0'&&S[x]!='\0') {
    printf("%c",S[x]);
    x+=w;
  }
  //printf("\n");
        return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  int num[5];
  int tmp;
  int i, j;

  scanf("%d%d%d%d%d", &num[0], &num[1], &num[2], &num[3], &num[4]);

  for(i = 0; i < 4; i++){
    for(j = i + 1; j < 5; j++){
      if(num[i] < num[j]){
	tmp = num[i];
	num[i] = num[j];
	num[j] = tmp;
      }
    }
  }

    for(i = 0; i < 5; i++){
      printf("%d", num[i]);
      if(i == 4)  break;
      putchar(' ');
    }
    printf("\n");

  return 0;
}

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

using namespace std;

int H, W;
string S[20];
int dp[20][20][21][21];

int rec(int sx, int sy, int gx, int gy)
{
  if(sx >= gx || sy >= gy) return (0);
  if(~dp[sx][sy][gx][gy]) return (dp[sx][sy][gx][gy]);
  unordered_set< int > grundy;
  for(int mx = sx; mx < gx; mx++) {
    for(int my = sy; my < gy; my++) {
      if(S[my][mx] == 'X') continue;
      grundy.insert(rec(sx, sy, mx, my) ^
                    rec(mx + 1, sy, gx, my) ^
                    rec(sx, my + 1, mx, gy) ^
                    rec(mx + 1, my + 1, gx, gy));
    }
  }
  int ret = 0;
  while(grundy.count(ret)) ++ret;
  return (dp[sx][sy][gx][gy] = ret);
}

int main()
{
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    cin >> S[i];
  }
  memset(dp, -1, sizeof(dp));
  if(rec(0, 0, W, H)) cout << "First" << endl;
  else cout << "Second" << endl;
}

Measured memory_bytes: 3868
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        int a = 0, b = 0, ans = 20000;
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            a += w[i];
        }
        for (int i = 0; i < n; i++) {
            a -= w[i];
            b += w[i];
            ans = Math.min(ans, Math.abs(a-b));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22992
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;



int main(void){
    int N,M,A;
    int ans=0;

    cin>>N>>M;

    for(int i=0;i<M;i++){
        cin>>A;
        ans = ans+A;
    }

    if(ans > N){
        cout<<-1<<endl;
    }else{
        cout<<N-ans<<endl;
    }




    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int A, B;

void solve()
{
    cin >> A >> B;
    cout << A * B << endl;
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3620
# coding: utf-8
# Your code here!

S = list(input())
K = int(input())
N = len(S)

flag = True
for i in range(N-1):
    if S[i] != S[i+1]:
        flag = False
        break

if flag:
    print(N*K // 2)
    exit()
cnt = 0
changed = [False for i in range(N)]
for i in range(1,N):
    if S[i] == S[i-1] and not changed[i-1]:
        cnt += 1
        changed[i] = True
ans = cnt * K
if S[0] == S[N-1]:
    head = 1
    tail = 1
    i = 0
    while S[i] == S[i+1]:
        head += 1
        i += 1
    i = N-1
    while S[i] == S[i-1]:
        tail += 1
        i -= 1
    if (head + tail) % 2 == 0:
        ans += K-1
print(ans)


Measured memory_bytes: 3064
//-- Araz Jabrayilov --
//-- araz17---zuna#1041 --

#include <bits/stdc++.h>

#define ll long long
#define endl '\n'
#define F first
#define S second

using namespace std;

///int a[1005];

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

    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    int x = 0;

    cin >> a >> b >> c >> d;

    while(true){
        if(x % 2 == 0){
            c -= b;
            if(c <= 0){
                break;
            }
        }
        else{
            a -= d;
            if(a <= 0){
                break;
            }
        }
        x++;
    }

    if(x % 2 == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */

  NodePointer mee;

  mee = nil->next;
  while(1){
    if(mee == nil || mee->key == key) break;
    mee = mee->next;
  }
  return mee;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */

  if(t != nil){
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
  }
  
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */

  deleteNode(nil->prev);
  
}

void delete(int key){
  /* your code */

  deleteNode(listSearch(key));
  
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* your code */

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



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

int main(){
    
    int64_t X,K,D,TX;
    int64_t cou=0;

    
     cin>>X>>K>>D;
int64_t ZX=abs(X);
  TX=ZX;



if(K<=TX/D){
    cout<<TX-K*D<<endl;
}else{
    int64_t ZXE;
    ZXE=ZX;
while(D<=ZXE){
    ZXE=ZXE-D;
    cou++;
}
if((K-cou)%2==0){
    cout<<ZXE<<endl;
} else{
    cout<<D-ZXE<<endl;
}
}
}



Measured memory_bytes: 3612
#include<stdio.h>
int main(){
    int h,w;
    int i,j;
    char a[101][101];
    scanf("%d%d",&h,&w);
    getchar();
    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            scanf("%c",&a[i][j]);
        }
        getchar();
    }
    for(i = -1; i < h+1; i++){
        for(j = -1; j < w+1; j++){
            if(i==-1||i==h)printf("#");
            else if(j==-1||j==w)printf("#");
            else printf("%c",a[i][j]);
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 128