akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)
 
int main(){
    int n,ans=0;
    scanf("%d",&n);
  int s[51];
  for(int i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  for(int i=0;i<n;i++){
    if(s[i]!=i+1){
      ans += 1;
    }
  }
  if(ans == 0 || ans == 2){
    printf("YES");
    return 0;
  }
  else
    printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,c;
    cin >> n >> c;
    int sum = 0;
    rep(i,c){
        int a;
        cin >> a;
        sum += a;
    }
    n++;
    cout << sum/n + (sum%n != 0) << endl;

}



Measured memory_bytes: 3072
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

const debug = false

func (p *problem) solve() {
	N := p.NextInt()
	points := p.NextInts()
	points = append(points, 0)

	var sum, prev int
	var costs []int
	for i := 0; i <= N; i++ {
		c := abs(prev - points[i])
		sum += c
		costs = append(costs, c)
		prev = points[i]
	}

	//log.Printf("sum:%d\npoints:%v\ncosts:%v\n", sum, points, costs)
	prev = 0
	for i := 0; i < N; i++ {
		pc := costs[i] + costs[i+1]
		sc := abs(prev - points[i+1])
		r := sum - (pc - sc)
		p.Printf("%d\n", r)
		//log.Printf("pc:%d, sc:%d, result:%d\n", pc, sc, r)
		prev = points[i]
	}
}

func abs(x int) int {
	if x < 0 {
		return x * -1
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	if debug {
		log.SetOutput(os.Stdout)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


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

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;
const int MAX_N = 1e5 + 5;

int N;
int points[MAX_N][3], dp[MAX_N][3];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> points[i][0] >> points[i][1] >> points[i][2];
	}

	dp[0][0] = points[0][0], dp[0][1] = points[0][1], dp[0][2] = points[0][2];
	for (int i = 1; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (k != j) dp[i][j] = max(dp[i][j], dp[i - 1][k] + points[i][j]);
			}
		}
	}

	cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << '\n';

	return 0;
}

Measured memory_bytes: 2560
#include<cstdio>

int N, X, T;

