akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

void Solve();

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

void Solve(){
  ll n;
    cin>>n;
  auto A=div(n);
  ll m=A.sz;
  ll ans=0;
  SORT(A);
  FOR(i,1,m){
    ll a=A[i]-1;
    if(n%a==n/a){
      ans+=a;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

typedef long long int ll;
const int N_MAX = 200005;
const int P_MAX = 10005;
long long int modp[P_MAX];

ll mod_pow(ll x, ll n, int mod){
    int res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int n, p;
    string S;
    cin >> n >> p >> S;
    ll m = 0;
    long long int ans = 0;
    memset(modp, 0, sizeof(modp));
    modp[0]++;
    if (p == 2){
        for(int i = 0; i < n; i++){
            if ((S[n-1-i] - '0') % 2 == 0){
                ans += n-i;
            }
        }
    }
    else if (p == 5){
        for(int i = 0; i < n; i++){
            if ((S[n-1-i] - '0') % 5 == 0){
                ans += n-i;
            }
        }
    }
    else {
        for(int i = 0; i < n; i++){
            m += mod_pow(10, i, p) * (S[n-1-i] - '0');
            m %= p;
            ans += modp[m];
            modp[m]++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 772
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    constexpr int A[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    int K;
    cin >> K;
    write(A[K - 1]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 5e18+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool dp1[8005][16005],dp2[8005][16005];
signed main() {
    string S;
    int x,y;
    cin >> S >> x >> y;
    int muki = 0;
    int cnt = 0;
    vector<vector<int>>res(2);
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'T') {
            if(cnt) {
                res[muki].push_back(cnt);
            }
            cnt = 0;muki^=1;
        }
        else {
            cnt++;
        }
    }
    if(cnt) {
        res[muki].push_back(cnt);
    }
    if(S[0] == 'F') {
        dp1[0][8000+res[0][0]] = true;
        res[0].erase(res[0].begin());
    }
    else {
        dp1[0][8000] = true;
    }
    dp2[0][8000] = true;
    for(int i = 0; i < res[0].size(); i++) {
        for(int j = 0; j <= 16000; j++) {
            if(dp1[i][j]) {
                dp1[i+1][j+res[0][i]] = true;
                dp1[i+1][j-res[0][i]] = true;
            }
        }
    }
    for(int i = 0; i < res[1].size(); i++) {
        for(int j = 0; j <= 16000; j++) {
            if(dp2[i][j]) {
                dp2[i+1][j+res[1][i]] = true;
                dp2[i+1][j-res[1][i]] = true;
            }
        }
    }
    cout << ((dp1[res[0].size()][8000+x] && dp2[res[1].size()][8000+y])?"Yes":"No") << endl;
}

Measured memory_bytes: 27484
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        k: usize,
        a: usize,
        b: usize,
    }

    let mut ans = "NG";
    if (a - 1) / k != b / k {
        ans = "OK";
    }
    println!("{}", ans);
}


Measured memory_bytes: 2180
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	inputs := scanIntNums()
	fmt.Println(check(inputs))
}

func check(nums []int) string {
	n := nums[0]
	c := nums[1]
	if n*500 >= c {
		return "Yes"
	}
	return "No"
}

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		boolean flag = false;

		Scanner scanner = new Scanner(System.in);
		String s = scanner.nextLine();
		String[] contest = s.split(" ");

		if (contest.length == 3 && contest[1].length() < 101
				&& "AtCoder".equals(contest[0]) && "Contest".equals(contest[2])) {
			if (Character.isUpperCase(contest[1].charAt(0))) {
				if (contest[1].length() > 1
						&& Character.isLowerCase(contest[1].charAt(1))) {
					flag = true;
				} else if (contest[1].length() == 1) {
					flag = true;
				}
			}
		}

		String ans = new String();

		if (flag) {
			for (int i = 0; i < contest.length; i++) {
				ans = ans + contest[i].charAt(0);
			}

			System.out.println(ans);

		}
	}
}

Measured memory_bytes: 21972
A, B = map(int, input().split())
S = input()
nums = ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
isvalid = all(c in nums for c in S[:A] + S[-B:]) and S[A] == "-"
print("Yes" if isvalid else "No")


Measured memory_bytes: 2940
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def sol():
    N = int(input())
    A = [0] * N
    B = [0] * N

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

    nowSum = 0
    for a, b in zip(A[:: -1], B[:: -1]):
        r = (a + nowSum) % b
        if (r + a + nowSum) % b != 0:
            r = b - r
        if r == 0:
            continue
        nowSum += r

    print(nowSum)

sol()

Measured memory_bytes: 12788
import sys
a,b = map(int, input().split())
s = input()

for i,x in enumerate(s):
  if i<a and x.isdigit():
    pass
  elif i==a and x=='-':
    pass
  elif a<i and x.isdigit():
    pass
  else:
    print("No")
    sys.exit()

print("Yes")


Measured memory_bytes: 2940
import sys
from itertools import groupby

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    idx = 0
    ans = [0] * len(S)
    for k, g in groupby(S):
        L = len(list(g))
        if k == 'R':
            for i in range(L):
                if (L - i) % 2 == 0:
                    ans[idx + L] += 1
                else:
                    ans[idx + L - 1] += 1
        if k == 'L':
            for i in range(L):
                if i % 2 == 0:
                    ans[idx] += 1
                else:
                    ans[idx - 1] += 1

        idx += L

    print(*ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 10704
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int n;
char input[2000];

int main(){
    scanf("%d", &n);
    scanf("%s", input + 1);   

    int lena = 0, lenb = 0;

    for(register int i=1; i<=n; i++){
        if(input[i] == 'R'){
            lena++;
        }else{
            lenb++;
        }
    } 

    if(lena > lenb){
        printf("Yes");
    }else{
        printf("No");
    }
    
    return 0;
}

Measured memory_bytes: 256
//Quick Sort

#include<stdio.h>
#include<stdlib.h>

#define SENTINEL 1000000001

typedef struct{
  int num;
  char suit;
}Data;


void Quicksort(Data*,int,int);

int Partition(Data*,int,int);

void Swap(Data*,Data*);

void Merge_sort(Data*,int,int);

void Merge(Data*,int,int,int);

int Test_stable(Data,Data);


int main(void){
  int n;
  Data *data,*stable_data;
  int i;
  char garbage;

  scanf("%d",&n);

  //%cは改行やスペースを読み込むのでその対策
  scanf("%c",&garbage);

  data=(Data*)malloc(n*sizeof(Data));
  stable_data=(Data*)malloc(n*sizeof(Data));

  for(i=0;i<n;i++){
    scanf("%c %d",&data[i].suit,&data[i].num);
    scanf("%c",&garbage);
    stable_data[i]=data[i];
  }

  Quicksort(data,0,n-1);

  Merge_sort(stable_data,0,n);

  for(i=0;i<n;i++){
    if(data[i].suit!=stable_data[i].suit){
      printf("Not stable\n");
      break;
    }
  }
  if(i==n) printf("Stable\n");

  for(i=0;i<n;i++) printf("%c %d\n",data[i].suit,data[i].num);


  free(data);
  free(stable_data);

  return 0;
}

void Quicksort(Data *A,int p,int r){
  int work;

  if(p<r){
    work=Partition(A,p,r);
    Quicksort(A,p,work-1);
    Quicksort(A,work+1,r);
  }
}

int Partition(Data *A,int p,int r){
  int pivot;
  int i,j;

  pivot=A[r].num;

  j=p;
  for(i=p;i<r;i++){
    if(A[i].num<=pivot){
      Swap(&A[i],&A[j]);
      j++;
    }
  }
  Swap(&A[j],&A[r]);

  return j;
}

void Swap(Data *a,Data *b){
  Data work;

  work=*a;
  *a=*b;
  *b=work;
}

void Merge_sort(Data *A,int left,int right){
  int mid;

  if(left+1<right){
    mid=(left+right)/2;
    Merge_sort(A,left,mid);
    Merge_sort(A,mid,right);
    Merge(A,left,mid,right);
  }
}

void Merge(Data *A,int left,int mid,int right){
  int n1,n2;
  Data *L,*R;
  int i,j,k;

  n1=mid-left;
  n2=right-mid;

  L=(Data*)malloc(sizeof(Data)*(n1+1));
  R=(Data*)malloc(sizeof(Data)*(n2+1));

  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];

  L[n1].num=SENTINEL;
  L[n1].suit=' ';
  R[n2].num=SENTINEL;
  R[n2].suit=' ';

  i=0;
  j=0;

  for(k=left;k<right;k++){
    if(L[i].num<=R[j].num){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
  }

  free(L);
  free(R);
}

Measured memory_bytes: 2772
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(),
            B = sc.nextInt(),
            C = sc.nextInt();
        if ((A < C && C < B) || (A > C && C > B)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
    
}


Measured memory_bytes: 21972
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        s: String,
    }

    println!("{}", if a >= 3200 { s } else { "red".to_string() });
}


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

