akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	int n,m;
	in(n,m);
	unionfind uni;
	uni.init(n);
	rep(i,m){
		int a,b;
		in(a,b);
		uni.marge(a-1,b-1);
	}
	int ans=0;
	unordered_map<int,int> are;
	rep(i,n){
		are[uni.root(i)]+=1;
		chmax(ans,are[uni.root(i)]);
	}
	out(ans);
	return 0;
}


Measured memory_bytes: 12052
def main():
    n,m=map(int,input().split())
    h=list(map(int,input().split()))
    dic={}
    for i in range(m):
        a,b=map(int,input().split())
        dic.setdefault(a,[]).append(b)
        dic.setdefault(b,[]).append(a)
    ans=0
    for i in range(n):
        tmp=h[i]
        f=True
        if i+1 in dic:
            for j in dic[i+1]:
                if tmp<=h[j-1]:
                   f=False
        if f: ans+=1
    print(ans)

if __name__ =='__main__':
    main()

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  ll a,b;
  cin>>a>>b;
  if(a<0&&b<0){
    if((b-a+1)%2)cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;
  }
  else if(a<=0&&0<=b)cout<<"Zero"<<endl;
  else if(0<a&&0<b)cout<<"Positive"<<endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

template <class T> inline void read(T &x) {
	char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	if (flag) x = -x;
}

inline int input() {
	int x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

const int mod = 1e9 + 7;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; }
inline void inc(int &x, int y) { x += y; x -= x >= mod ? mod : 0; }

inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = (ll) res * x % mod;
		x = (ll) x * x % mod, y >>= 1;
	} return res;
}

template <class T> void chkmax(T &x, T y) { x = x > y ? x : y; }
template <class T> void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> T gcd(T x, T y) { return !y ? x : gcd(x % y, y); }

int n, k;
int a[2][N];

inline void shift(int *a) {
	int tmp = a[1];
	for (int i = 1; i < n; ++i) a[i] = a[i + 1];
	a[n] = tmp;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> k, n = ((k + 3) >> 2) << 1;
	if (k == 1) return puts("1\n1"), 0;
	
	int now = 0;
	for (int i = 1; i <= n; ++i) a[0][i] = ++now;
	for (int i = 1; i <= n; ++i) a[1][i] = ++now > k ? now - n : now;
	shift(a[1]);

	printf("%d\n", n);
	for (int i = 1; i <= n / 2; ++i) {
		for (int j = 1; j <= n; ++j) printf("%d ", a[0][j]);
		putchar('\n');
		for (int j = 1; j <= n; ++j) printf("%d ", a[1][j]);
		putchar('\n');
		shift(a[0]), shift(a[0]);
		shift(a[1]), shift(a[1]);
	}
	return 0;
}

Measured memory_bytes: 1280
#!/usr/bin/perl

#
my $s = <>; chomp($s);

#
$h{"SUN"} = 7;
$h{"MON"} = 6;
$h{"TUE"} = 5;
$h{"WED"} = 4;
$h{"THU"} = 3;
$h{"FRI"} = 2;
$h{"SAT"} = 1;

