akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

class Dice{
    public:
    int face[6];
    Dice(){}
    void roll_x(){ roll(0,1,5,4);}
    void roll_y(){ roll(0,2,5,3);}
    void roll(int i,int j,int k,int l){
        int n = face[i]; face[i] = face[j]; face[j] = face[k]; face[k] = face[l]; face[l] = n;
    }
    void move(char ch){
        if (ch == 'N') roll_x();
        if (ch == 'W') roll_y();
        if (ch == 'S') for (int i = 0;i < 3;i++) roll_x();
        if (ch == 'E') for (int i = 0;i < 3;i++) roll_y();
    }
};
int main(){
    Dice one;
    string s;
    for (int i = 0;i < 6;i++) cin >> one.face[i];
    cin >> s;
    for (int i = 0;i < s.size();i++) one.move(s[i]);
    cout << one.face[0] << endl;
    return 0;
}


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

int main() {
	vector<int>	vec(6);
	rep(i, 6)
		cin >> vec.at(i);
	string	S;
	cin >> S;
	rep(i, S.size())
	{
		int	temp;
		if (S.at(i) == 'N')
		{
			temp = vec.at(0);
			vec.at(0) = vec.at(1);
			vec.at(1) = vec.at(5);
			vec.at(5) = vec.at(4);
			vec.at(4) = temp;
		}
		else if (S.at(i) == 'S')
		{
			temp = vec.at(0);
			vec.at(0) = vec.at(4);
			vec.at(4) = vec.at(5);
			vec.at(5) = vec.at(1);
			vec.at(1) = temp;
		}
		else if (S.at(i) == 'W')
		{
			temp = vec.at(0);
			vec.at(0) = vec.at(2);
			vec.at(2) = vec.at(5);
			vec.at(5) = vec.at(3);
			vec.at(3) = temp;
		}
		else
		{
			temp = vec.at(0);
			vec.at(0) = vec.at(3);
			vec.at(3) = vec.at(5);
			vec.at(5) = vec.at(2);
			vec.at(2) = temp;
		}
	}
	cout << vec.at(0) << endl;
}



Measured memory_bytes: 3172
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
  string s;
  cin >> s;
  if(s[1] == 'B')s[1] = 'R';
  else s[1] = 'B';
  cout << s << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int H, W, K;
	cin >> H >> W >> K;

	static bool isBlack[6][6];
	for(int y = 0; y < H; y++) {
		for(int x = 0; x < W; x++) {
			char c;
			cin >> c;
			isBlack[y][x] = (c == '#');
		}
	}

	int result = 0;
	for(int wf = 0; wf < (1 << W); wf++) {
		for(int hf = 0; hf < (1 << H); hf++) {
			int counter = 0;
			for(int y = 0; y < H; y++) {
				for(int x = 0; x < W; x++) {
					if(wf & (1 << x) || hf & (1 << y)) {
						continue;
					}

					if(isBlack[y][x]) {
						counter++;
					}
				}
			}
			if(counter == K) {
				result++;
			}
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 3628
from collections import defaultdict

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    
    for m in range(M):
        b, c = map(int, input().split())
        d[c] += b
        
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)

    ans = 0
    for k, v in d:
        ans += min(N, v) * k
        N -= v
        if N < 0:
          break
        
    return ans

print(solve())

Measured memory_bytes: 43296
// https://atcoder.jp/contests/abc070/tasks/abc070_c

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, T, m;

ll ea(ll a, ll b)
{
  if (a < b)
    swap(a, b);

  ll r = a % b,
     c = a, d = b;
  while (r != 0)
  {
    c = d;
    d = r;
    r = c % d;
  }
  return a / d * b;
}

int main()
{
  cin >> N >> T;

  m = T;
  REP(i, N - 1)
  {
    cin >> T;
    m = ea(m, T);
  }

  cout << m << '\n';

  return 0;
}


Measured memory_bytes: 256
#coding:utf-8
s = int(input())

#上の2桁
up = s // 100
#下の2桁
down = s % 100

#AMBIGUOUS
if  up >= 1 and up <= 12 and down >=1 and down <= 12:
    print("AMBIGUOUS")
#NA
elif (up == 0 or up > 12 ) and (down == 0 or down > 12):
    print("NA")

#MMYY
elif up >= 1 and up <=12:
    print("MMYY")
#MMYY
else:
    print("YYMM")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, p;
	cin >> a >> p;
	p += a * 3;
	cout << p / 2 << endl;
}


Measured memory_bytes: 764
def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
 
N, M, L = map(int, input().split())
D1 = [[10**18]*N for _ in range(N)]
 