int main(){
  long long N;
  cin >> N;
  long long A = 0;
  long long B = 0;
  long long C = 0;
  long long D = 0;
  string S;
  for (long long i = 0; i < N; i++){
    cin >> S;
    if (S == "AC"){A++;}
    if (S == "WA"){B++;}
    if (S == "TLE"){C++;}
    if (S == "RE"){D++;}
  }
  cout << "AC x ";
  cout << A << endl;
  cout << "WA x ";
  cout << B << endl;
  cout << "TLE x ";
  cout << C << endl;
  cout << "RE x ";
  cout << D << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    string S;
    cin >> S;
    REP(i, 4) cout << S[i];
    cout << " ";
    REP(i, 8) cout << S[i+4];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n = I()
    d = LI()
    m = I()
    t = LI()
    ddic = collections.Counter(d)
    tdic = collections.Counter(t)

    for i in tdic.keys():
        sub = max(0,tdic[i]-ddic.get(i,0))
        if sub > 0:
            print("NO")
            break
    else:
        print("YES")
main()

Measured memory_bytes: 159260
#include <stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	long long int sum =0;
	for(int i = 1 ;i<=N;i++){
		if(i%3==0 && i%5==0){
			sum +=0;
		}
		else if(i%3==0){
			sum += 0;
		}
		else if(i%5==0){
			sum+=0;
		}
		else {
			sum += i;
		}
	}
	printf("%lld",sum);
	
	return 0;
}