print $h{"$s"};

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int N, a[100010];
int main(){
	cin>>N;
	
	REP(i, 0, N){
		int aa;
		cin>>aa;
		
		if(aa>0) a[aa-1]++;
		a[aa]++;
		a[aa+1]++;
	}
	
	int mx=0;
	REP(i, 0, 100000){
		mx=max(mx, a[i]);
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 5100000
#define MOD 1000000007
#define INF 2000000000

vector<int> a;
void dfs(Graph &G,int v,int p,vector<int> &len,vector<int> &ans){
  int k=lower_bound(len.begin(),len.end(),a.at(v))-len.begin();
  int pre=len.at(k);
  len.at(k)=a.at(v);
  ans.at(v)=lower_bound(len.begin(),len.end(),INF)-len.begin();
  ans.at(v)--;
  for(auto nv:G.at(v)){
    if(nv==p){
      continue;
    }
    dfs(G,nv,v,len,ans);
  }
  len.at(k)=pre;
}

int main(){
  int N;
  cin>>N;
  a.resize(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  Graph G(N);
  for(int i=0;i<N-1;i++){
    int u,v;
    cin>>u>>v;
    u--,v--;
    G.at(u).push_back(v);
    G.at(v).push_back(u);
  }

  vector<int> len(N+2,INF);
  len.at(0)=0;
  vector<int> ans(N,0);

  dfs(G,0,-1,len,ans);
  for(int i=0;i<N;i++){
    cout<<ans.at(i)<<endl;
  }
}


Measured memory_bytes: 30732
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

void solve() {
  int n, w;
  cin >> n >> w;
  vector<ll> wt(n), val(n);
  ll sum_val = 0;
  for (int i = 0; i < n; ++i) {
    cin >> wt[i] >> val[i];
    sum_val += val[i];
  }
  vector<ll> minWeight(sum_val + 1, 1e10);
  minWeight[0] = 0;
  for (int item = 0; item < n; ++item) {
    for (int value_already = sum_val - val[item]; value_already >= 0;
         --value_already) {
      minWeight[value_already + val[item]] =
          min(minWeight[value_already + val[item]],
              minWeight[value_already] + wt[item]);
    }
  }
  ll ans = 0;
  for (int i = 0; i <= sum_val; ++i) {
    if (minWeight[i] <= w) {
      ans = max(ans, (ll)i);
    }
  }
  cout << ans << endl;
}
int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

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

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n), b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    vector<int> cnt1(n+1), cnt2(n+1);
    rep(i,n)cnt1[a[i]]++;
    rep(i,n)cnt2[b[i]]++;
    rep(i,n+1){
        if(cnt1[i]+cnt2[i]>=n+1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    vector<int> ord(n+1);
    rep(i,n+1)ord[i]=i;
    sort(ord.begin(),ord.end(),[&](int x, int y){
        return cnt1[x]+cnt2[x]>cnt1[y]+cnt2[y];
    });
    vector<int> used1(n), used2(n);
    int idx = 0;
    vector<int> ans1(n),ans2(n);
    for(auto i : ord){
        while(cnt1[i]){
            ans1[idx++]=i;
            --cnt1[i];
            if(idx == n)break;
        }
        if(idx == n)break;
        while(cnt2[i]){
            ans2[idx++]=i;
            --cnt2[i];
            if(idx == n)break;
        }
        if(idx == n)break;
    }
    idx = 0;
    for(auto i : ord){
        rep(j,cnt1[i]){
            while(ans1[idx])++idx;
            ans1[idx]=i;
        }
    }
    idx = 0;
    for(auto i : ord){
        rep(j,cnt2[i]){
            while(ans2[idx])++idx;
            ans2[idx]=i;
        }
    }
    vector<int> ans(n);
    rep(i,n)ans[i]=i;
    sort(ans.begin(),ans.end(),[&](int u, int v){
        return ans1[u] < ans1[v];
    });
    rep(i,n)cout<<ans2[ans[i]]<<" ";
    return 0;
}

Measured memory_bytes: 11180
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl;
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl;
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl;
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl;
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl;
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_da].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

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

const ll maxn = 100010;

void MAIN() {

    ll a , b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b);

}

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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(

    )";
    MAIN();
    return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    string s;
    cin >> s;
    set<char> st;
    rep(i, s.size())
    {
        st.insert(s[i]);
    }
    if (st.size() == 3)
        Yes;
    else
        No;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int n;

int calc(int x,int y){
	int pw=0;
	int ans=0;
	int xx=x;
	for (;x+y<=n;pw++){
		x*=10;	
	}
	if (pw<=1 && xx!=y){return 0;}
	else if (xx==y && pw==0 && xx>n) return 0;
	else if (xx==y && (pw == 1 || (pw==0 && xx<=n))){ return 1;}
	else {
//		cout << "pw" << pw << ' ';
		if (pw==2 && xx!=y) return 1;
		else if (pw==2 && xx==y) return 2;
		else if (xx==y) ans++;
		for (int as=1,p=2;p<pw;p++){
			ans += as;
			as *= 10;
		}
//		cout << ans << endl;
		int mx=1;
		for (int k=1;k<=pw-2;k++){
			mx *= 10;
		}
		mx --;
		x/=10;
		for (int k=0;k<=mx;k++){
			if (x + 10*k + y <= n) ans++;
			else break;	
		}
		return ans;
	}
}

int main(){
	cin >> n;
//	cout << calc(1,1) << endl << endl;
	int s=0;
	for (int i=1;i<=9;i++){
		for (int j=i;j<=9;j++){
//			cout << i << ' ' << j << ' ' << calc(i,j) << ' ' << calc(j,i) << endl;
			s+=calc(i,j)*calc(j,i)*(i==j?1:2);
		}
	}
	cout << s;
	return 0;
} 

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

int main() {

  string S;
  cin >> S;

  int countZero = 0;
  int countOne = 0;
  
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == '0') {
      countZero++;
    } else {
      countOne++;
    }
  }
  
  cout << min(countZero, countOne) * 2 << endl;

}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int len = s.length();
		int[] ans = new int[len];

		int countR = 1;

		for (int i = 1; i < len; i++) {
			int startL = i;
			int countL = 0;

			if (s.charAt(i) == 'R') {
				if (s.charAt(i - 1) == 'L') {
					countR = 1;
				} else {
					countR++;
				}
			} else {
				if (s.charAt(i - 1) == 'R') {
					int tmpL = startL;
					while (s.charAt(tmpL) == 'L') {
						countL++;
						tmpL++;
						if (tmpL == len) {
							break;
						}
					}
					ans[startL - 1] = hidari(countR, countL);
					ans[startL] = migi(countR, countL);
				}
			}

		}

		for (int i = 0; i < len; i++) {
			System.out.print(ans[i] + " ");
		}
		sc.close();
	}

	public static int hidari(int R, int L) {
		if (R % 2 == L % 2) {
			return (L + R) / 2;
		} else {

			if (R % 2 == 0)
				return (L + R) / 2;
			else
				return (L + R) / 2 + 1;

		}
	}

	public static int migi(int R, int L) {
		if (R % 2 == L % 2) {
			return (L + R) / 2;
		} else {
			if (R % 2 == 0)
				return (L + R) / 2 + 1;
			else
				return (L + R) / 2;
		}
	}

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