int main(){

    int ans = 0;
    
    scanf("%d %d %d", &N, &X, &T);

    if(N % X == 0){
        ans = N/X*T;
    }
    else{
        ans = (N / X + 1)*T;
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 1712
#include <iostream>
using namespace std;
int main() {
    int tmp = 0;
    string S;
    cin >> S;
    if(S[0] == S[1]) tmp++;
    if(S[1] == S[2]) tmp++;
    if(S[2] == S[3]) tmp++;
    if(0 < tmp) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC152B - Comparing Strings

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        String sa = "";
        String sb = "";

        for (int i = 0; i < b; i++) {
            sa += a;
        }

        for (int i = 0; i < a; i++) {
            sb += b;
        }

//        System.out.println((sa.compareTo(sb) == -1) ? sa : sb);
        System.out.println((a < b) ? sa : sb);
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define MAX 100001
int main()
{
	string s;
	int a[MAX],k,n,maxs=0;
	cin >> n >> k;
	cin >> s;
	int b = 0;
	memset(a, 0, MAX * sizeof(int));
	a[0] = 1;
	for (int i = 1; i < n; i++)
	{
		if (s[i] == s[i-1])
		{
			a[b]++;
		}
		else
		{
			a[++b]++;
		}
	}
	int d = (s[0] == '1') ? 1 : 0;
	int sum = 0;
	b++;
	if (d == 1)
		k = min(k, b / 2);
	else
		if (b % 2)
			k = min(k, (b + 1) / 2);
		else
			k = min(k, b / 2);
	int i = 0, e = k;
	while (e&&i<b)
	{
		sum += a[i++];
		if ((i - d-1) % 2 == 0)
			e--;
	}
	if (i < b)
		sum += a[i++];
	maxs = max(maxs, sum);
	while (i < b)
	{
		if (d)
		{
			sum = sum-a[i - 2*k-1]-a[i-2*k]+a[i];
			i++; 
          if(i<b)
          {sum += a[i]; i++;}
			maxs = max(maxs, sum);
		}
		else if (!d)
		{
			sum = sum - a[i - 2*k] + a[i];
			i++;
			if (i < b)
			{
				sum += a[i];
				i++;
			}
			d = 1;
			maxs = max(maxs, sum);
		}
	}
	cout << maxs;
	return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0049
{
    public class Program

    {
        public static void Main(string[] args)
        {
            Dictionary<string, int> bloodTypeCnt = new Dictionary<string, int>() { { "A", 0 }, { "B", 0 }, { "AB", 0 }, { "O", 0 } };
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) break;
                bloodTypeCnt[line.Trim().Split(',')[1]]++;
            }
            foreach (var item in bloodTypeCnt) Console.WriteLine(item.Value);
        }
    }

}



Measured memory_bytes: 15888
/*
    author:  Maksim1744
    created: 18.01.2020 15:05:18
*/

#include <bits/stdc++.h>

using namespace std;

#define ll   long long
#define ld   long double

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T>& v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T>& v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T>& v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>& v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>& p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define TAG_LENGTH       25
#define LR_LEFT          left
#define LR_RIGHT         right
#define LR_VALUE         value
#define LR_SECOND_VALUE  mn
#include "C:/C++ libs/print.cpp"
#else
#define showl            42;
#define shows            42;
#define show(...)        42;
#define showm(...)       42;
#define showt(...)       42;
#define printTree(...)   42;
#define printGraph(...)  42;
#define printLRTree(...) 42;
#define printMatrix(...) 42;
#define printWGraph(...) 42;
#define debug     if (false)
#endif

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int h, w, n;
    cin >> h >> w >> n;
    int cnt = 0;
    while (n > 0) {
        if (h < w) swap(h, w);
        n -= h;
        --w;
        ++cnt;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import math

j = list(map(int, input().split()))
n = j[0]
a = j[1]
b = j[2]
if (n < a + b - 1) or (n > a * b):
    print(-1)
    exit(0)

ans = list(range(b, 0, -1))
if (n > b):
    counter = len(ans)
    loopcounter = 1
    #sikii = math.ceil((n-b) / (a-1))
    sikii = b
    yoyuu = n - a -b+1
    while (counter < n):
        if (yoyuu >= sikii):
            ans += list(range(counter + sikii, counter, -1))
            yoyuu -= (sikii - 1)
        elif (yoyuu == 0):
            ans += [counter + 1]
        else:
            ans += list(range(counter + yoyuu + 1, counter, -1))
            yoyuu = 0
        loopcounter += 1
        counter = len(ans)

print(' '.join(map(str, ans)))


Measured memory_bytes: 36004
#include <bits/stdc++.h>
using namespace std;
int n, k;
int mod=1000000007;
//int a[n+1];
long long dp[100001][3];
void solve(int s, int visited[], vector<vector<int>> &v)
{  // cout<<s<<" ";
    dp[s][0] = 1;
    dp[s][1] = 1; 
    visited[s]=1;
    if(v[s].size()==1 && visited[*v[s].begin()]==1) {return;}
    
    for(auto x:v[s])
    {   if(!visited[x]) solve(x,visited, v);
        else continue;
       // cout<<s<<" "<<x<<" ";
        dp[s][0] = (dp[s][0]*(dp[x][0]+dp[x][1])%mod)%mod;
        dp[s][1] = (dp[s][1]*dp[x][0])%mod;
    }    
    
}

int main()
{   
 cin>>n;
 vector<vector<int>> v(n+1);
 int x,y;
 int visited[n+1]={0};
 for(int i=1;i<n;++i)
    {cin>>x>>y; v[x].push_back(y);v[y].push_back(x);}
//for(int i=1;i<=n;++i)
//if(!visited[i])solve(i,visited,v);cout<<dp[1][0]+dp[1][1]; 
solve(1,visited,v);
 
cout<<(dp[1][0]+dp[1][1])%mod; 
 /*for(int i=1;i<=n;++i) 
 {   
     for(int j=0;j<=1;++j)
 
     cout<<dp[i][j]<<" ";
     cout<<endl;
     

}*/

}


Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)
ll modi = 1000000007;

bool cp(ll n){
    if(n == 1)return false;
    else if(n == 2)return true;
    else if(n ==3)return true;
    for(int i  = 2; i*i<=n; i++){
        if(n%i == 0){
            return false;
        }
    }
    return true;
}
void SforPrime(int n)
{
	bool prime[n+1];
	memset(prime, true, sizeof(prime));

	for (int p=2; p*p<=n; p++)
	{
		if (prime[p] == true)
		{
			for (int i=p*p; i<=n; i += p)
				prime[i] = false;
		}
	}
}
ll calPower(ll val, ll n){
    ll i = 1;
    ll ind = 1;
    ll prev = val;
    while(val<=n){
        if(n%val == 0)ind = i;
        val  = val*prev;
        i++;
    }
    return i-1;
}
int main(){
    //130016239756757
    ll n, l;
    cin>>n>>l;
    string arr[n];
    for(int i = 0; i<n; i++){
        cin>>arr[i];
    }
    sort(arr, arr+n);
    for(int i = 0; i<n; i++){
        cout<<arr[i];
    }
}

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

using namespace std;

const int N = 1234567;

int t[N];

int main() {
  int n, c, k;
  scanf("%d %d %d", &n, &c, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", t + i);
  }
  sort(t, t + n);
  int cnt = 0, bus = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (t[i] <= bus && cnt < c) {
      cnt++;
    } else {
      bus = t[i] + k;
      cnt = 1;
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<long long>a(n);
    rep(i,n) cin>>a.at(i);
    long long ans=1;
    rep(i,n){
        if(ans<=1000000000000000000/a.at(i)) ans*=a.at(i);
        else{
            ans=-1;
            break;
        }
    }
    rep(i,n){
        if(a.at(i)==0) ans=0;
    }
    cout<<ans;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
//#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n;cin>>n;
    vi v(n);cin>>v;
    int yes=1;
    for(int &i:v){
        if(i&1)i=0;
        if(i%3==0 || i%5==0){
            
        }else yes=0;
    }
    if(yes){
        cout<<"APPROVED";
    }else cout<<"DENIED";
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (3000 + 2)
ld p[MAX_N];
ld dp[MAX_N][2];

void exec(){
  int n;
  int now = 0, prev = 1;
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> p[i];
  }

  dp[0][now] = 1;
  for (int i = 0; i < n; i++){
    swap(now, prev);
    for (int j = 0; j <= n; j++){
        dp[j][now] = 0;
    }
    for (int j = 0; j <= n; j++){
      if (dp[j][prev] > 0){
        dp[j][now] += dp[j][prev] * (1 - p[i]);
        dp[j + 1][now] += dp[j][prev] * p[i];
      }
    }
  }

  ld ans = 0;
  for (int i = n / 2 + 1; i <= n; i++){
    ans += dp[i][now];
  }

  printf("%.12Lf\n", ans);

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

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


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

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		int temp=s[i]-'A'+n;
		//cout<<temp<<endl;
		if(temp>=26) 
		{
			temp%=26;
		}
		s[i]=(char)(temp+'A');
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int x,y,a,b,c;
    cin >> x >> y;
    if(x > y){
        a = x%y;
        b = y;
    }
    else if(y > x){
        a = y%x;
        b = x;
    }
    else if(x == y){
        a = x;
        b = y;
    }
    
    for(int i = 0;i<a;i++){
        c = a-i;
        if(a%c == 0){
            if(b%c == 0){
                break;
            }
        }
    }
    
    cout << c << endl;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
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;

ll n;
int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = a * c;
    ans = ans < a * d ? a * d : ans;
    ans = ans < b * c ? b * c : ans;
    ans = ans < b * d ? b * d : ans;

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


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

int main() {
	int n, ans;
	string s;
	
	scanf("%d", &n);
	cin >> s;
	ans = 0;

	for (int i = 1; i < n; ++i) {
		vector<int>v1(26);
		vector<int>v2(26);
		int ans2 = 0;
		for (int j = 0; j < i; ++j) {
			v1[(int)s[j] - (int)'a'] += 1;
		}
		for (int j = i; j < n; ++j) {
			v2[(int)s[j] - (int)'a'] += 1;
		}
		for (int j = 0; j < 26; ++j) {
			if (v1[j] != 0 && v2[j] != 0) {
				ans2 += 1;
			}
		}
		ans = max(ans, ans2);
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');

  (function(x) {
    // ????????????????????????
   console.log(Math.pow(x,3))

  })(parseInt(inputs[0], 10)); // ??°?????????

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15760
//注意:代码模板中的代码将会被复制到任何新创建的文件中，编辑代码模板中的代码，让他帮你自动增加固定代码吧
#include <iostream> 
using namespace std;
int main(){
    int n;
    cin>>n;
    int x=n*800,y=(n/15)*200;
    cout<<x-y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int input, output;
    int base = 111;
    int i;
 
    // 数字の入力
    scanf("%d", &input);
    
    for(i = 1; i < 10; i++)
    {
        if( input <= (base * i) )
        {
            output = base * i;
            break;
        }
        
    }
    
    // 出力
    printf("%d\n",output);
    return 0;
}

Measured memory_bytes: 128
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
int main(){
//  cout<<fixed<<setprecision(1)<<1<<endl;
//system("cls");
	int n;
	cin>>n;
	int a=0,w=0,t=0,r=0;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(s=="AC")a++;
		if(s=="WA")w++;
		if(s=="TLE")t++;
		if(s=="RE")r++; 
	}
	cout<<"AC"<<" x "<<a<<endl;
	cout<<"WA"<<" x "<<w<<endl;
	cout<<"TLE"<<" x "<<t<<endl;
	cout<<"RE"<<" x "<<r<<endl;
	return 0;
}

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

#define F first
#define S second
#define pb push_back
#define mp make_pair

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

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n,i,j,sum = 1000 ,stocks = 0;

	cin >> n;
	ll a[n];
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}

	for(i=0;i<n-1;i++)
	{
		if(a[i] < a[i+1])
		{
			ll x = sum/a[i];
			stocks += x;

			sum -= a[i]*x;
		}
		else if(a[i] > a[i-1])
		{
			sum += stocks*a[i];
			stocks = 0;
		}
	}

	if(stocks > 0)
		sum += stocks*a[n-1];

	cout << sum << endl;

	
}

Measured memory_bytes: 3640
import java.util.*;

class Main{
    public static void main( String[] args ) {
	Scanner sc = new Scanner(System.in);
	int num[] = new int[4];
	for ( int i = 0; i < 4; i++ ) {
	    num[i] = sc.nextInt();
	}
	boolean f1 = false,f2 = false,f3 = false,f4 = false;
	for ( int i = 0; i < 4; i++ ) {
	    if ( num[i] == 1 ) f1 = true;
	    else if ( num[i] == 9 ) f2 = true;
	    else if ( num[i] == 7 ) f3 = true;
	    else if ( num[i] == 4 ) f4 = true;
	}

	if ( f1 && f2 && f3 && f4 ) System.out.println("YES");
	else System.out.println("NO");
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
 
	
	ll N;
	cin >> N;
	ll an = N;
	
	for (ll i = 0; i <=N; i++) {
		ll k = i,m=0;
		while (k > 0) {
			m += k % 6;
			k /= 6;
		}
		k = N - i;
		while (k > 0) {
			m += k % 9;
			k /= 9;
		}
		an = min(an, m);
	}
	
	
	cout <<an<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;

int main(){
    cin>>a>>b>>c;
    if(a-b==0){
        cout<<c;
    }
    else if(a-c==0){
        cout<<b;
    }
    else{
        cout<<a;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re register
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 2e5+7;
/*
int head[M],cnt=1;
void init(int n){cnt=1;for(int i=0;i<=n;i++)head[i]=0;}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
int x[M],y[M];
int p[4][M];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n;
  	cin>>n;
  	for(int i=1;i<=n;i++)
  	{
  		cin>>x[i]>>y[i];
  		p[0][i]=x[i]+y[i];
  		p[1][i]=-x[i]+y[i];
  		p[2][i]=x[i]-y[i];
  		p[3][i]=-x[i]-y[i];
	}
	for(int i=0;i<4;i++)sort(p[i]+1,p[i]+1+n);
	int mx=0;
	for(int i=0;i<4;i++)
	{
		mx=max(mx,p[i][n]-p[i][1]);
		//cout<<i<<"  "<<p[i][n]<<"  "<<p[i][1]<<endl;
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 8288
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    cout.precision(10);
    int two, one, zero;
    int n, m, d;
    cin >> n >> m >> d;
    zero = max(2 * d - n, 0);
    zero = min(zero, n);
    two = max(0, n - 2 * d);
    two = min(two, n);
    one = n - zero - two;
    if(d == 0){
        zero = 0;
        two = 0;
        one = n;
    }
    //cout << zero << " " << one << " " << two << endl;
    cout << ((double)two * 2.0 + (double)one) * (double)(m - 1)  / (double)n / (double)n << endl;
    return 0;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    s=STR()
    ans=0
    temp=0
    for i in s:
        if i=='R':
            temp+=1
            ans=max(temp,ans)
        else:
            temp=0
    print(ans)
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 9056
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#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 f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		ll l,r,d;
		cin>>l>>r>>d;
		ll count = 0;
		for(ll i=l; i<=r; i++) {
			if(i%d == 0) {
				count++;
			}
		}		
		cout<<count<<endl;

		return 0;
	}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,N;
    cin >> a >> b ;
    cin >> N;
    int s[N],f[N];
    for (int i=0; i<N; i++){
        cin >> s[i] >> f[i];
    }
    bool tyohuku=false;
    for (int i=0; i<N; i++){
        if(b>s[i] && f[i]>a){
            tyohuku=true;
        }
    }
    if(tyohuku){
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3132
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(a, b, c) {
    // ????????????????????????
    var result = a < b ? (b < c ? 'Yes' : 'No') : 'No';
    console.log(result);

  }(params[0], params[1], params[2]));

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15492
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template<typename T>
T extgcd(T a, T b, T &x ,T &y){
    for (T u = y = 1, v = x = 0; a; ) {
        ll q = b/a;
        swap(x -= q*u, u);
        swap(y -= q*v, v);
        swap(b -= q*a, a);
    }
    return b;
}

template<typename T>
T mod_inv(T x, T m){
    T s, t;
    extgcd(x, m, s, t);
    return (m+s)% m;
}

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};
template <class T> class Factorial {
    T mod;
    vector<uint64_t> facts, factinv;

public:
    Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
        facts[0] = 1;
        for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
        factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
        for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
    }

    T fact(int k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T operator[](const int &k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T C(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
    }

    T P(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>((facts[p] * factinv[p-q]) % mod);
    }

    T H(int p, int q) const {
        if(p < 0 || q < 0) return 0;
        return static_cast<T>(q == 0 ? 1 : C(p+q-1, q));
    }
};


int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &&i : v) scanf("%lld", &i);
    Factorial<ll> fa(n, MOD);
    vector<int> s(n+1, 0);
    for (int i = 1; i <= n; ++i) {
        s[i] = (s[i-1]+mod_inv(i+1, MOD)) % MOD;

    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        (ans += ((v[i]*(1+ s[n-i-1]+s[i]))%MOD * fa[n])) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<ll,int> P;

int main(){
    int n,m;
    cin >> n >> m;
    vector<P> p(n);
    rep(i,n)cin >> p[i].first >> p[i].second;
    sort(p.begin(),p.end());
    int i = 0;
    ll ans=0;
    while(m>0){
        if(p[i].second>0){
            --m;
            --p[i].second;
            ans+= p[i].first;
        }else ++i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);

int main() {
	vi n(10);
	REP(i, 10) {
		cin >> n[i];
	}
	sort(RALL(n));
	REP(i, 3) {
		cout << n[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
main(){
  int N;
  cin>>N;
  vector<int>xs(N);
  for(auto&x:xs)cin>>x;
  for(int i=1;i<N;++i)xs[i]+=xs[i-1];
  cout<<xs.back()-N<<endl;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  h,w,a,b = readline() |> split |> parseArray

  ans=falses((h,w))
  ans[1:b,1:a]=true
  ans[b+1:h,a+1:w]=true

  for i in 1:h, j in 1:w
    print(ans[i,j]?1:0)
    j==w && println()
  end
end

main()


Measured memory_bytes: 174604
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,k,a[105],dp[1 << 17];

int32_t main(){_
    //freopen("in","r",stdin);
	cin >> n >> k;
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int val = 0;val <= k;val++)
	{
		for(int i = 1;i <= n;i++)
		{
			if(a[i] > val) break;
			if(dp[val - a[i]] == 0) dp[val] = 1;
		}
	}	
	if(!dp[k]) rc("Second");
	rc("First");
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    ll n, c, k; cin >> n >> c >> k;

    V<ll> t(n);
    for(int i = 0; i < n; i++) cin >> t[i];
    sort(ALL(t));

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll cnt = 0;
        ll p = i;
        for(int j = i; j < n; j++){
            if(t[p] <= t[j] && t[j] <= t[p] + k && cnt < c){
                cnt++;
                i = j;
            }else{
                break;
            }
        }
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4028
# N = input()   # 単純な入力
# input = list(input()) # ひとかたまりの文字列をリスト化
N = int(input())  # 整数一つ
# input = input().split()   # スペース区切りを文字としてリスト化
# X,Y = map(int,input().split())  # ２個や３個の整数をそれぞれ取得
# input = list(map(int,input().split()))

cnt = 0
if N == 1:
    print(4)
elif N ==2:
    print(4)
else:
    while N !=1:
        if N%2==0:
            N = N//2
        else:
            N =3*N+1
        cnt += 1
    print(cnt+2)

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

using namespace std;

struct Edge {
    int u, v, i;
    Edge() {}
    Edge(int u, int v, int i): u(u), v(v), i(i) {}
    Edge reverse() {
        return Edge(v, u, i);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<Edge>> adj_list(n);
    vector<int> degrees(n);
    for (int i = 0; i < n-1; ++i) {
        Edge e;
        e.i = i;
        cin >> e.u >> e.v;
        --e.u;
        --e.v;
        adj_list[e.u].push_back(e);
        adj_list[e.v].push_back(e.reverse());
        ++degrees[e.u];
        ++degrees[e.v];
    }
    vector<int> colors(n-1, -1);
    int k = *max_element(degrees.begin(), degrees.end());
    function<void (int, int, int)> give_colors = [&](int i, int from, int from_color) {
        int current_color = 0;
        for (auto e : adj_list[i]) {
            if (e.v == from) {
                continue;
            }
            if (current_color == from_color) {
                ++current_color;
            }
            colors[e.i] = current_color;
            give_colors(e.v, i, current_color);
            ++current_color;
        }
    };
    give_colors(0, -1, -1);
    cout << k << endl;
    for (auto color : colors) {
        cout << (color + 1) << "\n";
    }
    return 0;
}


Measured memory_bytes: 9472
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [n, a, b] = input.trim().split(" ").map(Number);
  return n * a < b ? n * a : b;
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29564
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sst stringstream
#define sz size()
#define vc vector
typedef vc<int> vi;
typedef vc<ll> vl;
typedef vc<string> vs;

int H,W,N;
char s[1000010],c[1010][1010];
int sy,sx,gy,gx;
int dir[1000010],cost[1000010][4],dist[1010][1010];
int dy[]={0,1,0,-1};
int dx[]={1,0,-1,0};

typedef pair<int,pi> T;

int main(){
	while(cin>>H>>W>>N && H){
		rep(i,N)cin>>s[i];
		rep(i,H+2)rep(j,W+2)c[i][j]='#';
		rep2(i,1,H+1)rep2(j,1,W+1){
			cin>>c[i][j];
			if(c[i][j]=='S')sy=i,sx=j,c[i][j]='.';
			if(c[i][j]=='G')gy=i,gx=j,c[i][j]='.';
		}
		
		dir[0]=3;
		rep(i,N){
			if(s[i]=='L')dir[i+1]=(dir[i]+3)%4;
			else dir[i+1]=(dir[i]+1)%4;
		}
		for(int i=N;i>=0;i--){
			rep(j,4){
				if(j==dir[i])cost[i][j]=0;
				else{
					if(i==N)cost[i][j]=INF;
					else cost[i][j]=cost[i+1][j]+1;
				}
			}
		}
		
		rep(i,H+2)rep(j,W+2)dist[i][j]=INF;
		dist[sy][sx]=0;
		priority_queue<T,vector<T>,greater<T> > Q;
		Q.push(T(0,pi(sy,sx)));
		while(Q.sz){
			T is=Q.top();
			Q.pop();
			int dis=is.fir;
			pi st=is.sec;
			if(dist[st.fir][st.sec] < dis)continue;
			if(st.fir==gy && st.sec==gx){
				cout<<"Yes"<<endl;
				goto end;
			}
			
			rep(i,4){
				int ny=st.fir+dy[i],nx=st.sec+dx[i];
				if(c[ny][nx]=='#')continue;
				if(dis + cost[dis][i] < dist[ny][nx]){
					dist[ny][nx] = dis + cost[dis][i];
					Q.push(T(dist[ny][nx],pi(ny,nx)));
				}
			}
		}
		cout<<"No"<<endl;
		end:;
	}
}

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

int main(){
    int N=0,M=0;
    cin >> N >> M;
    int low=0,high=100000;
    for(int i=0,l,r;i<M;++i){
        l=0,r=0;
        cin >> l >> r;
        low = max(low, l);
        high = min(high,r);
    }
    cout << (high-low>=0?high-low+1:0) << endl;
}


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

int main() {
  int r;
  int D;
  int x;
  cin >> r >> D >> x;
  int N=1;
  while (N<=10)
  { int y;
   y=r*x-D;
   cout << y << endl;
   x=y;
   N++;
  }
}

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

int main(){
  string s;
  cin>>s;
  if(s[s.size()-1]=='s')s+="es";
  else s+="s";
  cout<<s<<endl;
}

Measured memory_bytes: 3628
import java.io.PrintWriter

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    var (n,d)=listOfInt()
    var pts = mutableListOf<List<Long>>()
    repeat(n) {
        pts.add(readLine()!!.split(" ").map { it.toLong() })
    }
    var sqs = mutableSetOf<Long>()
    repeat(1000000) {
        sqs.add(it.toLong() * it)
    }
    var re=0
    repeat(n){ i ->
        repeat(i){ j ->
            var sum = 0L
            repeat(d) { k ->
                var tmp = pts[i][k] - pts[j][k]
                sum += tmp * tmp
            }
            if(sqs.contains(sum)) ++re
        }
    }
    pw.println(re)
    pw.flush()
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }
fun listOfLong() = listOfString().map { it.toLong() }
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 141272
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
const in mdl=1000000007LL;
in p2(in a){
  return (1LL<<a);
}
in pw(in a, in b, in lm=62){
  a%=mdl;
  if(a<0)
    a+=mdl;
  in r=1;
  for(in i=lm;i>=0;--i){
    r=r*r%mdl;
    if(b&p2(i))
      r=r*a%mdl;
  }
  return r;
}
in inv(in a){
  a%=mdl;
  if(a<0)
    a+=mdl;
  assert(a!=0);
  return pw(a,mdl-2,30);
}
VI fc,invfc;
in ncr(in a, in b){
  if(b==0 || b==a)
    return 1;//even if a<0
  if(b<0 || b>a)
    return 0;
  return fc[a]*invfc[b]%mdl*invfc[a-b]%mdl;
}
void inifc(){
  const in mxfc=1001000;
  fc.resize(mxfc);
  invfc.resize(mxfc);
  fc[0]=fc[1]=invfc[0]=invfc[1]=1;
  for(in i=2;i<mxfc;++i){
    fc[i]=fc[i-1]*i%mdl;
    invfc[i]=invfc[mdl%i]*(mdl-mdl/i)%mdl;
  }
  for(in i=2;i<mxfc;++i){
    invfc[i]*=invfc[i-1];
    invfc[i]%=mdl;
  }
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  inifc();
  in h,w,a,b;
  cin>>h>>w>>a>>b;
  in sm=0;
  for(in i=0;i<h-a;++i){
    sm+=ncr(i+b-1,i)*ncr(w-b-1+h-i-1,h-i-1)%mdl;
  }
  sm%=mdl;
  cout<<sm<<endl;
  return 0;
}


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

#define all(x) x.begin(),x.end()
#define LB(V,x) lower_bound(all(V),x)-V.begin()

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using pi = pair<int32, int32>;
using pll = pair<int64, int64>;
using vi = vector<int32>;
using vll = vector<int64>;
using ll = int64;

void Main(){
    int A, B, Q;
    cin >> A >> B >> Q;
    vll S(A), T(B), X(Q);
    for(auto &s:S) cin >> s;
    for(auto &t:T) cin >> t;
    while(Q--){
        ll x, ans=1LL<<62;
        cin >> x;
        int sr = LB(S,x);
        int sl = sr-1;
        int tr = LB(T,x);
        int tl = tr-1;
        if(sr<A){
            if(tr<B) ans = min(ans,min(S[sr]-x,T[tr]-x)+abs(S[sr]-T[tr]));
            if(tl>=0) ans = min(ans,min(S[sr]-x,x-T[tl])+abs(S[sr]-T[tl]));
        }
        if(sl>=0){
            if(tr<B) ans = min(ans,min(x-S[sl],T[tr]-x)+abs(S[sl]-T[tr]));
            if(tl>=0) ans = min(ans,min(x-S[sl],x-T[tl])+abs(S[sl]-T[tl]));
        }
        cout << ans << endl;
    }
}

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

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

int main() {
  long long num,hissatu;
  long long cnt = 0;
  bool chk = true;
  
  cin >> num >> hissatu;
  vector<int> vec(num);
  for(int i = 0; i < num; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  long long size = -1;
  if(vec.size() > hissatu) size = vec.size() - hissatu;
  for(int i = 0; i < size; i++){
    cnt += vec.at(i);
  }
  
  cout << cnt;
}


Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
int main(){
	ll W, H, x, y; cin >> W >> H >> x >> y;

	ld cx = W / 2.0, cy = H / 2.0;

	cout << fixed << setprecision(15) << W * H / 2.0 << " ";

	if(x == cx && y == cy) cout << 1 << endl;
	else cout << 0 << endl;


	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int answer = 0;
  
  for(int i = 0; i<S.size(); i++){
    if(S.at(i) == '1'){
      answer++;
    }
    else if(S.at(i) == '0'){
      continue;
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
n = int(input())
stone = list(input())
l = 0
r = n-1
ans = 0
while l < r:
    if stone[l]=='W':
        if stone[r]=='R':
            ans += 1
            l += 1
            r -= 1
        else:
            r -= 1
    else:
        l += 1
        if stone[r]=='W':
            r -= 1
print(ans)

Measured memory_bytes: 10784
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n , r;
	cin >> n >>r;
	if( n >= 10) cout <<r;
	else cout << r + 100 * (10 - n );
}

Measured memory_bytes: 3664
#include<iostream>
using namespace std;
int main(){
	int h,w;
	while (true){
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				int a;
				a = (i + j) % 2;
				if (a == 0){
					cout << "#";
				}
				else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
from pprint import pprint
import numpy as np
import numba as nb
@nb.njit
def Knapsack1(n,w,wl,vl):
  dp = np.zeros(shape=(n + 1, w + 1), dtype=np.int64)
  for wsum in range(1,w+1):
  	#print("i={}".format(i))    
    for i in range(n):
      #print("重さ：{}".format(wsum))
      if wsum >= wl[i]:
        if dp[i][wsum] < dp[i][wsum-wl[i]]+vl[i]:
          #print("選ぶ, (重さ：{}, 価値：{})".format(wv[i][0], wv[i][1]))
          dp[i+1][wsum] = dp[i][wsum-wl[i]]+vl[i]
        else:
          dp[i+1][wsum] = dp[i][wsum]
          
      else:
        dp[i+1][wsum] = dp[i][wsum]
  #print(dp)
  print(dp[-1][-1])

n,w=map(int, input().split())
wv=[list(map(int,input().split()))  for i in  range(n)]
wv.sort(key=lambda x:(x[1],x[0]))
wv=np.array(wv)
wv=wv.T
wl=wv[0]
vl=wv[1]
#print(wl)
#print(vl)
Knapsack1(n,w,wl,vl)


Measured memory_bytes: 191400
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    if(N <= K) cout << 1 << endl;
    else cout << (N - 1 + K - 1 - 1) / (K - 1) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 123;
int n, a[N], q, cnt[N];
ll s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
		s += a[i];
	}
	cin >> q;
	while (q--) {
		int b, c;
		cin >> b >> c;
		s += (c - b) * cnt[b];
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << s << '\n';
	}
}


Measured memory_bytes: 4436