Measured memory_bytes: 1732
S=input()
total = []
count=[0,0,0]
mode='R'
for i in range(len(S)):
  if mode=='R' and S[i]=='R':
    count[1] += 1
  elif mode=='R' and S[i]=='L':
    count[0] += 1
    mode='L'
    count[2] = i-1
  elif mode=='L' and S[i]=='L':
    count[0] += 1
  elif mode=='L' and S[i]=='R':
    total.append(tuple(count))
    count = [0,1,0]
    mode = 'R'
total.append(tuple(count))

ans = [0]*len(S)
for l,r,idx in total:
  r1=(r+1)//2
  r2 = r - r1
  l1=(l+1)//2
  l2 = l - l1
  ans[idx] += r1 + l2
  ans[idx+1] += r2 + l1

print(*ans)

Measured memory_bytes: 15720
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

int h[100002];
int dp[100002];
int main(){
    FAST
    //Do awesome things here
    int n;
    cin >> n;
    rp(i, n){
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    fr(i, 2, n){
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
using namespace std;


ll gcd(ll a, ll b)   //Function to find gcd of two numbers
{
    if (a == 0)
    return b;
    return gcd(b % a, a);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    
    string str;
    cin>>str;
    
    int i=0 , j = n-1;
    
    int ans=0;
    
    while(1)
    {
        while(i<j && str[i]=='R')
        i++;
        
        while(i<j && str[j]=='W')
        j--;
        
        if(i==j)
        break;
        
        swap(str[i] , str[j]);
        
        ans++;
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3728
#!/usr/bin/env python3
import sys
import math
from functools import reduce
import operator
INF = float("inf")


def GCD(a, b):
    while b:
        a, b = b, a % b
    return a


def LCM(a, b):
    return a*b//GCD(a, b)


def solve(N: int, M: int, a: "List[int]"):

    # 各aを2で割れる回数(の２べき)
    K = set()
    for i, av in enumerate(a):
        K.add(av & -av)
    if len(K) != 1:
        print(0)
        return

    lcm = a[0]//2
    for av in a:
        lcm = LCM(lcm, av//2)

    ans = int(M/lcm)
    if ans > 0 and ans % 2 == 0:
        ans -= 1
    ans = (ans+1)//2

    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15876
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

def calc(lst, pos, pr):
    ret = []
    while pos < len(lst):
        if lst[pos] == '(':
            val, pos = calc(lst, pos + 1, pr)
            ret.append(val)
        elif lst[pos] == ')':
            pos += 1
            break
        else:
            ret.append(lst[pos])
            pos += 1
    lst = ret
    for p in pr:
        i = 0
        ret = []
        while i < len(lst):
            if lst[i] in p:
                ret[-1] = eval(str(ret[-1]) + lst[i] + str(lst[i + 1]))
                i += 2
            else:
                ret.append(lst[i])
                i += 1
        lst = ret
    return lst[0], pos

S = raw_input()

lst = []
ss = ''
for c in S:
    if c in ['+', '-', '*', '(', ')']:
        if ss != '':
            lst.append(int(ss))
        lst.append(c)
        ss = ''
    else:
        ss += c
if ss != '':
    lst.append(int(ss))

ans = -(10 ** 30)
for i, j, k in it.product([0, 1, 2], repeat = 3):
    pr = [[], [], []]
    pr[i].append('+')
    pr[j].append('-')
    pr[k].append('*')
    ans = max(ans, calc(lst, 0, pr)[0])

print ans


Measured memory_bytes: 5072
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int l,n;
    cin>>n>>l;
    vector<ll> arr(n+1);
    ll tot=0;
    for(int i=1;i<=n;++i)
    {
        arr[i]=l+i-1;
        tot+=arr[i];
    }

    ll diff=INT_MAX;
    ll nt=0;
    for(int i=1;i<=n;++i)
    {
        ll nn=tot-arr[i];
        if(diff>abs(tot-nn))
        {
            diff=min(diff,abs(tot-nn));
            nt=nn;
        }
    }

    cout<<nt;
    return 0;
}

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

#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ALL(c) c.begin(), c.end()
#define SZ(c) (int) c.size()
#define DBG1(x) cout<<#x<<" = "<<x<<"\n"
#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

using ll = long long;
using pii = pair<int,int>;

const ll MOD = 1'000'000'007;
const int MN = 1'000'000;

int main()
{
ios::sync_with_stdio(false);
#ifdef CP
    CP;
#endif
    int n;
    cin >> n;
    vector<vector<ll>> d(4, vector<ll>(n));
    int x,y;
    REP(i, 0, n){
        cin >> x >> y;
        d[0][i] = x + y;
        d[1][i] = x - y;
        d[2][i] = -x + y;
        d[3][i] = -x - y;
    }
    
    REP(i,0,4){
        sort(ALL(d[i]));
    }
    
    ll ans = numeric_limits<ll>::min();

    REP(i, 0, 4){
        ans = max(ans, d[i].back() - d[i].front());
    }

    cout << ans << endl;

}

Measured memory_bytes: 11100
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		s: usize,
	}

	if s < 3 {
		println!("0");
		return;
	}

	let mut v = vec![0usize; s+1];
	v[0] = 1;
	v[1] = 0;
	v[2] = 0;
	for i in 3..=s {
		v[i] = (v[i-1] + v[i-3]) % 1000000007;
	}
	println!("{}", v[s]);
}


Measured memory_bytes: 2204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
#define fs first
#define re resize
#define sc second
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,n) FOR(i,0,n-1)
#define ins insert
#define mod 1000000007
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define endl "\n"
void fastIO(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif   
}
ll modexpo(ll a , ll b){
    if(a==0)return 0;
    if(a==1 or b==0)return 1;
    if(b==1)return a;
    if(b&1) return (a%mod*modexpo(a,b-1)%mod)%mod;
    return modexpo(a%mod * a%mod  ,  b/2 ) % mod;
}
void printv(vll v){
    for(auto&x:v) {
        cout<<x<<" ";
    }
    cout<<endl;
}
string to_string1(ll x){stringstream ss; ss<<x; return ss.str();}
ll to_integer(string s){stringstream ss(s); ll x; ss>>x; return x;}
#define tp9 1000000000 
#define N 8000
ll  a, b,c,d;
void input(){
    cin >> a>> b >> c>> d;
} 
ld pi = 3.1415926535;
void printYes() {
    cout << "Yes\n";
}
void printNo() {
    cout << "No\n";
}
ll t , n , p ;
string s;
int main(){
    ll a,b; cin>>a>>b;
    cout<<a*b;
    return 0;
}




Measured memory_bytes: 3608
def shift_l(str)
  str[1..-1] + str[0]
end

def cycle(str)
  [str].tap { |xs| (str.size - 1).times { xs << shift_l(xs.last) } }
end

s = gets.strip
t = gets.strip
b = cycle(s).any? { |str| str == t }
puts b ? 'Yes' : 'No'


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    if(a+5*b+10*c+50*d+100*e+500*f >= 1000) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    
}



Measured memory_bytes: 3116
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 100100;
const int MOD = 1e9+7;
int cnt[MAXN]={0};

int solve(int N) {
	ll ans = 1;
	if (N % 2 == 1) {
		if (cnt[0] != 1) return 0;
		for (int i = 2; i < N; i += 2) {
			if (cnt[i] != 2) return 0;
			(ans *= 2) %= MOD;
		}
		return ans;
	} else {
		for (int i = 1; i < N; i+=2) {
			if (cnt[i] != 2) return 0;
			(ans *= 2) %= MOD;
		}
		return ans;
	}
}

int main(void) {
    int N;
    cin >> N;
    
    for (int i=0; i<N; i++ ){
        int a;
        cin >> a;
        cnt[a]++;
    }

    
    cout << solve(N) << endl;

}

Measured memory_bytes: 640
import math
a, b, C = map(float, input().split())
cs = math.radians(C)
c = math.sqrt((a**2+b**2)-2*a*b*math.cos(cs))
h = b*math.sin(cs)
m = (a+b+c)*0.5
S = (m*(m-a)*(m-b)*(m-c))**0.5
L = a+b+c
print(f"{S:.8f}")
print(f"{L:.8f}")
print(f"{h:.8f}")


Measured memory_bytes: 5724
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
vector<int>g[100005];
bool vis[100005];
ll dp[100005];

void dfs(int u){
	vis[u]=true;
	for(auto i:g[u]){
		if(!vis[i])
		dfs(i);
		dp[u]=max(dp[u],dp[i]+1);
	}
}
	
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	memset(vis,0,sizeof(vis));
	memset(dp,0,sizeof(dp));
	int n,m;
	cin>>n>>m;
	int u,v;
	for(int i=0;i<m;i++){
		cin>>u>>v;
		g[u].push_back(v);
	}
	for(int i=1;i<=n;i++){
		if(!vis[i])
		dfs(i);
	}
	cout<<*max_element(dp,dp+n+1);
	return 0;
}