using namespace std;


int main() {

    int n; cin >> n;
    int sum = 0;
    vector<int> v;
    rep(i,n){
        int tmp; cin >> tmp;
        sum += tmp;
        if(tmp%10 != 0) v.push_back(tmp);
    }

    sort(v.begin(),v.end());

    if(sum%10 != 0) cout << sum;
    else if(v.empty()) cout << 0;
    else cout << sum-v[0];

    return 0;
}











Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int N;
	cin >> N;
  	int array[N];
	for(int i=0;i<N;i++){
    	cin >> array[i];
    }
  
  	int y=1;
 	for(int i=1;i<N;i++){
      	int flag=0;
    	for(int j=0;j<i;j++){
        	if (array[i] < array[j]){
            	flag = 1;
              	break;
            }
        }
        if (flag == 0){
        	y++;
        }
    } 
  	
    cout << y << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int a,b;
    int count=0;
    cin >> a >> b;
    for(int i=a;i<=b;i++){
        string str = to_string(i);
        if(str.substr(0,1)==str.substr(4,1) && str.substr(1,1)==str.substr(3,1)){
            count++;
        }
    }
    cout << count << endl;
}


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

fn main() {
    input! {
        n: usize, k: usize,
        v: [i64; n]
    }

    let mut ret = 0;
    for l in 0..k+1 {
        for r in 0..k-l+1 {
            if l + r > n {break;}
            let mut deq = v.iter().cloned().collect::<std::collections::VecDeque<_>>();
            let mut p = vec![];
            let mut sum = 0;
            for _ in 0..l {
                let tmp = deq.pop_front().unwrap();
                sum += tmp;
                if tmp < 0 {
                    p.push(tmp);
                }
            }
            for _ in 0..r {
                let tmp = deq.pop_back().unwrap();
                sum += tmp;
                if tmp < 0 {
                    p.push(tmp);
                }
            }
            p.sort();
            for i in 0..std::cmp::min(k-(l+r), p.len()) {
                sum -= p[i];
            }
            ret = std::cmp::max(ret, sum);
        }
    }
    println!("{}", ret);
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
#define MAX 10000
int n, q, nrank[MAX]={}, parent[MAX];

int find(int a) {
    int p = a;
    while (parent[p] != -1) {
        p = parent[p];
    }
    return(p);
}

void unite(int x, int y) {
    int xp, yp;
    xp = find(x);
    yp = find(y);
    if (xp == yp) {
        return;
    }
    if (nrank[xp] < nrank[yp]) {
        parent[xp] = yp;
    } else if (nrank[xp] > nrank[yp]) {
        parent[yp] = xp;
    } else {
        parent[xp] = yp;
        nrank[yp] += 1;
    }
}

int same(int x, int y) {
    if (find(x) == find(y)) {
        return 1;
    } else {
        return 0;
    }
}

int main() {
    int com, x, y;
    cin >> n >> q;
    for (int i=0; i<n; i++) {
        parent[i] = -1;
    }
    for (int i=0; i<q; i++) {
        cin >> com >> x >> y;
        if (com == 0) {
            unite(x, y);
        } else {
            cout << same(x, y) << endl;;
        }
    }
}


Measured memory_bytes: 3168
package main

import (
	"fmt"
	"math"
)

func main() {
	var P, Q, R float64
	fmt.Scan(&P, &Q, &R)

	a := P + Q
	b := Q + R
	c := R + P
	ans := math.Min(math.Min(a, b), c)
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int SURP = 1000000007;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if (a > c){
		swap(a,c);
		swap(b,d);
	}
	int start = 0;
	int end = 0;
	int ret = 0;
	if(b > c){
		start = c;
		if(b < d){
			end = b;
		}else{
			end = d;
		}
		ret = end -start;
	}

	cout << ret << endl;
	return 0;

}


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;
const int INF = 1e9;

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

  cout << ((b - a == c - b) ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int simulate(const vi& a,int changedpos)
{
	int li=changedpos,ri=changedpos;
	for(;;){
		int color=a[ri];
		int li2,ri2;
		for(li2=li-1;;li2--){
			if(li2<0 || a[li2]!=color){
				li2++;
				break;
			}
		}
		for(ri2=ri;ri2<a.size() && a[ri2]==color;ri2++)
			;
		if((ri2-li2)-(ri-li)>=4){
			li=li2;
			ri=ri2;
		}
		else
			break;
		if(li==0 || ri==a.size() || a[li-1]!=a[ri])
			break;
	}
	return a.size()-(ri-li);
}

int main()
{
	for(int n;cin>>n,n;){
		vi a(n);
		rep(i,n)
			cin>>a[i];
		
		int res=1<<29;
		rep(i,n){
			int temp=a[i];
			repi(j,1,4){
				if(j==temp)
					continue;
				a[i]=j;
				res=min(res,simulate(a,i));
			}
			a[i]=temp;
		}
		
		cout<<res<<endl;
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, bool> pib;

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef vector<double> vf;

typedef long double ld;

#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

#define printItr(A) for(auto itr = A.begin(); itr != A.end(); ++itr){cout << * itr << ", ";}cout << endl;

const double PI = 3.141592653589793;

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	ll X, Y;
	cin >> X;
	cin >> Y;

	ll ans = 0;
	if (X <= 3) {
		ans += 4 - X;
	}
	if (Y <= 3) {
		ans += 4 - Y;
	}

	if (X == Y && X == 1) {
		ans += 4;
	}

	cout << ans * 100000 << endl;

	return 0;
}

Measured memory_bytes: 256
let nil = -1

type tree = { mutable parent : int; mutable child : int; mutable bro : int; mutable depth : int }

let make () = { parent = nil; child = nil; bro = nil; depth = nil }

let set_depth t n =
  let rec root i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else root (i + 1) in
  let rec doit i d =
    t.(i).depth <- d;
    if t.(i).bro <> nil then doit t.(i).bro d;
    if t.(i).child <> nil then doit t.(i).child (d + 1) in
  doit (root 0) 0

let print_tree t =
  let rec print_children i c =
    if c <> nil then begin
      if c <> t.(i).child then print_string ", ";
      print_int c;
      print_children i t.(c).bro
    end in
  t |> Array.iteri (fun i _ ->
    "node " ^ string_of_int i ^ ": parent = " ^ string_of_int t.(i).parent
       ^ ", depth = " ^ string_of_int t.(i).depth
       ^ (if t.(i).parent = nil then ", root, ["
          else if t.(i).child = nil then ", leaf, ["
          else ", internal node, [")
    |> print_string;
    print_children i t.(i).child;
    print_string "]\n")

let () =
  let n = Scanf.scanf "%d " (fun i -> i) in
  let t = Array.init n (fun _ -> make ()) in
  for _ = 0 to n - 1 do
    let (id, k) = Scanf.scanf "%d %d " (fun id k -> (id, k)) in
    let left_child = ref 0 in
    for i = 0 to k - 1 do
      let c = Scanf.scanf "%d " (fun i -> i) in
      t.(c).parent <- id;
      if i = 0 then t.(id).child <- c
      else t.(!left_child).bro <- c;
      left_child := c;
    done;
  done;
  set_depth t n;
  print_tree t

Measured memory_bytes: 13232
n = int(input())
List = list(map(int,input().split()))
counter = 0
for i in range(n-1):
  if i == List[i] -1:
    List[i],List[i+1] = List[i+1],List[i]
    counter += 1
if List[-1] == n:
  counter += 1
print(counter)

Measured memory_bytes: 14008
N = int(input())
b = [int(x) for x in input().split()]
li=[]
def dfs(B,li):
    cand = []
    if(B == []):
        return True
    if(max(B)>len(B)):
        return False
    for i in range(1,len(B)+1):
        if(i in B):
            if(B.index(i)+1<i):
                return False
            elif(B.index(i)+1==i):
                cand.append(i)

    for i in cand:
        if(dfs(B[:i-1]+B[i:],li)):
            li.append(i)
            return True

    return False

if(dfs(b,li)):
    for i in li:
        print(i)
else:
    print(-1)


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

ans = 1000
ans_list1 = []
ans_list2 = []
l = [0,0]
d = [0,0]

for i in range(1,n):
    if a[i-1] <= a[i]:
        l[1] = i
        ans_list2.append(d)
        d = [i,i]
    else:
        d[1] = i
        ans_list1.append(l)
        l = [i,i]
ans_list1.append(l)
ans_list2.append(d)

for i in range(len(ans_list1)):
    k = ans // a[ans_list1[i][0]]
    ans += (a[ans_list1[i][1]] - a[ans_list1[i][0]]) * k

print(ans)

Measured memory_bytes: 9072
sx, sy, tx, ty = gets.split.map(&:to_i)
path = ''

path << 'U' * (ty - sy) + 'R' * (tx - sx)
path << 'D' * (ty - sy) + 'L' * (tx - sx)
path << 'L'
path << 'U' * (ty - sy + 1) + 'R' * (tx - sx + 1)
path << 'D'
path << 'R'
path << 'D' * (ty - sy + 1) + 'L' * (tx - sx + 1)
path << 'U'

puts path



Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f(i,p,q) for(int i=p;i<q;i++)
#define vi vector<int>v;
#define tc int t; cin>>t; while(t--)
//#define an long long n; cin>>n; long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
int main()
{   
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

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

    long long i=1,j=1,ans=0,n,x,y,len; string s; bool flag;
    // tc{
        
    // }
    cin>>n;
    
    while(i*j<n)
    {
        while(i*j<n)
        {
            ans++; j++;
        }
        i++;
        j=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3616
N=int(input())
A=[0]+[int(_) for _ in input().split()]
ans=[0]*(N+1)
result=[]
for i in range(N,0,-1):
    bai=N//i
    if A[i]!=sum(ans[i*b] for b in range(2,bai+1))%2:
        ans[i]=1
        result+=[i]
print(len(result))
print(*result)

Measured memory_bytes: 14096
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

const ll INF = 100000000000000000;

ll a[100002];
ll les[100002];
bool b[100002];
P p[100002];

template <typename T>
struct Edge
{
    int to;
    T cost;
};

template <typename T>
struct WeightedGraph
{
    int n;
    vector<vector<Edge<T>>> g;
    
    WeightedGraph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to, T cost){
        g[from].push_back((Edge<T>){to, cost});
    }
};

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

struct SCCD    //StronglyConnectedComponentsDecomposition
{
    Graph g;
    Graph rg;
    int n;
    vector<bool> used;
    vector<int> cmp;
    vector<int> vs;
    
    SCCD(Graph &g, Graph &rg) : g(g), rg(rg){
        n = g.n;
        used.resize(n);
        cmp.resize(n);
    }
    
    void dfs(int u){
        used[u] = true;
        for(int v : g.g[u]){
            if(!used[v]) dfs(v);
        }
        vs.push_back(u);
    }
    
    void rdfs(int u, int k){
        used[u] = true;
        cmp[u] = k;
        for(int v : rg.g[u]){
            if(!used[v]) rdfs(v, k);
        }
    }
    
    int decomposition(){
        fill(used.begin(), used.end(), false);
        for(int i = 0; i < n; i++){
            if(!used[i]) dfs(i);
        }
        fill(used.begin(), used.end(), false);
        int k = 0;
        for(int i = n - 1; i >= 0; i--){
            if(!used[vs[i]]){
                rdfs(vs[i], k);
                k++;
            }
        }
        return k;
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> a[i];
    Graph g(n), rg(n);
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        g.add_edge(x, y);
        g.add_edge(y, x);
        rg.add_edge(x, y);
        rg.add_edge(y, x);
    }
    SCCD sccd(g, rg);
    int k = sccd.decomposition();
    if(k == 1){
        cout << 0 << endl;
        return 0;
    }
    if(k > n / 2 + 1){
        cout << "Impossible" << endl;
        return 0;
    }
    for(int i = 0; i < k; i++) les[i] = INF;
    int ales[100002];
    for(int i = 0; i < n; i++){
        if(a[i] < les[sccd.cmp[i]]){
            les[sccd.cmp[i]] = a[i];
            ales[sccd.cmp[i]] = i;
        }
    }
    ll ans = 0;
    for(int i = 0; i < k; i++){
        b[ales[i]] = true;
        ans += les[i];
    }
    for(int i = 0; i < n; i++) p[i] = P(a[i], i);
    sort(p, p + n);
    int i = 0;
    int s = 0;
    while(s < k - 2){
        if(!b[p[i].second]){
            ans += p[i].first;
            s++;
        }
        i++;
    }
    cout << ans << endl;
}

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

#define px 20

int main() {

  while( true ) {

    long long int r, n;
    cin >> r >> n;
    if ( r == 0 ) break;

    long long int dy[50][2] = {};

    for ( long long int i = 0; i < n; i++ ) {
      long long int minx, maxx, h;
      cin >> minx >> maxx >> h;
      minx += px;
      maxx += px;
      for ( long long int j = minx; j < maxx; j++ ) {
	dy[j][1] = max( dy[j][1], h );
	dy[j+1][0] = max( dy[j+1][0], h );
      }
    }
    
    double ans = 50.0;

    for ( long long int i = px - r + 1; i < px + r; i++ ) {
      double x = i - px;
      double y = sqrt( r * r - x * x );
      ans = min( ans, dy[i][0] - y + r );
      ans = min( ans, dy[i][1] - y + r );
    }
    ans = min( ans, 0.0 + dy[px-r][1] + r );
    ans = min( ans, 0.0 + dy[px+r][0] + r );
    cout << fixed << setprecision(10) << ans << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 1236
#include <stdio.h>

int main(void) {

	int W,H,x,y,r;

	scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
	if (x>0&&y>0) {
    if (x+r<=W) {
	if (y+r<=H) 
	printf("Yes\n");
	else
	printf("No\n");
	}
	else
	printf("No\n");
	}  
	else
	printf("No\n");
	return 0;
}

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

int main() {
  int s;
  int n = 0;
  
  cin >> s;
  
  if(s==100|s==10|s==1) n=1;
  if(s==110|s==11|s==101) n=2;
  if(s==111) n=3;
 
  cout << n << endl;
}


Measured memory_bytes: 256
V,E,r = map(int, input().split())
edges = []
for _ in range(E):
    tmp = [int(x) for x in input().split()]
    edges.append(tmp)
 
d = [float('inf') for _ in range(V)]
d[r] = 0
 
for _ in range(V-1):
    count = 0
    for x in edges:
        s,t,w = x
        if d[t] > d[s] + w:
            count += 1
            d[t] = d[s] + w
    if count == 0:
        break
 
for x in d:
    if x == float('inf'):
        print('INF')
    else:
        print(x)


Measured memory_bytes: 108664
#include <iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<math.h>

#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
    int n,d;
    cin >>n>>d;
    vector<vector<float> > v(n, vector<float>(d,0));
    REP(i,n)
        REP(j,d)
            cin >> v[i][j];
    float res=0;
    int cnt=0;
    float dum;
    for(int i=1;i<n;i++) {
        for(int j=0;j<i;j++) {
            REP(k,d) res += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
            dum = sqrt(res);
            if (static_cast<int>(dum) == dum) cnt++;
            res = 0;
        }
    }
    cout <<cnt<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
char s[1000000];
int ans[1000000];
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=2;i<=len;i++){
		if(s[i-1]=='<'&&s[i]=='>') a[i]=1;
		else{
			if(s[i-1]=='>'&&s[i]=='<') a[i]=-1;
		}
	}
	if(s[1]=='<') a[1]=-1;
	else a[1]=1;
	if(s[len]=='<') a[len+1]=1;
	else a[len+1]=-1;
	for(int i=1;i<=len+1;i++){
		if(a[i]==-1){
			int k=i-1,l=i+1,cnt=0;
			while(k>0){
				cnt++;
				ans[k]=max(ans[k],cnt);
				if(a[k]==1) break;
				k--;
			}
			cnt=0;
			while(l<=len+1){
				cnt++;
				ans[l]=max(ans[l],cnt);
				if(a[l]==1) break;
				l++;
			}
		}
	}
	long long sum=0;
	for(int i=1;i<=len+1;i++) sum+=ans[i];
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const int MAX = 1e6 + 5;

int n,m,p,cor=0,wrn=0;
set<int> v;
string s;
map<int,bool> c;
map<int,int> pen;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	REP(i,MAX){
		c[i] = 0;
	}
	cin>>n>>m;
	REP(i,m){
		cin>>p>>s;
		v.insert(p);
		if(s == "AC" && !c[p]){
			c[p] = 1;
			cor++;
		}
		else if(s == "WA" && !c[p])
			pen[p]++;
	}
	PTR(it,v){
		if(c[*it])
			wrn += pen[*it];
	}
	cout<<cor<<' '<<wrn;

	return 0;
}

Measured memory_bytes: 56576
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CHAR_MAX		200005									// 最大文字数

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_CHAR_MAX];									// 文字列
static int siSLen;												// 文字列長
static int si1BCnt[D_CHAR_MAX];									// 黒数
static int si1WCnt[D_CHAR_MAX];									// 白数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 文字列長 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siSLen);

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);

	// 個数 - 取得
	for (i = 0; i < siSLen; i++) {
		if (sc1Str[i] == '#') {
			si1BCnt[i]++;
		}
		else {
			si1WCnt[i]++;
		}
	}

	// 累積和
	for (i = 1; i < siSLen; i++) {
		si1BCnt[i] += si1BCnt[i - 1];
		si1WCnt[i] += si1WCnt[i - 1];
	}

	// 最小値 - 取得
	int liMin = si1BCnt[siSLen - 1];
	if (liMin > si1WCnt[siSLen - 1]) {
		liMin = si1WCnt[siSLen - 1];
	}
	for (i = 0; i < siSLen; i++) {
		int liCnt = si1BCnt[i] + si1WCnt[siSLen - 1] - si1WCnt[i];
		if (liMin > liCnt) {
			liMin = liCnt;
		}
	}

	return liMin;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1BCnt, 0, sizeof(si1BCnt));						// 黒数
	memset(si1WCnt, 0, sizeof(si1WCnt));						// 白数

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1920
<?php
  $pageList = [];
  while(($line = trim(fgets(STDIN))) !== ''){
    sscanf($line,"%s %d",$word,$page);
    if(!isset($pageList[$word])){
      $pageList[$word] = [];
    }
    $pageList[$word][] = $page;
  }

  ksort($pageList);

  foreach($pageList as $word => $vals){
    echo $word . "\n";
    sort($vals);
    echo implode(' ',$vals) . "\n";
  }

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

vector<int> Prime;
void PrimeCalc() {
  bool IsPrime[1000000];
  for(int i=0; i<1000000; i++) {
    IsPrime[i] = true;
  }
  IsPrime[0] = IsPrime[1] = false;
  for (int i=2; i<1000000; i++) {
    if (IsPrime[i]) {
      Prime.push_back(i);
      for (int j=2*i; j<1000000; j+=i) {
        IsPrime[j] = false;
      }
    }
  }
}

void solve() {
  PrimeCalc();
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i=0; i<Prime.size(); i++) {
      if (Prime[i]<=n) {
        ans++;
      } else {
        break;
      }
    }
    cout << ans << endl;
  }
}

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