for i in range(N):
    D1[i][i] = 0
 
for _ in range(M):
    A, B, C = map(int, input().split())
    D1[A-1][B-1] = C
    D1[B-1][A-1] = C

warshall_floyd(D1)
D2 = [[10**18]*N for _ in range(N)]

for i in range(N):
    D2[i][i] = 0
    
for i in range(N):
    for j in range(N):
        if i!=j and D1[i][j]<=L:
            D2[i][j] = 1

warshall_floyd(D2)
Q = int(input())

for _ in range(Q):
    s, t = map(int, input().split())
    ans = D2[s-1][t-1]
    
    if ans==10**18:
        print(-1)
    else:
        print(ans-1)

Measured memory_bytes: 58968
#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 h,n;
  int ans=0;
    scanf("%d %d",&h,&n);
    int a[100001];
 for(int i=0;i<n;i++){
   scanf("%d",&a[i]);
   ans += a[i];
 }
  if(ans>=h){
    printf("Yes");
  }
  else
    printf("No");
  
  return 0;
}

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

using namespace std;

typedef long long ll;

#define INF 10000000
#define mp make_pair
#define fi first
#define se second

int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);
    int n,m;
    cin >> n >> m;
    queue<int>pl;
    vector<int>g[n];
    int a,b;
    for(int i = 0;i<m;i++){
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
        if(a == 0){
            pl.push(b);
        }
        if(b == 0){
            pl.push(a);
        }
    }
    while(pl.size()>0){
        for(int i = 0;i<g[pl.front()].size();i++){
            if(g[pl.front()][i] == n-1){
                cout << "POSSIBLE";
                return 0;
            }
        }
        pl.pop();
    }
    cout << "IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 12400
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main(){
	fast;
	bool is_prime[100050];
	for(int i=2;i<100050;i++)
		is_prime[i]=true;
	is_prime[1]=false;
	for(int i=2;i*i<100050;i++)
	{
		if(is_prime[i] == false)
			continue;
		for(int j=i*i;j<100050;j+=i)
		{
			is_prime[j] = false;
		}
	}
    int x;
	cin>>x;
	for(int i=x;i<100050;i++)
	{
		if(is_prime[i])
		{
			cout<<i;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] h = new int[n];
        for (int i = 0 ; i < n ; i++) {
            h[i] = in.nextInt();
        }
        if (n == 1) {
            System.out.println(0); return;
        } else if (n == 2) {
            System.out.println(Math.abs(h[1] - h[0]));
            return;
        }
        int[] min = new int[n];
        min[0] = 0;
        min[1] = Math.abs(h[1] - h[0]);
        min[2] = Math.min(min[1] + Math.abs(h[2] - h[1]), Math.abs(h[2] - h[0]));
        for (int i = 3 ; i < n ; i++) {
            min[i] = Math.min(min[i-1] + Math.abs(h[i] - h[i-1]), min[i-2] + Math.abs(h[i] - h[i-2]));
        }
        System.out.println(min[n-1]);
    }
}


Measured memory_bytes: 50192
/**
  *  Worg
  */
#include <vector>
#include <iostream>
#include <algorithm>

const long long INF = 1e18;

int main() {
    int n; std::cin >> n;
    std::vector<long long> sum_a(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        long long x; std::cin >> x;
        sum_a[i] = sum_a[i - 1] + x;
    }

    std::vector<std::vector<long long>> dp(n + 1, std::vector<long long>(n + 1, INF));
    for (int i = n; i >= 1; i--) {
        dp[i][i] = 0;
        for (int j = i + 1; j <= n; j++) {
            for (int k = i; k < j; k++) {
                long long current_cost = dp[i][k] + dp[k + 1][j] + sum_a[j] - sum_a[i - 1];
                dp[i][j] = std::min(dp[i][j], current_cost);
            }
        }
    }

    std::cout << dp[1][n] << "\n";
    return 0;
}