Measured memory_bytes: 8704
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

ll n;

int main() {
	cin >> n;
	if (n & 1) {
		cout << 0 << endl;
		return 0;
	}
	
	ll ret = 0;
	ll five = 5;
	ll corr = 0;
	while (five <= n) {
		ret += n / five;
		if (n >= five) {
			corr += (n - five) / (2 * five) + 1;	
		}
		five *= 5;
	}
	//cerr << ret << " " << corr << endl;
	cout << ret - corr << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int a, b, w;
  cin>>w>>a>>b;
  cout<<max(0, abs(a-b)-w)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int A[20];
int n, mTemp;

int dfs(int i, int v){
  if (v == mTemp) return 1;
  if (i>=n || v > mTemp ) return 0;
  return dfs(i+1, v+A[i]) || dfs(i+1, v);
}

int main(){
  int q;

  scanf("%d", &n);
  for (int i=0;i<n;i++)
    scanf("%d", A+i);

  scanf("%d", &q);
  for (int i=0;i<q;i++){
    scanf("%d", &mTemp);
    printf("%s\n", dfs(0, 0)?"yes":"no");
  }
  return 0;
}


Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    int N, A, B;
    cin >> N >> A >> B;

    if (abs(A - B) % 2) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "A" + sS[1].Substring(0, 1) + "C";

            // 出力
            Console.WriteLine("{0}", sOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (n, k) = InputLine.to_ia

  puts n.to_s(k).length.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<pair<int, int>> vp(N);
    REP(i, N) {
        cin >> vp[i].first >> vp[i].second;
    }
    SORT(vp);
    REP(i, N) {
        K -= vp[i].second;
        if (K <= 0) {
            cout << vp[i].first << "\n";
            break;
        }
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vi a(n+1),b;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=n;i>=n/2+1;--i){
		if(a[i]==1)b.PB(i);
	}
	for(int i=n/2;i>=1;--i){
		int sum=0;
		for(int j=i*2;j<=n;j+=i){
			sum+=a[j];
		}
		if(a[i]!=sum%2){
			a[i]=1;
			b.PB(i);
		}
		else{
			a[i]=0;
		}
	}
    int m=b.size();
	cout<<m<<endl;
	rep(i,m){
		if(i!=b.size()-1)cout<<b[i]<<" ";
		else cout<<b[i]<<endl;
	}
}


Measured memory_bytes: 2424
h,w = map(int, input().split())

smap = []
for _ in range(h):
    s = input()
    ss = []
    for i in range(w):
        ss.append(s[i])
    smap.append(ss)
cmap = [[float('inf') for _ in range(w)] for _ in range(h)]
queue = [(0,0)]
l = [(1,0), (-1,0), (0,1), (0,-1)]

initial_whites = 0

for x in smap:
    for y in x:
        if y == '.':
            initial_whites += 1

cmap[0][0] = 0

while queue:
    v = queue.pop(0)
    smap[v[0]][v[1]] = '#'
    for x in l:
        y = (v[0]+x[0], v[1]+x[1])
        if 0 <= y[0] <= h-1 and 0 <= y[1] <= w-1:
            if smap[y[0]][y[1]] == '.':
                smap[y[0]][y[1]] = '#'
                cmap[y[0]][y[1]] = cmap[v[0]][v[1]] + 1
                queue.append(y)
            else:
                pass
        else:
            pass


if cmap[h-1][w-1] == float('inf'):
    print(-1)
else:
    print(initial_whites - cmap[h-1][w-1] - 1)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var S = ReadText();
            var T = ReadText();

            var min = long.MaxValue;
            for (int start = 0; start < S.Length - T.Length + 1; start++)
            {
                var count = 0L;
                for (int i = 0; i < T.Length; i++)
                {
                    if (S[start + i] != T[i]) count++;
                }
                min = Math.Min(min, count);
            }

            return min;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 25968
#include <cstdio>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

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

const int INF = 1001001001;
const double EPS = 1e-10;


template<typename T1,typename T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){
  return os << '(' << p.first <<',' << p.second << ')';
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& a){
  os << '[';
  rep(i,a.size()) os << (i ? " " : "") << a[i];
  return os << ']';
}

