akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

lint N;

int main()
{
    cin >> N;
    lint s = 1;
    while (s * (s - 1) / 2 < N) s++;

    if (s * (s - 1) / 2 != N)
    {
        cout << "No" << endl;
        exit(0);
    }
    cout << "Yes" << endl;
    vector<vector<lint>> S(s);
    int now = 1;
    REP(i, s)
    {
        FOR(j,i + 1, s)
        {
            S[i].push_back(now);
            S[j].push_back(now);
            now++;
        }
    }
    cout << s << endl;
    for (auto vec : S)
    {
        cout << vec.size();
        for (auto val : vec) cout << " " << val;
        cout << endl;
    }
}


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

int main(void){
	int N;
	cin>>N;
	int A[N][2];
	for(int j=0;j<2;j++)
	for(int i=0;i<N;i++)
		cin>>A[i][j];
	
	for(int i=0;i<N-1;i++){
		A[i+1][0] += A[i][0];
		A[N-1-(i+1)][1] += A[N-1-i][1];
	}

	int ans = 0;
	for(int i=0;i<N;i++)
		if(ans < A[i][0]+A[i][1])ans = A[i][0]+A[i][1];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =1e5+10;
const int mod=1e9+7;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    string t;
    cin>>t;
    int n=s.size();
    int k=t.size();
    int ans=1e9;
    for(int i=0;i<n;i++)
    {
        if(i+k-1>=n)
            break;
        string g=s.substr(i,k);
        int cnt=0;
        for(int j=0;j<k;j++)
        {
            if(g[j]!=t[j])
                cnt++;
        }
        ans=min(ans,cnt);

    }
    cout<<ans<<'\n';







}


Measured memory_bytes: 3672
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.*;

/**
 *
 * @author nai
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int ans = 0;
        //ABの方がオトクな場合
        if(A + B > C * 2){
            //ans1
            int needC = Math.min(X,Y) * 2;
            ans += needC * C ; 
            ans += (X > Y ? (X - needC / 2) * A : (Y - needC / 2) * B ); 
            
            //ans2
            needC = Math.max(X, Y) * 2;
            int ans2 = needC * C;
            if(ans2 < ans)
                ans = ans2;
            
            
        }
        else 
        {
            ans += A * X + B * Y;
        }
        System.out.println(ans);
    }
    
}


Measured memory_bytes: 23764
n,k = map(int,input().split())
lis = list(map(int,input().split()))
yakisoba = [0 for i in range(n)]
yakisaba = [0 for i in range(n)]
for i in range(n):
  for j in range(n):
    if lis[i] > lis[j]:
      yakisoba[i] += 1
      if i < j:
        yakisaba[i] += 1
ans = sum(yakisaba)
num = sum(yakisoba)
nu = sum(yakisaba)
print(((nu*k + num * (k * (k-1)) // 2)%(10 ** 9 + 7)))

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


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	string s;
	cin>>s;
	int n=s.length();
	s=string(n,'x');
	cout<<s<<endl;

	return 0;
}

Measured memory_bytes: 256
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
using namespace std;


vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}


int main()
{
    int n, m, k, a,x,y;
    int syogen[15][15];
    for (int i = 0; i < 15; i++) {
        for (int j = 0; j < 15; j++) {
            syogen[i][j] = -1;
        }
    }
    

    cin >> n ;

    for (int i = 0; i < n; i++) {
        cin >> a;

        for (int j = 0; j < a; j++) {
            cin >> x >> y;
            syogen[i][x - 1] = y;
        }
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        bool ok = true;
        vector<int> S = IntegerToVector(bit, n);
        int state[15];
        for (int i = 0; i < 15; i++) {
            state[i] = 0;
        }
        for (int j : S) {
            state[j] = 1;
        }

        for(int k : S) {
            for (int i = 0; i < n; i++) {
                if (syogen[k][i] == 0) {
                    if (state[i] != 0) {
                        ok = false;
                        break;
                    }
                }
                else if (syogen[k][i] == 1) {
                    if (state[i] != 1) {
                        ok = false;
                        break;
                    }
                }
            }
            if (ok == false)break;
        }
        if (ok) {
           if(ans<S.size()) ans = S.size();
        }


    }
    cout << ans << endl;
}



Measured memory_bytes: 3604
/* ex3_2
    riverstone*/