Measured memory_bytes: 1536
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    def lcm(x, y):
        return (x * y) // gcd(x, y)

    def gcd(a,b):
        while b!=0:
            a,b=b,a%b
        return a

    print(lcm(A,B))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string T;
	cin >> T;
	REP(i, T.size()) if (T[i] == '?') T[i] = 'D';
	cout << T << endl;
	return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int A, B;
  cin >> A >> B;
  if((A * B) % 2 == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <map>
#include <cmath>
#include <queue>
#include <cstring>

using namespace std;
const int maxn = 1e7+5;
typedef long long ll;

int fun(int n)
{
    for(int i=0;i<=100;i++)
   {
       for(int j=0;j<=100;j++)
            if(i*4+j*7 == n)
                return 1;
   }
   return 0;

}

int main()
{
    int n;
    scanf("%d",&n);
    if(fun(n))
        printf("Yes\n");
    else printf("No\n");


    return 0;
}


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

// int main(){
// 	string s,t;
// 	cin >> s;
// 	cin >> t;
// 	bool flag = true; 
// 	rep(i,s.length()){
// 		if (s[i] != t[i])
// 			flag = false;
// 	}

// 	if (flag == true && t.length() - s.length() == 1)
// 		cout << "Yes";
// 	else cout << "No";
// 	return 0;
// }
//ans
int main (){
	string s;
	cin >> s;
	if (s == "RRR")
		cout << 3 << endl;
	else if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))
		cout << 2 << endl;
	else if (s.find('R') != -1)
		cout << 1 << endl;
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long int n,i,flag=1,cnt=0;
   cin >> n;
   
   unsigned long long int ar[n],pro=1,k=1000000000000000000;
   
   
   for(i=0;i<n;i++)
   {
       cin >> ar[i];
       
       if(ar[i]==0)
       cnt++;
   }
   
   if(cnt==0)
   {
       for(i=0;i<n;i++)
       {
           if(ar[i]<=(k/pro))  //this is same as pro>10^18
           {
                pro = (pro*ar[i]);
           }
          else
          {
              cout << "-1";
              return 0;
          }
          
        }
   }
   else
   {
   cout << "0";
   return 0;
   }
   
   cout << pro;
   
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  map<string, int>mp;
  for (int i=0; i<n; i++){
    string s; cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for (auto p : mp) mx = max(p.second, mx);
  for (auto p : mp){
    if (p.second == mx) cout << p.first << endl;
  }
}

Measured memory_bytes: 19208
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::{min, max};
use itertools::Itertools;
use num_integer::div_floor;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr >() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn main() {
    let n:u64 = read();
    let alist:Vec<u64> = (0..n).map(|_|read()).collect();
    let mut counter = HashMap::new();
    for a in alist {
        let ent =counter.entry(a).or_insert(0);
        *ent += 1;
    }
    let mut twos:Vec<u64> = counter.iter()
        .filter(|(key, val)|**val > 1)
        .map(|(key, val)|*key)
        .collect();
    twos.sort_by(|a, b|b.cmp(a));
    let fst = *twos.get(0).unwrap_or(&0);
    let snd = if let Some(fst) = twos.get(0) {
        if *counter.get(fst).unwrap_or(&0) > 3 {
            *fst
        } else {
            *twos.get(1).unwrap_or(&0)
        }
    } else {
        0
    };
    println!("{}", fst * snd);


}



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

int main() {
    int n, d, sum=0;
    cin >> n >> d;
    vector <vector<int>> v(n);
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<d; j++)
        {
            int x;
            cin >> x;
            v[i].push_back(x);          
        }        
    }

    for (int i=0; i<n-1; i++)
        for (int j=i+1; j<n; j++)
        {
            float s=0;
            for (int k=0; k<d; k++)
                s += pow(v[i][k] - v[j][k], 2);
            s = sqrt(s);
            if (s == (int)s)
                sum++;
        }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int N, K;
	int x[100010];
	long long min = 2000000000;
	long long tmp;
	long long tmp1 = 200000000;

	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
	}

	for (int i = 0; i <= N - K; i++)
	{
		//左ターン
		if (x[i] < 0) {
			if (x[i + K - 1] <= 0) {
				tmp = -x[i];
			}
			else {
				tmp = x[i + K - 1] + (-x[i] * 2);
			}
		}
		else {
			tmp = x[i + K - 1];
		}

		//右ターン
		if (x[i + K - 1] > 0) {
			if (x[i] < 0) {
				tmp1 = x[i + K - 1] * 2 + (-x[i]);
			}
		}


		if (tmp<min)
		{
			min = tmp;
		}
		if (tmp1<min)
		{
			min = tmp1;
		}
	}

	cout << min << endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)

l, r = map(int, input().split())

MOD = 2019

#n = 2019
#pf = {}
#
#for i in range(2,int(n**0.5)+1):
#    while n % i == 0:
#        pf[i] = pf.get(i,0) + 1
#        n //= i
#if n > 1: pf[n] = 1
#print(pf)
## 2019=3*673

import itertools

l_mod = l%MOD
r_mod = r%MOD

if r-l > 2019:
    ans = 0