Measured memory_bytes: 4240
*d=0;*c=0,2,5,5,4,5,6,3,7,6;eval"N,_,*A="+`dd`.split*?,;N.times{|i|d[i]&&A.map{|x|d[t=i+c[x]]=[d[t]||0,d[i]*10+x].max}};p d[N]

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


using namespace std;


using ull = unsigned long long;


int main() {
    ull X;
    cin >> X;

    ull ans = 0;
    ans += (X / 500) * 1000;
    ans += ((X % 500) / 5) * 5;
    cout << ans << endl;
}


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

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

	ll cnt = n/(a+b) * a;
	cnt += min(a, n%(a+b));

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
#define mod 1000000007

int N;
ll A[100], x;

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> N;
  for(int i = 0;i < N;i++) {
    cin >> x;
    for(int i = 0;i < 60;i++) {
      ll temp = x & (1LL << i);
      if(temp) A[i]++;
    }
  }
  for(int i = 0;i < 60;i++) {
    A[i] = A[i]*(N-A[i]);
  }
  for(int i = 1;i <= 60;i++) {
    A[i] = A[i] + (A[i-1] >> 1);
    A[i-1] = A[i-1] & 1;
  }
  for(int i = 0;i <= 60;i++) {
    A[i] %= mod;
  }

  ll p2 = 1;
  ll ans = 0;
  for(int i = 0;i <= 60;i++) {
    ans = (ans + A[i]*p2)%mod;
    p2 *= 2;
    p2 %= mod;
  }
  cout << ans;

  return 0;
}


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