int main() {
  for(int N, M; cin >> N >> M, (N | M) != 0; ) {
    vector<pii> list;
    int ans = 0;
    rep(i, N) {
      int D, P; cin >> D >> P;
      list.emplace_back(P, D);
      ans += D * P;
    }
    sort(all(list));
    reverse(all(list));

    rep(i, N) {
      int D, P;
      tie(P, D) = list[i];
      ans -= P * min(M, D);
      M -= min(M, D);
    }

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

Measured memory_bytes: 1328
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s;cin >> s;
	long long  ans = 0, sum = 0, ret = 0;
	int i, j;

	for (i = 0; i < (1 << (s.size() - 1)); i++) {
		ret = s[0] - '0';
		sum = 0;

		for (j = 0; j < (s.size() - 1); j++) {
			if (i & (1 << j)) {
				sum += ret;
				ret = 0;
			}
			ret = ret * 10 + s[j + 1] - '0';
		}

		sum += ret;
		ans += sum;
	}
	cout << ans << endl;

}

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

int main() {
    int N;  cin >> N;
    vector<int> p(N + 1);
    for (int i = 1; i <= N; ++i) cin >> p[i];

    long long ans = 0;
    int conti = 0;
    for (int i = 1; i <= N + 1; ++i) {
        if (i <= N && p[i] == i) ++conti;
        else {
            if (conti <= 1) ans += conti;
            else ans += (conti + 1) / 2;
            conti = 0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    N, Ma, Mb = map(int, input().split())
    A = []
    a_sum = 1
    b_sum = 1
    for _ in range(N):
        a, b, c = map(int, input().split())
        A.append((a, b, c))
        a_sum += a
        b_sum += b

    DP = [[10**5 for _ in range(b_sum)] for _ in range(a_sum)]
    q = deque()
    for a, b, c in A:
        DP[a][b] = min(DP[a][b], c)

        q_ = deque()
        q_.append((a, b, c))
        while len(q) > 0:
            x, y, z = q.popleft()
            q_.append((x, y, z))

            s, t, u = x+a, y+b, z+c
            if DP[s][t] > u:
                DP[s][t] = u
                q_.append((s, t, u))

        q = q_

    n = min(a_sum // Ma, b_sum // Mb)
    ans = 10**5
    for i in range(1, n):
        x, y = Ma * i, Mb * i
        ans = min(ans, DP[x][y])

    if ans == 10**5:
        return -1
    else:
        return ans


if __name__ == '__main__':
    print(main())


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

int main(void){

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

    int a,b,c,d;

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

    for(;;){

                c -= b;
                //cout << c << endl;
        if(c<1){
            cout<<"Yes"<<endl;
             return 0;
        }

            a -= d;
             //cout << a << endl;
        if(a<1){
            cout<<"No"<<endl;
            return 0;
        }
        
    }


    return 0;
}

Measured memory_bytes: 3544
import Control.Monad
import Data.List

solve :: [(Integer,Integer)] -> Integer -> Integer -> Integer
solve [] _ _ = 0
solve ((a,b):xs) c m
  | c+b <= m = b*a + solve xs (c+b) m
  | c <= m && c+b > m = (m-c)*a + solve xs m m
  | otherwise = 0

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  dat <- sort <$> do
    replicateM n $ do
      [a,b] <- map read . words <$> getLine :: IO [Integer]
      return (a,b)

  print $ solve dat 0 (fromIntegral m)


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    int n, k; cin >> n >> k;
    vector<ll> num(k);
    // nまででkで割ってi%k個余る数の個数がnum[i%k]個
    REPS(i, 1, n) num[i%k]++;
    ll ans = 0;
    rep(a, k) {
        int b = (k - a) % k;
        int c = (k - a) % k;
        if ((b + c) % k != 0) continue;
        ans += num[a] * num[b] * num[c];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define int long long

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

signed main(){
    int n; cin >> n;
    
    int ans = 0;
    int i = 1;
    while(i*i<=n){
        ans = i*i;
        i++;
    }
    cout << ans << endl;
}






Measured memory_bytes: 256