#include<stdio.h>
 
int main(void){
    //numberをint型で定義して入力する。
    int number;
    scanf("%d", &number);
 
    // numberを10で割った余りをswitchで場合分け
    switch (number % 10){
    case 2: case 4: case 5: case 7: case 9:
        printf("hon\n");
        break;
    
    case 0: case 1: case 6: case 8:
        printf("pon\n");
        break;
 
    case 3:
        printf("bon\n");
        break;
    }
    return 0;
}

Measured memory_bytes: 1660
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [n] <- readInt
  a <- readInt
  print $ solve a

solve a = a'
  where
    a' = sum $ map (f . (\xs -> (head xs, length xs))) (group $ sort a)

f (num, len)
  | num > len = len
  | otherwise = len - num


Measured memory_bytes: 17788
#include <bits/stdc++.h>
#define int long long

using namespace std;
const int INF = 1e18;

struct edge
{
    int to;
    int cost;
};
using Graph = vector<vector<edge>>;

#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
Graph G;

void dijkstra(int start)
{
    int seen[10010];
    int dist[10010];

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    for (int i = 0; i < n; i++)
    {
        seen[i] = (i == start) ? GRAY : WHITE;
        dist[i] = (i == start) ? 0 : INF;
        pq.push(make_pair(dist[i], i));
    }

    while (!pq.empty())
    {
        auto now = pq.top();
        pq.pop();
        int u = now.second;
        int distU = now.first;

        seen[u] = BLACK;

        for (auto ne : G[u])
        {
            int v = ne.to;
            int cv = ne.cost;
            if (dist[u] + cv < dist[v])
            {
                dist[v] = dist[u] + cv;
                pq.push(make_pair(dist[v], v));
                seen[v] = GRAY;
            }
        }
    }

    for (int i = 0; i < n; i++)
        cout << i << " " << dist[i] << endl;
}

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    cin >> n;
    G.resize(n);

    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int v, c;
            cin >> v >> c;
            G[u].push_back((edge){v, c});
        }
    }

    dijkstra(0);
}

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



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

int N, P;
string S;
int cnt[10010];

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


signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> P >> S;
    if (P==2) {
        int ans = 0;
        rep(i, N) if ((S[i]-'0')%2==0) ans += i+1;
        cout << ans << endl;
        exit(0);
    }
    if (P==5) {
        int ans = 0;
        rep(i, N) if (S[i]=='0' || S[i]=='5') ans += i+1;
        cout << ans << endl;
        exit(0);
    }
    
    reverse(S.begin(), S.end());
    cnt[0] = 1;
    int now = 0;
    int ans = 0;
    rep(i, N) {
        now += (S[i]-'0')*mod_pow(10, i, P);
        now %= P;
        ans += cnt[now];
        cnt[now]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
in1 = input()
in2 = input()
NK_str = in1.split(" ")
p_str = in2.split(" ")
NK = [int(i) for i in NK_str]
p = [int(j) for j in p_str]
p.sort()
sum = 0
for i in range(NK[1]):
  sum += p[i]

print(sum)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() { 
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  vi water,suger;
  rep(i,f+1){
    rep(j,f+1){
      int x = i*c+j*d;
      int y = i*a*100+j*b*100;
      if(x<=f)suger.push_back(x);
      if(y<=f)water.push_back(y);
    }
  }
  int ax=0,ay=0;
  double rate = 0;
  for(auto s:suger){
    for(auto w:water){
      if(s+w>f)continue;
      double z = (double)s/((double)s+(double)w);
      if(z < rate)continue;
      if((double)s/(double)e*100 > w)continue;
      ax = s;
      ay = w;
      rate = z;
    }
  }
  cout<<ax+ay<<" "<<ax<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

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

	ll x;
	cin >> x;

	int tier = (x / 200);
	cout << 10 - tier << '\n';
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    //int c=0;
    while(t--) {

       ll n,i,j,k;
       vector<pair<ll,ll> >v;
       cin>>n;
        for(i=0;i<n;i++)
        {
            cin>>j>>k;
            v.pb({j,k});
        }
        ll f=0;
        for(i=0;i<n-2;i++)
        {
            if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second)
            {
                f=1;
                break;
            }
        }
        if(f)
            cout<<"Yes";
        else
            cout<<"No";
    }

}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int a[10],b[10];
char c;
int main() {
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5];
b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];
    while(cin>>c){
if(c=='S'){
b[0]=a[4];b[1]=a[0];b[5]=a[1];b[4]=a[5];}else
if(c=='N'){
b[0]=a[1];b[1]=a[5];b[5]=a[4];b[4]=a[0];}else
if(c=='E'){
b[0]=a[3];b[2]=a[0];b[5]=a[2];b[3]=a[5];}else
{b[0]=a[2];b[2]=a[5];b[5]=a[3];b[3]=a[0];}
a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];}
cout<<a[0]<<endl;
	return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#define M 1<<17