const int N = 101010;

char a[N];
int n, ans;

int main(void) {
  scanf("%s", a + 1);
  n = strlen(a + 1);
  if (n & 1) {
    int m = n - n / 2; ans = m - 1;
    for (int i = 0; i <= n / 2; i++) {
      if (a[m - i] != '0' || a[m + i] != '0') break;
      ans = m + i;
    }
    for (int i = 0; i <= n / 2; i++) {
      if (a[m - i] != '1' || a[m + i] != '1') break;
      ans = max(m + i, ans);
    }
  } else {
    int m = n / 2; ans = m;
    for (int i = 0; i <= n / 2; i++) {
      if (a[m - i] != '0' || a[m + 1 + i] != '0') break;
      ans = m + i + 1;
    }
    for (int i = 0; i <= n / 2; i++) {
      if (a[m - i] != '1' || a[m + 1 + i] != '1') break;
      ans = max(m + i + 1, ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
// #define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 100000000000;
#define pp pair<ll, pair<ll, ll>> 
// #define fi first
// #define se second
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
 
/*--------------------------------------------------------------------------------

--------------------------------------------------------------------------------*/

int main(){
    ll n; cin >> n;
    vector<Vl> w(19, Vl(19));
    while(n--){
        string s; cin >> s;
        bool f = false;
        ll m = 0;
        rep(i, 0, sz(s)) if(s[i]=='.') f = true;
        if(f){
            ll t = 0;
            f = false;
            ll rest = 1000000000LL;
            rep(i, 0, sz(s)){
                if(s[i]=='.') f = true;
                else{
                    m *= 10;
                    m += s[i]-'0';
                    if(f) rest /= 10;
                }
            }
            m *= rest;
        }else{
            rep(i, 0, sz(s)){
                m *= 10;
                m += s[i]-'0';
            }
            m *= 1000000000LL;
        }
        // cout << m << endl;
        ll c2 = 0, c5 = 0;
        while(m%2==0 && c2 < 18){
            m /= 2;
            c2++;
        }
        while(m%5==0 && c5 < 18){
            m /= 5;
            c5++;
        }
        w[c2][c5]++;
    }
    ll ans = 0;
    Rep(i, 0, 18){
        Rep(j, 0, 18){
            Rep(k, 0, 18){
                Rep(l, 0, 18){
                    if(i+k < 18 || j+l < 18) continue;
                    if(i==k && j==l) ans += w[i][j] * (w[i][j]-1);
                    else ans += w[i][j]*w[k][l];
                }
            }
        }
    }
    ans /= 2;
    co(ans);

    return 0;
}

Measured memory_bytes: 3608
/*Made by Shivam Solanki*/
#include<bits/stdc++.h> 
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define repllr(i,k,n) for (ll i = n; i >= k; --i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<n/(a+b)*a+min(n%(a+b),a)<<'\n';
} 
 
  
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

	int main(){
	
		int a,b,c,d,x,y;
		
		while(1){
			scanf("%d%d",&a,&b);
			d=0;
			if(a==0 && b==0){
				break;
			}
			if(a>=b){
				x=a;
				y=b;
			}
			else if(a<b){
				x=b;
				y=a;
			}
			
			while(1){
				c=x%y;
				x=y;
				y=c;
				d=d+1;
				if(y==0){
					printf("%d %d\n",x,d);
					break;
				}
			}
		}
	return 0;
}

Measured memory_bytes: 600