else:
#    if l_mod <= 3 <= r_mod and l_mod <= 673 <= r_mod:
#        ans = 0
    if l_mod < r_mod:
        li = [i for i in range(l_mod, r_mod+1)]
        ans = 2018
        for v in itertools.combinations(li, 2):
            ans = min(ans, v[0]*v[1]%MOD)        
    else:
        ans = 0

print(ans)

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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

const int max_h = 6, max_w = 6;
int h, w, k, ans = 0;
char c[max_h][max_w];

int main(){
    cin >> h >> w >> k;
    string s;
    cin.ignore();
    rep(i, h) {
        getline(cin, s);
        rep(j, w) c[i][j] = s[j];
    }

    for(int bita = 0; bita < (1 << h); bita++){
        for(int bitb = 0; bitb < (1 << w); bitb++){
            int cnt = 0;
            rep(i, h) rep(j, w){
                if(((bita >> i) & 1) && ((bitb >> j) & 1)){
                    if(c[i][j] == '#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

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

int main()
{
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  for (auto &&i : s)
  {
    cin >> i;
  }
  queue<pair<int, int>> q;
  q.emplace(0, 0);
  vector<vector<int>> cost(H, vector<int>(W, INF));
  cost[0][0] = 1;
  while (!q.empty())
  {
    auto p = q.front();
    q.pop();
    int y = p.first, x = p.second;
    if (y == H - 1 && x == W - 1)
      break;
    for (int i = 0; i < 4; ++i)
    {
      int ny = y + dy[i], nx = x + dx[i];
      if (0 <= ny && ny < H && 0 <= nx && nx < W && s[ny][nx] == '.' && cost[ny][nx] == INF)
      {
        q.emplace(ny, nx);
        cost[ny][nx] = cost[y][x] + 1;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      if (s[i][j] == '.')
        cnt++;
    }
  }
  if (cost[H - 1][W - 1] == INF)
    cout << -1 << endl;
  else
    cout << cnt - cost[H - 1][W - 1] << endl;

  return 0;
}


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

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

    if (c>=a and c-a<=d) cout << "Yes" << endl;
    else if (c<=a and a-c<=d) cout << "Yes" << endl;
    else if (b>=a and c>=b and b-a<=d and c-b<=d) cout << "Yes" << endl;
    else if (a>=b and b>=c and a-b<=d and b-c<=d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(){
	const int MAX = 20;
	const int MIN = 0;
	
	int num;
	std::cin >> num;

	std::vector< std::vector<long long int> > dp((num - 1), std::vector<long long int>((MAX + 1), 0));
	int value;
	std::cin >> value;
	dp[0][value] = 1;
	for(int i = 0; i < (num - 2); ++i){
		std::cin >> value;
		for(int j = 0; j <= MAX; ++j){
			if((j + value) <= MAX){
				dp[i + 1][j] += dp[i][j + value];
			}
			if((j - value) >= MIN){
				dp[i + 1][j] += dp[i][j - value];
			}
		}
	}
	std::cin >> value;
	std::cout << dp[num - 2][value] << std::endl;
	return 0;
}

Measured memory_bytes: 1224
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.range;

long lowerBound(long[] xs, long x) {
    long l= 0;
    long h = xs.length;
    while (l < h) {
        long mid = (l + h) / 2;
        if (x <= xs[mid]) {
            h = mid;
        } else {
            l = mid + 1;
        }
    }
    return l;
}

void main() {
  long n = readln.strip.to!long;
  long a, b;
  readf("%d %d\n", &a, &b);
  long[] ps = readln.strip.split(" ").map!(to!long).array;

  auto s = sort(ps).array;
  auto x = s.lowerBound(a + 1);
  auto y = s.lowerBound(b + 1) - x;
  auto z = n - x - y;

  writeln(min(x, min(y, z)));


}


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

int main() {
    string s;
    int cnt = 0;
    cin >> s;
    for (int i = 0; i < s.length() / 2; i++) {
        if(s.at(i) != s.at(s.length() - 1 - i)){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3588
//
//  main.cpp
//  atcoder-stones
//
//  Created by r on 6/1/19.
//  Copyright © 2019 r. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <assert.h>
#include <limits>
#include <cstdio>
using namespace std;

//#define RDEBUG 1
#ifdef RDEBUG
#define D(x) x
#else
#define D(x)
#endif
#define inf 0x7fffffff
#define MOD 1000000007

int N, K, a[110], dp[100010][2];

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> K;
    for (int i = 0; i<N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i<a[0]; i++) {
        dp[i][0] = 0;
        dp[i][1] = 1;
    }
    for (int i = a[0]; i<=K; i++) {
        dp[i][1] = 1;
        for (int j = 0; j<N; j++) {
            if (i-a[j]>=0) {
                dp[i][0]|=dp[i-a[j]][1];
                dp[i][1]&=dp[i-a[j]][0];
            }
        }
    }
    if (dp[K][0] == 1) cout << "First" << endl;
    if (dp[K][0] == 0) cout << "Second" << endl;
    return 0;
}





Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll> vec[27];

ll binSearch(ll lastPos, ll vecPos){
    ll left=0, right=vec[vecPos].size()-1;
    ll toReturn=-1;
    while(left<=right){
        ll mid=left+(right-left)/2;
        //printf("left: %d, right: %d, mid: %d\n", left, right, mid);
        if(vec[vecPos][mid]>lastPos){
            toReturn=vec[vecPos][mid];
            //printf("To retturn: %d\n", toReturn);
            right=mid-1;
        }
        else{
            left=mid+1;
        }
    }
    //printf("Returning: %d\n", toReturn);
    return toReturn;
}

int main(){
    //freopen("in.txt", "r", stdin);
    ll i, j;
    string s, t;
    cin >> s >> t;
    ll sLen=s.length();
    ll tLen=t.length();
    for(i=0; i<sLen; i++){
        vec[s[i]-'a'].push_back(i);
    }

    ll rounds=0;
    ll ans=0;
    ll lastPos=-1;
    bool can=true;
    for(i=0; i<tLen && can; i++){
        ll vecPos=t[i]-'a';
        //printf("for %c: %lld\n", t[i], vecPos);
        //printf("Size: %d\n", vec[vecPos].size());
        if(vec[vecPos].size()==0){
            can=false;
            continue;
        }
        ll nextPos=binSearch(lastPos, vecPos);
        //printf("%lld to %lld\n", lastPos, nextPos);
        if(nextPos==-1){
            rounds++;
            lastPos=vec[vecPos][0];
            //printf("Rolling to %lld\n", vec[vecPos][0]);
        }
        else{
            lastPos=nextPos;
        }
        //printf("%lld to %lld\n", lastPos, nextPos);
    }
    if(can){
        cout << rounds*sLen+lastPos+1 << "\n";
        //cout << ans << "\n";
    }
    else{
        cout << "-1\n";
    }
}


Measured memory_bytes: 1724
// https://abc042.contest.atcoder.jp/tasks/arc058_a
#include <iostream>

using namespace std;

int main() {
	int n, d;
	bool ds[10];
	cin >> n >> d;
	for (int i = 0; i < 10; i++) ds[i] = false;
	for (int i = 0; i < d; i++) {
		int x;
		cin >> x;
		ds[x] = true;
	}
	while (true) {
		int x = n;
		bool ok = true;
		while (x > 0) {
			if (ds[x % 10]) {
				ok = false;
				break;
			}
			x /= 10;
		}
		if (ok) break;
		n++;
	}
	cout << n << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

dp = [0] * (N+1)
dp[0] = 1000
for i in range(1, N+1):
    dp[i] = dp[i-1]
    for j in range(1,i):
        dp[i] = max(dp[i], dp[j] // A[j-1] * A[i-1] + (dp[j] % A[j-1]))

print(dp[-1])


Measured memory_bytes: 64312
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second




int main() {
	int n, a, mi = 0, ma = 0, p = 0;
	bool b[100] = { 0 };
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a;
		if (a / 400 == 0)b[0] = 1;
		else if(a / 400 == 1)b[1] = 1;
		else if (a / 400 == 2)b[2] = 1;
		else if (a / 400 == 3)b[3] = 1;
		else if (a / 400 == 4)b[4] = 1;
		else if (a / 400 == 5)b[5] = 1;
		else if (a / 400 == 6)b[6] = 1;
		else if (a / 400 == 7)b[7] = 1;
		else b[8] = 1, p++;
	}
	for (int i = 0;i < 8;i++) {
		if (b[i])mi++, ma++;
	}
	if (b[8] && mi >= 0)cout << max(1, mi) << ' ' << ma + p << endl;
	else if (!b[8] && mi > 0)cout << mi << ' ' << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 200003
int main()
{
    int i,n;
    string str;
    llin(str);
    n=str.size();
    int ans=0;
    rep(i,n/2)
    {
        if(str[i]!=str[n-i-1])
            ans++;
    }
    out(ans);
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n,a,b,cnt=0,cnt1=0;
    string s;
    cin >> n >> a >> b >> s;
    for(auto i:s){
        bool flag = 0;
        if(i=='a'){
            if(cnt<a+b){
                 flag = 1;
                 cnt++;
            }
        }
        if(i=='b'){
            cnt1++;
            if(cnt<a+b&&cnt1<=b){
                flag = 1;
                cnt++;
            }
        }
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N,K;
    cin>>N>>K;
    string S;
    cin>>S;

    bool is1 = true;
    ll sum = 0;
    v a;
    ll l=0,r=0;
    ll t=-1;
    ll ans = 0;
    while(t<K && r<N){
        if(is1 == true){
            if(S[r] == '1')sum++;
            else{
                ans = max(sum,ans);
                t++;
                sum++;
                if(t == K)sum--;
                is1 = false;
            }
        }
        else{
            if(S[r] == '1'){
                sum++;
                is1 = true;
            }
            else{
                sum++;
            }
        }
        r++;
    }
    r--;
    ans = max(sum,ans);
    while(r<N){
        is1 = true;
        while(1 && l<N){
            if(is1 == true){
                if(S[l] == '1')sum--;
                else{
                    sum--;
                    is1 = false;
                }
            }
            else{
                if(S[l] == '1'){
                    is1 = true;
                    break;
                }
                else{
                    sum--;
                }
            }
            l++;
        }

        is1 = false;
        while(1 && r<N){
            if(is1 == true){
                if(S[r] == '1')sum++;
                else{
                    ans = max(sum,ans);
                    is1 = false;
                    break;
                }
            }
            else{
                if(S[r] == '1'){
                    sum++;
                    is1 = true;
                }
                else{
                    sum++;
                }
            }
            r++;
        }
    }
    ans = max(sum,ans);
    cout<<ans;
    return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  set<char> c(s.begin(), s.end());
  if (c.size() == 4u) {
    cout << "Yes" << endl;
  } else if (c.size() == 2u) {
    if ((c.count('N') && c.count('S')) || (c.count('W') && c.count('E'))) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

#define V vector
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define prec(x) cout<<fixed<<setprecision(x)
#define f(i,a) for(int i = 0 ; i < a ; i++)
#define ff first
#define ss second
#define all(x) (x).begin() ,(x).end()

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

ll binpow(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}

void solve()
{
	ll n;
	cin >> n;

	ll a[n];

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

	sort(a , a + n);

	int ans = 0;

	rep(i , 0 , n)
	{
		rep(j , i + 1 , n)
		{
			rep(k , j + 1 , n)
			{
				if (a[i] + a[j] > a[k] and a[i] != a[j] and a[j] != a[k])
					ans++;
			}
		}
	}

	cout << ans << "\n";
}

int main() {


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


	int t = 1;
	//cin >> t;

	while (t--)
	{
		solve();
	}

	return 0;
}





Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
using namespace std;



ll path(ll r,ll c,char grid[1000][1000])
{
    if(grid[0][0]=='#')
    {
        return 0;
    }
    if(grid[r-1][c-1]=='#')
    {
        return 0;
    }
    ll dp[r][c]={0};
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            dp[i][j] = 0;
        }
    }
    for(int j=0;j<c;j++)
    {
        if(grid[0][j]=='#')
        {
            break;
        }
        dp[0][j]=1;
    }
    for(int i=0;i<r;i++)
    {
        if(grid[i][0]=='#')
        {
            break;
        }
        dp[i][0]=1;
    }
    for(ll i=1;i<r;i++)
    {
        for(ll j=1;j<c;j++)
        {
            if(grid[i][j]=='#')
            {
                continue;
            }
            ll ans=0;
            if(grid[i-1][j]!='#')
            {
                ans = dp[i-1][j]%mod;
            }
            if(grid[i][j-1]!='#')
            {
                ans = (ans + (dp[i][j-1]))%mod;
            }
            dp[i][j] = ans%mod;
        }
    }
    return dp[r-1][c-1]%mod;
}

int main()
{
    ll r,c;
    cin>>r>>c;
    char grid[1000][1000];
    for(ll i=0;i<r;i++)
    {
        for(ll j=0;j<c;j++)
        {
            cin>>grid[i][j];
        }
    }
    cout<<path(r,c,grid)%mod<<"\n";
}



Measured memory_bytes: 12372
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    s='0'+s;
    int len=s.length();
    len=len-1;
    int mark1=0,mark2=0;
    for(int i=1;i<=len;i+=2){
        if(s[i]=='L'){
            mark1=1;
            break;
        }
    }
    for(int i=2;i<=len;i+=2){
        if(s[i]=='R'){
            mark2=1;
            break;
        }
    }
    if(mark1==0 && mark2==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
c = input().split()
c = [(int(s[1]), s[0]) for s in c]
d = c.copy()

# BubbleSort
for i in range(0, n):
    for j in [n-k for k in range(1, n-i)]:
        if c[j][0] < c[j-1][0]:
            c[j], c[j-1] = c[j-1], c[j]

ans1 = " ".join([c[i][1] + str(c[i][0]) for i in range(n)])
print(ans1)
print("Stable")

#SelectionSort
for i in range(0, n):
    minj = i
    for j in range(i, n):
        if d[j][0] < d[minj][0]:
            minj = j
    d[i], d[minj] = d[minj], d[i]

ans2 = " ".join([d[i][1] + str(d[i][0]) for i in range(n)])
print(ans2)
if ans2 == ans1:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main()
{
    int a,b;
    
    while(scanf("%d%d",&a,&b) == 2)
    {
        if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0)
            printf("Possible\n");
        else printf("Impossible\n");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    int a[100005];
    rep(i, 1, n + 1) {
        cin >> a[i];
    }
    long long ans = 0;
    rep(i, 0, n) {
        if (a[i] + a[i + 1] > x) {
            ans += a[i] + a[i + 1] - x;
            a[i + 1] = x - a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define pi acos(-1);
ll strtoint(string str);
int main(){
	fast;
	ll n,x,k,cnt=0; cin>>n>>k;
	for(auto i=0;i<n;++i){
		cin>>x;
		if(x>=k)++cnt;
	}
	cout<<cnt<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

const int MAXN = 3002;
const int P = 998244353;

int a[MAXN];
int64_t f[2][MAXN];

int64_t solve(int n, int sum) {
  memset(f, 0, sizeof(f));
  int64_t ans = 0;
  int mask = 0;
  for (int i = n; i > 0; --i) {
    mask ^= 1;
    if (sum > a[i]) ans += i * f[mask ^ 1][sum - a[i]];
    else if (sum == a[i]) ans += i * (n + 1 - i);
    ans %= P;

    for (int j = 1; j <= sum; ++j) {
      f[mask][j] = f[mask ^ 1][j];
      if (j >= a[i]) f[mask][j] = (f[mask][j] + f[mask ^ 1][j - a[i]]) % P;
    }
    f[mask][a[i]] += n + 1 - i;
  }
  return ans;
}

int main() {
  int n, sum;
  std::cin >> n >> sum;
  for (int i = 1; i <= n; ++i) std::cin >> a[i];
  std::cout << solve(n, sum) << std::endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

const int SIZE = 2e5+100;
string s;

ll ans[SIZE];

int main(){
    cin >> s;
    bool rf = true,lf = false;
    int rp = 0,lp = 0;
    int sp = 0,ep = 0;
    ll rcou = 1,lcou = 0;
    for(int i = 1; i < s.length(); i++){
        if(rf && !lf){
            if(s[i] == 'R'){
                ++rcou;
            }
            else{
                lf = true;
                ++lcou;
            }
        }
        else if(lf && rf){
            if(s[i] == 'L'){
                ++lcou;
            }
            else{
                ep = i-1;
                rp = sp+rcou-1;
                lp = sp+rcou;
                for(int j = 0; j < rcou; j++){
                    if(j%2 == 0){
                        ans[rp]++;
                    }
                    else{
                        ans[lp]++;
                    }
                }
                for(int j = 0; j < lcou; j++){
                    if(j%2 == 0)    ans[lp]++;
                    else
                    {
                        ans[rp]++;
                    }
                    
                }
                sp = i;
                rcou = 1;
                lcou = 0;
                lf = false;
            }
        }
    }

                rp = sp+rcou-1;
                lp = sp+rcou;
                for(int j = 0; j < rcou; j++){
                    if(j%2 == 0){
                        ans[rp]++;
                    }
                    else{
                        ans[lp]++;
                    }
                }
                for(int j = 0; j < lcou; j++){
                    if(j%2 == 0)    ans[lp]++;
                    else
                    {
                        ans[rp]++;
                    }
                    
                }

    for(int i = 0; i < s.length(); i++){
        cout << ans[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

using namespace std;

int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	REP(i, n) cin>>a[i];
	vector<int> dp(n + 1);
	dp[0] = -1;
	FOR(i, 1, n + 1) {
		dp[i] = INF;
	}
	FOR(i, 1, n + 1) {
		vector<int>::iterator ite = lower_bound(ALL(dp), a[i - 1]);
		if(ite != a.end()) *ite = a[i - 1];
	}
	int res = 0;
	REP(i, n + 1) {
		if(dp[i] != INF) res = i;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {

    private static final int INF = 1_000_000_000;
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int R = sc.nextInt();

        int[] r = new int[R];
        for (int i = 0; i < R; i++) {
            r[i] = sc.nextInt()-1;
        }

        int[][] cost = new int[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (i == j) {
                    cost[i][j] = 0;
                } else {
                    cost[i][j] = INF;
                }
            }
        }
        for (int i = 0; i < M; i++) {
            int A = sc.nextInt()-1;
            int B = sc.nextInt()-1;
            int C = sc.nextInt();
            cost[A][B] = C;
            cost[B][A] = C;
        }

        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    int c = Math.min(cost[i][j],cost[i][k]+cost[k][j]);
                    cost[i][j] = c;
                    cost[j][i] = c;
                }
            }
        }

        List<Integer> now = new ArrayList<>();
        List<Integer> remain = new ArrayList<>();
        for (int i = 0; i < r.length; i++) {
            remain.add(r[i]);
        }
        int ans = calc(now,remain,cost);

        System.out.println(ans);
    }

    private static int calc(List<Integer> now, List<Integer> remain, int[][] cost) {
        if (remain.size() == 0) {
            int tmp = 0;
            for (int i = 1; i < now.size(); i++) {
                tmp += cost[now.get(i-1)][now.get(i)];
            }
            return tmp;
        }

        int min = INF;
        for (int r : remain) {
            now.add(r);
            List<Integer> nextRemain = new ArrayList<>();
            for (int rr : remain) {
                if (rr == r) continue;
                nextRemain.add(rr);
            }
            int tmp = calc(now,nextRemain,cost);
            min = Math.min(min,tmp);
            now.remove(now.size()-1);
        }

        return min;
    }
}


Measured memory_bytes: 47996
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <cstring>
#include <stdio.h>
#include <iomanip>

using namespace std;

typedef long long int lli;

int main() {
	long double L,ans;
	cin >> L;

	ans = (L / 3.0)*(L / 3.0)*(L / 3.0);
	cout << std::fixed << std::setprecision(12) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
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();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class DXXOR {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll N, K;
        in >> N >> K;
        vector<ll> A(N);
        REP(i,0,N) in >> A[i];

        int digitNum = 1;
        RREP(i,0,40) {
            if ((1LL << i) & K) {
                digitNum = i+1;
                break;
            }
        }
//        debug(digitNum);
        vector<int> digitCnt (digitNum, 0);

        REP(i,0,N) {
//            out << "A:" << bitset<13>(A[i]) << "\n";
            REP(k,0,digitNum) {
//                out << "k:" << k << ":" << bitset<13>(1 << k) << "\n";
                if ((1LL << k) & A[i]) {
                    digitCnt[k]++;
                }
            }
        }
        ll X = 0, X2 = 0;
        RREP(k,0,digitNum) {
//            debug(digitCnt[k]);
            if (digitCnt[k] <= N / 2 && (X + (1LL << k)) <= K) {
                X += (1LL << k);
            }
            if (digitCnt[k] <= N / 2 && k != digitNum-1) {
                X2 += (1LL << k);
            }
        }
        ll answer = 0, answer2 = 0;
        REP(i,0,N) {
            answer += X ^ A[i];
            answer2 += X2 ^ A[i];
        }
        out << max(answer, answer2) << "\n";
    }
};


int main() {
	DXXOR solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << a / __gcd(a, b) * b << '\n';
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
	static int gcd(int x, int y){
		if(x<y)gcd(y,x);
		if(y == 0)return x;
		return gcd(y,x%y);
	}
	static int lcm(int x, int y){
		return x*y/gcd(x,y);
	}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		System.out.print(lcm(360, x)/x);
	}
}


Measured memory_bytes: 35652
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0) 
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 5;
const int inf = ~0u >> 1;
ll Pow(ll a, ll b)
{
    ll ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a);
        a = (a * a);
        b >>= 1;
    }
    return ans;
}
int main() {
    IO;
    ll x;
    cin >> x;
    for (int i = -maxn; i <= maxn; ++i) {
        for (int j = -maxn; j <= maxn; ++j) {
            if (Pow(i, 5) - Pow(j, 5) == x) {
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main()
{
  int n, l;
  cin >> n >> l;
  vector<string> str(n);
  int i;
  for(i = 0; i < n; i++)
  {
    cin >> str.at(i);
  }
  sort(str.begin(), str.end());
  for(i = 0; i < n; i++)
  {
    cout << str.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256