using namespace std;
int p[M][11],d[M],c[M],v[M],n,m,q,i,j,k,a,b;
vector<int>G[M];
int f(int u,int s,int l,int i=0)
{
	if(s>=0&&!p[u][s])for(p[u][s]=l;i<G[u].size();i++)f(G[u][i],s-1,l);
}
main()
{
	for(cin>>n>>m;i++<m;G[a].push_back(b),G[b].push_back(a))cin>>a>>b;
	cin>>q;
	for(j;j<q;j++)cin>>v[j]>>d[j]>>c[j];
	for(;q--;)for(i=d[q]+1;i--;)f(v[q],i,c[q]);
	for(;k++<n;)cout<<p[k][0]<<endl;
}

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

int mygcd(int x, int y){
  if (x%y==0) return y;
  return mygcd(y, x%y);
}
int mylcm(int x, int y) {
  return x*y/mygcd(x, y);
}

int main() {
  int K; cin>>K;
  int res=0;
  for (int i=1; i<=K; i++) {
    for (int j=1; j<=K; j++) {
      for (int k=1; k<=K; k++) {
        res+=mygcd(i, mygcd(j, k));
      }
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 A, B, C, K;
  cin >> A >> B >> C >> K;
  i64 ans;
  if(K<=A){
    ans = K;
  } else if(K<=A+B){
    ans = A;
  } else {
    ans = A - (K-A-B);
  }

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

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

Measured memory_bytes: 3648
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<string> w(n);
    map<string, int> wmap;
    
    char last_char = ' ';
    rep(i, n)
    {
        cin >> w[i];
        
        if (i>0 && last_char != w[i][0])
        {
            cout << "No" << endl;
            return 0;
        }
        
        wmap[w[i]] += 1;
        if (wmap[w[i]] > 1)
        {
            cout << "No" << endl;
            return 0;
        }
        
        last_char = *(w[i].rbegin());
    }
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
num = [1]

x = 6
while x < 100000:
    num.append(x)
    x *= 6

x = 9
while x < 100000:
    num.append(x)
    x *= 9

dp = [n] * 1100000
dp[0] = 0

for i in range(n):
    for j in num:
        dp[i + j] = min(dp[i + j], dp[i] + 1)

print(dp[n])


Measured memory_bytes: 11636
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///


void solve(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x=a*c;
	ll y=b*c;
	ll z=a*d;
	ll m=b*d;
	ll ans=max(x,max(y,max(z,m)));
	cout<<ans<<endl;
	
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}

/****************ALHAMDULILLAH******************/


Measured memory_bytes: 3688
#include<iostream>
#include<string>
#include<iomanip>
#include<stdio.h>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<cstdlib>

using namespace std;

int main(void){
	long n;
	long a[110];
	long long min=10000000000;
	long max=1;
	cin >> n;
	for(int i=1;i <= n;i++){
		cin >> a[i];
		if(min > a[i] ){
			min = a[i];
		}
		if(max < a[i]){
			max = a[i];
		}
	}
	cout << max - min << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] arts){
    Scanner scan = new Scanner(System.in);
    int p = scan.nextInt();
    int q = scan.nextInt();
    int r = scan.nextInt();
    
    int sum1 = p + q;
    int sum2 = p + r;
    int sum3 = q + r;
    
    if(sum1 <= sum2 && sum1 <= sum3){
      System.out.println(sum1);
    }else if(sum2 <= sum1 && sum2 <= sum3){
      System.out.println(sum2);
    }else{
      System.out.println(sum3);
    }
  }
}

Measured memory_bytes: 21844
n, m = list(map(int, input().split()))
cities = []

for i in range(m):
    p, y = list(map(int, input().split()))
    cities.append([p, y, i])

sorted_cities = sorted(cities, key=lambda x: (x[0], x[1]))
cnt = 1
ans = []
for i in range(m-1):
    p_id = str(sorted_cities[i][0]).rjust(6, '0')
    c_id = str(cnt).rjust(6, '0')
    ans.append([sorted_cities[i][2], p_id+c_id])
    if sorted_cities[i][0] != sorted_cities[i+1][0]:
        cnt = 1
    else:
        cnt += 1

p_id = str(sorted_cities[m-1][0]).rjust(6, '0')
c_id = str(cnt).rjust(6, '0')
ans.append([sorted_cities[m-1][2], p_id+c_id])
ans.sort()

for id in ans:
    print(id[1])



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

int main()
{
	int n;
	cin >> n;
	auto l = vector<int>(n);
	for(auto&& ll : l) cin >> ll;
	sort(l.begin(), l.end());
	int ans = 0;
	for(int i = 0; i < n - 2; ++i){
		int a = l[i];
		for(int j = i + 1; j < n - 1; ++j){
			int b = l[j];
			if(a == b) continue;
			for(int k = j + 1; k < n; ++k){
				int c = l[k];
				if(b == c) continue;
				if(c < a + b) ++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(){
    long long int x,y,a,ans=0;
    cin>>x>>y;
    while(x<=y){
        ans++;
        x*=2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import sqrt, cos, pi

a, b, h, m = map(int, read().split())
theat = abs(h * 30 - 6 * m + m / 2) * pi / 180
print(sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(theat)))


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

int main(void){
    int n, result = 0;
    
    cin >> n;
    
    vector<int> l(n);
    
    rep(i, n){
        cin >> l.at(i);
    }
    
    sort(l.begin(), l.end());
    
    rep(i, n-2){
        for(int j = i+1; j < n-1; j++){
            for(int k = j+1; k < n; k++){
                if(l.at(k) >= l.at(i) + l.at(j)) break;
                result++;
            }
        }
    }
    
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int A,B,mA,mB,m,a[500010],b[500010],ans;
int main(){
	cin>>A>>B>>m;
	mA=mB=1000000000;
	FOR(i,1,A) getint(a[i]),mA=min(mA,a[i]);
	FOR(i,1,B) getint(b[i]),mB=min(mB,b[i]);
	ans=mA+mB;
	while (m--){
		int x,y,c;
		getint(x),getint(y),getint(c);
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<ll, ll> ll_ll;
typedef pair<double, int> d_i;
const int MOD = 1e9 + 7;
const ll INF = LLONG_MAX / 10;
struct edge { int v, w; };

int main() {
	string s; cin >> s;
	int N = s.length();
	int sum = 0;
	rep(i, N) sum += s[i] - '0';
	cout << max(sum, s[0] - '0' - 1 + (N - 1) * 9) << endl;
}


Measured memory_bytes: 256
#include<cstdio>  
#include<algorithm>  
#include<vector>  
#include<queue>  
#include<string>  
#include<cstring>  
#include<iostream>  
#include<map>
using namespace std;
#define ll long long  
const int maxn = 1e5 + 500;
char mp[500][1000];
char a[500][500];
int n;
bool ok() {
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (a[i][j] != a[j][i])
				return false;
	return true;
}
int main() {
	while (~scanf("%d", &n)) {
		int ans = 0;
		for (int i = 0; i < n; i++)
			scanf("%s", &mp[i]);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n - 1; j++)
				mp[i][j + n] = mp[i][j];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++)
				for (int k = 0; k < n; k++)
					a[j][k] = mp[j][k + i];
			if (ok())ans += n;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 768
fun main(args : Array<String>) {
    val (n, w) = readLine()!!.split(" ").map { it.toInt() }
    val ww = mutableListOf<Int>()
    val vv = mutableListOf<Int>()

    repeat(n) {
        val (w1, v1) = readLine()!!.split(" ").map { it.toInt() }
        ww.add(w1)
        vv.add(v1)
    }

    val dp = Array(n+1) { LongArray(w+1){0} }

    for (i in 1..n) {
        for (j in 1..w) {
            if (j >= ww[i-1]) {
                dp[i][j] = Math.max(dp[i-1][j-ww[i-1]] + vv[i-1], dp[i-1][j])
            } else {
                dp[i][j] = dp[i-1][j]
            }
        }
    }

    println(dp[n][w])
}

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

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

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

    int ans = 0;
    for(int i=0; i<n; i++){
        ans += 2 * min(x[i], k - x[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007

const ll INF=100000;

int main(){
  ll a[100][100]={0},b[100];
  ll n,m,c;
  cin  >> n >>m >>c;
  rep(i,m)cin >>b[i];
  rep(i,n)rep(j,m)cin >> a[i][j];
  ll ans=0;
  rep(i,n){
    ll res=0;
    rep(j,m){
      res+=a[i][j]*b[j];
    }
    res+=c;
    if(res>0)ans++;
  }
  cout << ans << endl;
}


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

using namespace std;

const int MAX = 101;
typedef pair<int,int> P;
vector<int> V[MAX];

void solve(){
  int odd = 0;

  for(int i = 0; i < MAX; i++) odd += V[i].size()%2;

  if(odd == 2 && V[1].size()%2 && V[2].size()%2) cout << "OK" << endl;
  else cout << "NG" << endl;
}

int main(){

  P p;

  while(cin >> p.first >> p.second){
    for(int i = 0; i < MAX; i++) V[i].clear();
    V[p.first].push_back(p.second);
    V[p.second].push_back(p.first);
    
    while(cin >> p.first >> p.second && p.first+p.second){
      V[p.first].push_back(p.second);
      V[p.second].push_back(p.first);
    }

    solve();
  }
  return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<algorithm>

using namespace std;

#define INF (1<<30)

int d,g;
int p[10];
int c[10];

bool use[10];

int dfs(int depth){
	if(depth == d){
		int count = 0;
		int score = 0;
		for(int i = 0;i < d;i++){
			if(!use[i])continue;
			score+=c[i];
			score+=p[i]*100*(i+1);
			count+=p[i];
		}
		for(int i = d-1; i!=-1; i--){
			if(use[i])continue;
			for(int j = 0;j < p[i];j++){
				if(score >= g)return count;
				score+=100*(i+1);
				count++;
			}
		}
		if(score >= g)return count;
		else return INF;
	}
	int ans = 0;
	ans = dfs(depth+1);
	use[depth] = 1;
	ans = min(ans, dfs(depth+1));
	use[depth] = 0;
	return ans;
}

int main(){

	cin >> d >> g;

	for(int i = 0;i < d;i++){
		cin >> p[i] >> c[i];
		use[i] = 0;
	}

	cout << dfs(0) << endl;

	return 0;
}

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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll n;
	cin>>n;
	ll a,b;
	cin>>a>>b;
	ll c,d;
	cin>>c>>d;
	if(a>b){
		swap(a,b);
	}
	ll t = 0;
	ll s = d-c;
	rep(i,n-1){
		if(i==n-2 && a+c > b){
			a -= d;
			t += s;
		}
		else if(a<b){
			a += c;
			t += s;
		}
		else{
			a -= d;
			t += s;
		}
	}
	if(abs(a-b)<=t){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}


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

Measured memory_bytes: 256
#include <stdio.h>

int a,b,c ;
 
int main(void){
    
    scanf ("%d%d%d",&a,&b,&c) ;
    
    if ( a==5 && b==5 && c==7){
        printf ("YES\n") ;
        
    } else if ( a==5 && b==7 && c==5 ){
        printf ("YES\n") ;
        
    } else if ( a==7 && b==5 && c==5 ){
        printf ("YES\n") ;
        
    } else {
        printf ("NO\n") ;
        
    }
    
    return 0 ;
}

Measured memory_bytes: 128
s = input()
p = input()
q = len(s)
for i in range(len(s)):
    f = 1
    for j in range(len(p)):
        f *= (1 if s[(i+j) % q] == p[j] else 0)
        if f == 0:
            break
    if f == 1:
        print("Yes")
        exit()
print("No")


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

template<typename T, typename E> struct LazySegmentTree {
  using F = function<T(T, T)>;
  using G = function<T(T, E)>;
  using H = function<E(E, E)>;
  using P = function<E(E, int)>;

  int n;
  T ti;
  E ei;
  F f;
  G g;
  H h;
  P p;
  vector<T> data;
  vector<E> lazy;

  LazySegmentTree(int n_, F f, G g, H h, T ti = INT_MAX, E ei = INT_MAX,
                  P p = [](E a, int b) { return a; })
      : f(f), g(g), h(h), ti(ti), ei(ei), p(p) {
    init(n_);
  }
  void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    data.assign(n * 2 - 1, ti);
    lazy.assign(n * 2 - 1, ei);
  }
  void build(vector<T> v) {
    for (int i = 0; i < v.size(); ++i) data[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; --i) {
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }
  inline void eval(int len, int k) {
    if (lazy[k] == ei) return;
    if (k * 2 + 1 < n * 2 - 1) {
      lazy[k * 2 + 1] = h(lazy[k * 2 + 1], lazy[k]);
      lazy[k * 2 + 2] = h(lazy[k * 2 + 2], lazy[k]);
    }
    data[k] = g(data[k], p(lazy[k], len));
    lazy[k] = ei;
  }
  T update(int a, int b, E x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(r - l, k);
    if (b <= l || r <= a) return data[k];
    if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      return g(data[k], p(lazy[k], r - l));
    }
    T vl = update(a, b, x, k * 2 + 1, l, (l + r) / 2);
    T vr = update(a, b, x, k * 2 + 2, (l + r) / 2, r);
    return data[k] = f(vl, vr);
  }
  T query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(r - l, k);
    if (b <= l || r <= a) return ti;
    if (a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
};

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

  LazySegmentTree<ll, ll>::F f = plus<ll>();
  LazySegmentTree<ll, ll>::G g = plus<ll>();
  LazySegmentTree<ll, ll>::H h = plus<ll>();
  LazySegmentTree<ll, ll>::P p = multiplies<ll>();

  int n, q; cin >> n >> q;
  LazySegmentTree<ll, ll> seg(n, f, g, h, 0, 0, p);

  while (q--) {
    int com; cin >> com;
    if (com) {
      int s, t; cin >> s >> t;
      cout << seg.query(s - 1, t) << endl;
    } else {
      int s, t, x; cin >> s >> t >> x;
      seg.update(s - 1, t, x);
    }
  }
  return 0;
}



Measured memory_bytes: 6952
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

a,b=get_i
if (a%3).zero? or (b%3).zero? or ((a+b)%3).zero?
  puts "Possible"
else
  puts "Impossible"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cis(s);
    string ans;
    ans = s[2] == s[3] && s[4] == s[5]
            ?"Yes"
            :"No";
    co(ans);
    return 0;
}

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

int main() {
	string W;
	cin >> W;
	vector<int>A(26);
	for (int i = 0; i < W.size(); ++i) {
		A[W[i] - 'a']++;
	}
	string ansS = "Yes";
	for (int i = 0; i < 26; ++i) {
		if (1 == A[i] % 2) {
			ansS = "No";
		}
	}
	cout << ansS << endl;
	return 0;
}

Measured memory_bytes: 3600
X, K, D = map(int, input().split())
X = abs(X)

#最大まで移動するとき
if X >= K * D:
    print(X - K*D)
    exit()

if D > X:
    bef = X
    nex = X - D

    if K % 2 == 0:
        print(abs(bef))
    else:
        print(abs(nex))

else: #D<=X
    bef = X % D
    nex = bef - D

    if  (K - X//D) % 2 == 0:
        print(abs(bef))
    else:
        print(abs(nex))

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

using Graph = vector<vector<int> >;

int n, sum;
vector<bool> seen;
priority_queue<pair<int, int> > pq;

void dfs(const Graph &G, int v, int p){
  seen[v] = true;

  rep(u, n){
    if(u == p) continue;
    if(G[v][u] == -1) continue;
    pq.push(make_pair((-1)*G[v][u], u));
  }

  while(!pq.empty()){
    pair<int, int> tmp;
    tmp = pq.top();
    pq.pop();
    if(seen[tmp.second]) continue;
    sum += (-1)*tmp.first;
    int nv = tmp.second;
    p = v;
    dfs(G, nv, p);
  }

  return;
}

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

  seen.assign(n, false);
  sum = 0;
  dfs(G, 0, -1);

  cout << sum << endl;

  return 0;
}





Measured memory_bytes: 3284
#include<stdio.h>
                #include<string.h>
                 
                int main(){
                	char line[150];
                  	int count=0;
                  	int length;
                  	int i;
                  
                  	scanf("%s",line);
                  	//line[strlen(line)]='\0';
                  	
                  	length=strlen(line);
                  	
                  	for(i=0;i<length;i++){
                      if(line[i]!=line[length-1-i])count++;
                    }
                  	printf("%d",count/2);
                }

Measured memory_bytes: 128
PROGRAM ATCODER

implicit none
integer(8) :: n,i,j,s,dif
integer(8),allocatable :: a(:), b(:), c(:)

read(*,*) n
allocate(a(n)) ; allocate(b(n)) ; allocate(c(n))

dif = 0
do i = 1, n
    read(*,*) a(i),b(i)
end do

c(:) = a(:) + b(:)

dif = -sum(b)

call hsort(n,c)

do i = 1, n, 2
    dif = dif + c(i)
end do

deallocate(a) ; deallocate(b) ; deallocate(c)

write(*,'(i0)') dif

END PROGRAM ATCODER


subroutine hsort(n, x)
  implicit none
  integer, intent(IN) :: n
  real(8), intent(INOUT) :: x(n)
  ! local
  integer k
  real(8) :: tmp
  ! external subroutine
  external mkheap

  do k = n/2, 1, -1
     tmp = x(k)
     call mkheap(n, x, k, n, tmp)
  enddo

  do k = n, 2, -1
     tmp = x(k)
     x(k) = x(1)
     call mkheap(n, x, 1, k-1, tmp)
  end do

  return
end subroutine hsort

subroutine mkheap(n, x, root, leaf, val)
  implicit none
  integer, intent(IN)    :: n, root, leaf
  real(8), intent(INOUT) :: x(1:n)
  real(8), intent(IN)    :: val
  ! local
  integer :: i, j

  i = root
  j = i * 2

  do
     if (j > leaf) exit

     if (j < leaf) then
        if (x(j) > x(j+1)) j = j + 1
     end if

     if (x(j) < val) then
        x(i) = x(j)
        i = j
        j = i * 2
     else
        j = leaf + 1
     endif
  end do

  x(i) = val

  return
end subroutine mkheap


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;

char a[MAXN];

int main()
{
//	freopen("D:\\test\\in.txt", "r+", stdin);
	scanf("%s", a + 1);
	int len = strlen(a + 1);
	int maxn = 0x3f3f3f3f;
	for (int i = 1; i < len; i++)
		if (a[i] != a[i + 1]) maxn = min(maxn, max(i, len - i));
	if (maxn == 0x3f3f3f3f)
		cout << len << endl;
	else
		cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for i in range(1, K+1):
    if i > N:
        break
    for j in range(i+1):
        temp = V[:j] + V[N-(i-j):]
        temp = sorted(temp)
        for k in range(K-i):
            if k >= i:
                break
            if temp[k] < 0:
                temp[k] = 0
        ans = max(ans, sum(temp))
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< ll > 	vi;
typedef pair< ll, ll > 	ii;

#define endl 		"\n"
#define pb		push_back
#define all(c) 		(c).begin(),(c).end()
#define rep(i,n)	for(ll i=0LL; i<(n); i++)
#define MOD 		1000000007
#define INF 		(int)1e9
#define MEM(a, b) 	memset(a, (b), sizeof(a))

double tick() {static clock_t oldt, newt = clock(); double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC; oldt = newt; return diff;}

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


	int a;
	cin >> a;
	cout << a + (a * a) + (a * a * a);


// cout<<"\nExecution time : "<<tick()<<"\n";
	return 0;
}

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


int main() {
//int N;
//cin >> N;
//string S;
//cin >> S;
int N, M;
cin >> N >> M;
int tap = 1;
int count = 0;
while (tap < M){
    tap += N;
    count++;
    tap--;
}
cout << count << endl;
//int vec[200010];
//for(int i = 0; i < N; i++) cin >> vec[i];

//if() cout << "" << endl;
//else cout << "" << endl;

// cout << "" << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}Node1;
 
typedef struct node *Node;
 
Node root;
 
Node treeSearch(Node u, int k){
  while(u != NULL && k != u->key){
      if(k < u->key){
    u = u->left;
      }else{ 
    u = u->right;
      }
    }
  return u;
}
 
void treeDelete(Node z){
  Node y; 
  Node x;
}
 
void insert(int k){
  Node y = NULL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;
 
  while(x != NULL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
    z->parent = y;
  }
  if(y == NULL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z; 
  }
}
 
void inorder(Node u){
 if(u != NULL){
     inorder(u->left);
     printf(" %d",u->key);
     inorder(u->right);
   }
}
 
void preorder(Node u){
 if(u != NULL){   
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for (i = 0;i < n;i++){
    scanf("%s", com);
    if (com[0] == 'f'){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if (t != NULL) printf("yes\n");
      else printf("no\n");
    } else if (com[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    } else if (com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if (com[0] == 'd'){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}



Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int m, d;
  cin >> m >> d;
  int ans = 0;
  for(int j = 1; j <= m; j++)
  {
  for(int i = 1; i <= d; i++)
  {
    int d1 = i % 10;
    int d2 = i / 10;
    if (d1 >= 2 && d2 >= 2 && d1 * d2 == j)
    {
      ans++;
    }
  }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n,m  = map(int, input().split())
L = 0
R = 500000
for i in range(m):
    l,r = map(int, input().split())
    L = max(L, l)
    R = min(R, r)
    l = 0
    r = 0

if 0 >R-L:
    print(0)
else:
    print(R-L+1)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, n) if (s[i] == 'R') ++cnt;
    int cnt2 = 0;
    rep(i, cnt) if (s[i] == 'W') ++cnt2;
    cout << cnt2 << endl;
}



Measured memory_bytes: 3736