akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE MultiParamTypeClasses,FlexibleContexts,FlexibleInstances,TypeSynonymInstances,BangPatterns,RankNTypes,TupleSections #-}
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Control.Arrow
import Debug.Trace
import Text.Printf

import Data.List
import Data.Int
import Data.Bits
import Data.Maybe
import Data.Monoid
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.Base
import Data.Function(on)
import Data.Tuple(swap)
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    (n,l) <- readIntPair
    as <- readInts
    case findIndex (\(x,y) -> x + y >= l) (zip as (tail as)) of
        Nothing -> putStrLn "Impossible"
        Just i -> do
            putStrLn "Possible"
            let ks = [1..i] ++ reverse [i+2..n-1] ++ [i+1]
            putStr $ unlines $ map show ks



-- IO
readInt :: B.ByteString -> Int
readInt = fromJust . fmap fst . B.readInt
readInts :: IO [Int]
readInts = map readInt . B.words <$> B.getLine
readIntPair :: IO (Int,Int)
readIntPair = l2p . map readInt . take 2 . B.words <$> B.getLine
readAllInts :: IO [[Int]]
readAllInts = map (map readInt . B.words) . B.lines <$> B.getContents
readLns :: Read a => IO [a]
readLns = map read . words <$> getLine

-- Utilities
l2p :: [a] -> (a,a)
l2p (a:b:_) = (a,b)
l2p _ = error "l2p: the input list is too short"
p2l :: (a,a) -> [a]
p2l (a,b) = [a,b]
itof :: Int -> Double
itof = fromIntegral
inf :: Int
inf = maxBound `div` 2

-- Monad
stepM_ :: Monad m => a -> (a -> Bool) -> (a -> a) -> (a -> m ()) -> m ()
stepM_ i0 judge incr step = sub i0 where 
    sub i | judge i = step i >> sub (incr i) 
          | otherwise = return ()
rep_ :: Monad m => Int -> (Int -> m ()) -> m ()
rep_ n = stepM_ 0 (<n) (+1)
thru :: Monad m => (v -> m ()) -> v -> m v
thru m v = m v >> return v
memoize :: (Monad m) => (k -> m (Maybe v)) -> (k -> v -> m ()) -> k -> m v -> m v
memoize getter setter key action = do
    mv <- getter key
    case mv of
        Just v -> return v
        Nothing -> action >>= thru (setter key)

-- Array
newUArray :: (MArray (STUArray s) e (ST s),Ix i) => 
             (i,i) -> e -> ST s (STUArray s i e)
newUArray = newArray
newBArray :: (Ix i) => (i,i) -> e -> ST s (STArray s i e)
newBArray = newArray
defaultArray :: (IArray a e,Ix i) => e -> (i,i) -> [(i,e)] -> a i e
defaultArray = accumArray $ curry snd
fromEdges :: Ix i => (i,i) -> [(i,e)] -> Array i [e]
fromEdges = accumArray (flip (:)) []


Measured memory_bytes: 10748
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int n,k;
int a[100010];
int main(){
    while(1){
        scanf("%d%d",&n,&k);
        if(n == 0)
            break;
        REP(i,k)
            scanf("%d",a + i);
        if(k == 1){
            printf("1\n");
            continue;
        }

        sort(a,a + k);

        if(a[0] > 0){
            int maxi = 1,c = 1;
            FOR(i,1,k){
                if(a[i] != a[i - 1] + 1){
                    maxi = max(maxi,c);
                    c = 1;
                }else
                    c++;
            }
            maxi = max(maxi,c);
            printf("%d\n", maxi);
            continue;
        }
        int maxi = 2;int c = 1;
        FOR(i,1,k){
            if(a[i] != a[i - 1] + 1){
                if(c < n)
                    c++;
                maxi = max(maxi,c);
                c = 1;
            }else
                c++;
        }
        if(c < n)
            maxi = max(maxi,c);

        c = 1;bool used = false;
        FOR(i,1,k){
            if(!used && a[i] == a[i - 1] + 2){
                c += 2;
                used = true;
            }else if(a[i] == a[i - 1] + 1)
                c++;
            else{
                maxi = max(maxi,c);
                if(a[i] == a[i - 1] + 2){
                    c = 3;used = true;
                }else{
                    c = 1;
                    used = false;
                }
            }
            maxi = max(maxi,c);
        }
        printf("%d\n", maxi);
    }
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define R(X) cin>>X

using namespace std;
inline int digitSum(int num){
	int out=0;
	while(num!=0){
		out+=num%10;
		num/=10;
	}
	return out;
}
int main(){
	int N;R(N);
	int a,b;R(a);R(b);
	int sum=0;
	for(int i=1;i<=N;i++)
	    if(digitSum(i)<=b&&digitSum(i)>=a)
		    sum+=i;
	cout<<sum;
	return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int ans=0;
  if(M%N==0){
    cout << M/N << endl;
    return 0;
  }
  for(int g=1;g*N<=M;g++){
    if(M%g==0){
      ans = max(ans,g);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<algorithm>
#include<cstdio>
#include<cctype>
using namespace std;
long long n[5];
long long  ma[5]={144000,7200,360,20,1};
long long tuki[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
long long p=31+29+31+30+31+30+31+31+30+31+30+21;
int  seireki(){
	long long ans[6]={0};
	long long kin=0;
	int  i,j;
	/*for(i=0;i<5;i++){
		cout<<n[i]<<endl;
	}*/
	kin=0;
	for(i=n[0]-1;i>=2012;i--){
		if(i%4==0&&i%100!=0||i%4==0&&i%400==0){
			kin+=366;
		}
		else{
			kin+=365;
		}
	}
	for(i=n[1]-1;i>=1;i--){
		kin+=tuki[i];
	}
	if(n[0]%4==0&&n[0]%100!=0||n[0]%4==0&&n[0]%400==0){
		if(n[1]>=3){
			kin++;
		}
	}
	kin+=n[2];
	kin-=p;
	kin%=1872000;
	for(i=0;i<5;i++){
		ans[i]=kin/ma[i];
		kin%=ma[i];
	}
	for(i=0;i<5;i++){
		cout<<ans[i];
		if(i<4){
			cout<<".";
		}
		else{
			cout<<endl;
		}
	}
}
void maya(void){
	long long ans[3];
	long long kin=0;
	int i,j;
	/*for(i=0;i<5;i++){
		kin=kin+n[i]*ma[i];
	}*/
	kin=kin+n[0]*144000;
	kin=kin+n[1]*7200;
	kin=kin+n[2]*360;
	kin=kin+n[3]*20;
	kin+=n[4];
	ans[0]=2012;
	ans[1]=12;
	ans[2]=21;
	//cout<<kin<<endl;
	while(kin--){
		ans[2]++;
		if(ans[2]>tuki[ans[1]]+(ans[1]==2&&(ans[0]%400==0||(ans[0]%4==0&&ans[0]%100!=0)))){
			ans[1]++;
			ans[2]=1;
		}
		if(ans[1]>12){
			ans[0]++;
			ans[1]=1;
		}
	}
	printf("%lld.%lld.%lld\n",ans[0],ans[1],ans[2]);
}
int main(){
	char koyomi[50];
	int i,j;
	while(1){
		cin>>koyomi;
		if(koyomi[0]=='#'){
			break;
		}
		memset(n,0,sizeof(n));
		j=0;
		//out<<strlen(koyomi)<<endl;
		for(i=0;i<strlen(koyomi);i++){
			if(koyomi[i]=='.'){
				j++;
			}
		}
		//printf("%lld.%lld.%lld.%lld.%lld\n",n[0],n[1],n[2],n[3],n[4]);
		if(j==2){
			sscanf(koyomi,"%lld.%lld.%lld",&n[0],&n[1],&n[2]);
			seireki();
		}
		else{
			sscanf(koyomi,"%lld.%lld.%lld.%lld.%lld",&n[0],&n[1],&n[2],&n[3],&n[4]);
			maya();
		}
	}
	return 0;
}
	

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

using namespace std;

int main()
{
   int n,m;
   cin>>n>>m;
   int i = min(n,m);
   int j = max(n,m);
   char a = (char) (i+48);
   string s = "";
   for(int k=0;k<j;k++){
       s=s+a;
   }
   cout<<s<<endl;
   return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int gcd(int p, int q){
    if(p < q) swap(p, q);
    while(q){
        int r = p % q;
        p = q;
        q = r;
    }
    return p;
}

int main(){
    int n, x;
    scanf("%d%d", &n, &x);
    int y[n];
    rep(i, n) scanf("%d", &y[i]);
    int ans = 0;
    rep(i, n) ans = gcd(ans, abs(x-y[i]));
    printf("%d\n", ans);
}

Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
import java.io.*;
 

class Main
{
    public static void main (String[] args)
    {
        
        Scanner sc = new Scanner(System.in);
        int h,w;
        while(true){
            h = sc.nextInt();
            w = sc.nextInt();
            if (h == 0 && w == 0) break;
             
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if ( i == 0 || i == h - 1 || j == 0 || j == w - 1)
                        System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34208
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e8+7;
const int mod = 1e9+7;

int main() {
    
    int n, k;
    scanf("%d%d",&n,&k);
    
    vector<int> a(n);
    
    for(int i = 0; i < n; ++i) {
        scanf("%d",&a[i]);
    }
    
    vector<ll> dp(k+1, 0);
    
    for(int i = 0; i <= a[n-1]; ++i) {
        dp[i] = 1;
    }
    
    for(int child = n-2; child >= 0; --child) {
        ll run = 0;
        vector<ll> new_dp(k+1, 0);
        
        debug() << imie(dp);
        
        for(int used = k; used >= k-a[child]; --used) {
            run += dp[used];
            if(run >= mod) run -= mod;
        }
        
        for(int used = k; used >= 0; --used) {
            new_dp[used] = run;
            run -= dp[used];
            if(run <= 0) run += mod;
            if(used-a[child]-1 >= 0) run += dp[used-a[child]-1];
            if(run >= mod) run -= mod;
        }
        
        dp = new_dp;
    }
    
    cout << dp[k] << endl;
    
    return 0;
}




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

int main(){
  ll N;cin>>N;
  vector<ll>d(N),a(N),b(N);
  for(int i=0;i<N;i++) cin>>a.at(i);
  for(int i=0;i<N;i++) cin>>b.at(i);
  ll minus=0,plus=0;
  
  for(int i=0;i<N;i++){
    d.at(i)=a.at(i)-b.at(i);
    if(d.at(i)<0)
      minus+=(-d.at(i))/2;
    else
      plus+=d.at(i);
  }
  
  if(minus>=plus)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int answer = 0;
		int max5 = 90000;
		int max3 = 900;
		int max1 = 9;

		if (n >= 10000) {
			if (n > 99999)
				answer += max5;
			else
				answer += n - 9999;

		}
		if (n >= 100) {
			if (n > 999)
				answer += max3;
			else
				answer += n - 99;
		}

		if (n >= 10)
			answer += max1;
		else
			answer += n;

		System.out.println(answer);

	}

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define S second
#define F first
#define PI 3.14159265358979323846

ll sqr(ll n) {
    return n*n;
}

const int MOD = 1e9 + 7;

ll binpow(ll a, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 != 0) return (binpow(a, n-1)*a); else {
        ll b = binpow(a, n/2);
        return (b*b);
    }
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

void solve() {
    int n, x, t;
    cin >> n >> x >> t;

    if (n % x == 0) cout << n/x * t << endl; else cout << (n/x + 1) * t << endl;
}

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

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;
int main()
{
	int x, y;
	int countxa = 0;
	int countya = 0;
	int countxb = 0;
	int countyb = 0;
	int a[7] = { 1,3,5,7,8,10,12 };
	int b[4] = { 4,6,9,11 };
	cin >> x >> y;
	for (int i = 0; i < 7; i++)
	{
		if (a[i] == x){
			countxa++;
		}
		if (a[i] == y) {
			countya++;
		}
	}
	for (int l = 0; l < 4; l++)
	{
		if (b[l] == x) {
			countxb++;
		}
		if (b[l] == y) {
			countyb++;
		}
	}
	if (countxa == countya && countxb == countyb) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

#define ll long long
#define gcd(a,b) __gcd(a,b)s
const int N=2e5+10;
const int inf=1e9;
const int mod=1e9+7;

int  main(int argc, char const *argv[])
{
	/*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;

	int p[a], q[b], r[c];

	for(int i=0; i<a; i++)
        cin >> p[i];
    for(int i=0; i<b; i++)
        cin >> q[i];
    for(int i=0; i<c; i++)
        cin >> r[i];

    sort(p, p+a, greater<int>());
    sort(q, q+b, greater<int>());
    sort(r, r+c, greater<int>());

    vector<ll>ans;

    for(int i=0; i<x; i++)
        ans.push_back(p[i]);
    for(int i=0; i<y; i++)
        ans.push_back(q[i]);

    sort(ans.begin(), ans.end(), greater<int>());

    int j=0;
    for(int i=x+y-1; i>=0; i--)
    {
        if(ans[i]<r[j] && j<c)
        {
            ans[i]=r[j];
            j++;
        }
    }

    ll sum=0;

    for(auto it: ans)
        sum+=it;

    cout << sum << endl;

	return 0;
}



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

vector<int> costs;
vector< vector<int> > algo;

  int n, m, k;

int func(int x, vector<int> score, int cost = 0) {
  bool flag = true;
  for (int i= 0; i < m; i++) {
    if (score[i] < k) {
      flag = false;
      break;
    }
  }
  if (flag) {
    return cost;
  }
  else if (x >= n) {
    return INT_MAX;
  } 
  else {
    vector<int> score_i;
    score_i = score;
    for (int i = 0; i < m; i++) {
      score_i[i] += algo[x][i];
    }
    return min(func(x+1, score, cost), func(x+1, score_i, cost+costs[x]));
  }
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
  #endif

  cin >> n >> m >> k;

  costs.reserve(n);
  algo.assign(n, vector<int>(m));

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

    for (int j = 0; j < m; j++) {
      cin >> algo[i][j];
    }
  }

  vector<int> score(m, 0);

  long long ans = func(0, score);

  if (ans == INT_MAX )
    cout << -1  << endl;
  else
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n,d,x;
    cin >> n >> d >> x;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,d){
        rep(j,n){
            rep(k,100){
                if(i+1 == k*a[j]+1)
                    x++;
            }
        }
    }
    cout << x << endl;
}


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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  double x = 380000.0, ans = 0.0;

  for (int i = 0; i < N; i++) {
    double a;
    string b;
    cin >> a >> b;
    if (b == "JPY") {
      ans += a;
    } else {
      ans += x * a;
    }
  }

  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>
#include <map>
#include <utility>

using namespace std;

int main(){

    char n[3];


    for(int i = 0 ;i < 3; i++){
        cin >> n[i];
        if(n[i] == '9'){
            cout << '1';
        }
        else if(n[i] == '1'){
            cout << '9';
        }
        
    }

    cout << endl;

    
}

Measured memory_bytes: 3616
n = int(input())
h = list(map(int, input().split()))

i = 0
ret = 0
cnt = 0
while i < n - 1:
    if h[i] >= h[i + 1]:
        cnt += 1
    else:
        ret = max(ret, cnt)
        cnt = 0
    i += 1
ret = max(ret, cnt)
print(ret)


Measured memory_bytes: 14252
#include<stdio.h>
int main(){
	int n,i,min,range,R[200000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&R[i]);
	}
	min=R[0];
	range=R[1]-R[0];
	for(i=1;i<n;i++){
		if(range<R[i]-min){
			range=R[i]-min;
		}
		if(min>R[i]){
			min=R[i];
		}
	}
	printf("%d\n",range);
	return 0;
}


Measured memory_bytes: 2640
abcd = input()
bit = 0b1000
ans=int(abcd[0])
op = [-1,-1,-1]
str_bit = bin(bit)

while bit<16:
  for i in range(3,6):
    if str_bit[i]=="1":
      op[i-3]=1
      ans+=int(abcd[i-2])
    else:
      op[i-3]=0
      ans-=int(abcd[i-2])
  
  if ans==7:
    for i in range(len(op)):
      if op[i]==1:
        op[i]="+"
      else:
        op[i]="-"
    print(abcd[0],op[0],abcd[1],op[1],abcd[2],op[2],abcd[3],"=7",sep='')
    exit()
  
  ans=int(abcd[0])
  bit+=1
  str_bit=bin(bit)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;

int main() {
	int a, b, c, d;
	scanf("%d%d%d%d ", &a, &b, &c, &d);
	int x = c - a, y = d - b;
	printf("%d %d %d %d\n ", c - y, d + x, a - y, b + x);


	
}

Measured memory_bytes: 256
def solve(N,M,P,S):
    counterAC = 0
    counterWA = 0
    dic = {key:"WA" for key in set(P)}
    counter = {key:0 for key in set(P)}
    for p,s in zip(P,S):
        if(dic[p] == "AC"):
            continue
        else:
            if(s == "AC"):
                counterAC += 1
                counterWA += counter[p]
                dic[p] = "AC"
            else:
                counter[p]+=1
    print(counterAC,counterWA)
def main():
    N,M = map(int,input().split())
    P = []
    S = []
    for _ in range(M):
        p,s=map(str,input().split())
        P.append(int(p))
        S.append(s)
    solve(N,M,P,S)
    # print(solve())

if __name__ == "__main__":
    main()


Measured memory_bytes: 37276
using System;
using System.Linq;

namespace ABC
{
    using System.Collections.Generic;
    using System.Runtime.InteropServices;
#if USE_STUB
    using static Stub.Console;
#else
    using static System.Console;
#endif
    using static System.Math;
    public class Program
    {
        static void Main(string[] args)
        {
            WriteLine(Solve());
        }

        static object Solve()
        {
            var line = ReadLine().Split().Select(int.Parse).ToArray();
            var a = line[0];
            var b = line[1];
            if (Abs((a + b) % 2) == 1)
                return "IMPOSSIBLE";

            return (a + b) / 2;
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define len(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>

signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s;
  cin >> s;
  cin >> s;
  cout << 'A' << s[0] << 'C' << endl;

  ret;
}


Measured memory_bytes: 3592
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll = long long;
const ll MOD = 1000000007; 

long pow_mod(long a,long n,long mod){
    long res=1;
    while(n>0){
        if(n&1){
            res = (res*a)%mod;
        }
        a = (a*a)%mod;
        n=(n>>1);
    }
    return res;
}
int main(){   
    ll N;
    cin>>N;
    bool flag = true;
    map<ll,ll> mp;
    for(ll i=0;i<N;i++){
        ll a;
        cin>>a;
        mp[a]++;
    }
    
    if(N%2==0){
        for(long i=0;i<N;i++){
            if(i%2==1&&mp[i]!=2){
                flag = false;
            }
            else if(i%2==0&&mp[i]>0){
                flag=false;
            }
        }
    }else{
        for(long i=0;i<N;i++){
            if(i==0&&mp[i]!=1){
                // cout<<i<<":"<<mp[i]<<endl;
                flag=false;
            }else if(i!=0&&i%2==0&&mp[i]!=2){
                // cout<<i<<":"<<mp[i]<<endl;
                // cout<<"AAA"<<endl;
                flag = false;
            }else if(i%2==1&&mp[i]>0){
                // cout<<i<<":"<<mp[i]<<endl;
                flag = false;
            }
        }
    }
    // cout<<flag<<endl;
    cout<<(flag?pow_mod(2,N/2,MOD):0)<<endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int F = 0;
  int count = 0;
  cin >> N;
  if(N < 0){
    F = 1;
  }
  vector<int> a(N);
  for(int i = 0;i < N;i++){
    cin >> a.at(i);
    if (a.at(i) > 100){
      break;
      F = 1;
    }
    if(i % 2 == 0 and a.at(i) % 2 == 1){
      count += 1;
    }
  }
  if (F != 1){
    cout << count << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong a, b;

int main() {

    cin >> a >> b;

    cout << a * b / __gcd(a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
a=list(map(int,input().split()))
if(len(set(a))==1 and a[0]==0):
    print("Yes")
elif(n%3!=0):
    print("No")
else:
    seta=list(set(a))
    nums=len(set(a))
    if(nums>3):
        print("No")
    elif(nums==3):
        if(a.count(seta[0])==n//3 and a.count(seta[1])==n//3 and a.count(seta[2]) and (seta[0] ^ seta[1] ^ seta[2] == 0)):
            print("Yes")
        else:
            print("No")
    elif(nums==2):
        seta.sort()
        if(seta[0]==0 and a.count(seta[0])==n//3):
            print("Yes")
        else:
            print("No")
    elif(nums==1):
        if(seta[0]==0):
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 14116
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define minimize(a,b) (a>(b)?a=(b),1:0)
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define ceil(a,b) (((a)+(b)-1)/(b))
#define yn(i) ((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}




string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}

int main(){
  string s; cin >>s;
  int d=0,ans=0,n=s.size();
  rep(i,n){
    if(s[i]=='S'){
      d+=1; continue;
    }
    if(d>0){
      d-=1; continue;
    }
    ans++;
  }
  print(ans+d);
}





Measured memory_bytes: 3660
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string s,ss,sss;
    cin >> s >> ss >> sss;

    cout << (char)toupper(s[0]) << (char)toupper(ss[0]) << (char)toupper(sss[0]) << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;


int main() {
    int n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    ll ans=0;
    if (p==2) {
        rep(i,n) {
            if ((s[i]-'0')%2==0) ans+=i+1;
        }
    } else if (p==5) {
        rep(i,n) {
            if ((s[i]-'0')%5==0) ans+=i+1;
        } 
    } else {
        vector<ll> a(p);
        int x;
        ++a[0];
        ll tenfactor=1;
        invrep(i,n) {
            x=(x+(s[i]-'0')*tenfactor)%p;
            ++a[x];
            tenfactor=(10*tenfactor)%p;
        }
        
        rep(i,p) ans+=a[i]*(a[i]-1)/2;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  
  long long W,H,x,y;
  //cin>>W>>H>>x>>y;
  cin>>W>>H>>x>>y;
  int oth = 0;
  if(x==W/2.0&&y==H/2.0)oth=1;
  cout<<(W*H/2.0)<<" "<<oth<<endl;
  /*
  if(H*y/W+x>W){
    x=W-x;
    y=H-y;
  }
  */
  
  
  return 0;
}

Measured memory_bytes: 256
import re

S = input()

if S[0] != "A":
    print("WA")
    exit()

if S.count("C") != 1:
    print("WA")
    exit()

if S[1].islower() and S[-1].islower() and len(re.findall('[a-z]', S)) == len(S)-2:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3188
/*
   О НЕТ! ОНИ ДОГОНЯЮТ!!!
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
*/

#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int N = 2e3 + 1;

vector <int> g[N];
int d, ans;

void dfs(int v, int pr, int dist)
{
    if (dist > d / 2)
    {
        ans++;
    }
    for (int to : g[v])
    {
        if (to != pr)
        {
            dfs(to, v, dist + 1);
        }
    }
}

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    int n;
    scanf("%d%d", &n, &d);
    for (int i = 1; i < n; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int res = n;
    if (d % 2 == 0)
    {
        for (int i = 0; i < n; i++)
        {
            ans = 0;
            dfs(i, -1, 0);
            res = min(res, ans);
        }
    }
    else
    {
        for (int i = 0; i < n; i++)
        {
            for (int to : g[i])
            {
                ans = 0;
                dfs(i, to, 0);
                dfs(to, i, 0);
                res = min(res, ans);
            }
        }
    }
    printf("%d\n", res);
}



Measured memory_bytes: 512
#include<stdio.h>
int main(void){
    int mouth=0;
    int want=0;
    int ans=0;
    int ima=1;
    int flag=0;

    scanf("%d",&mouth);
    scanf("%d",&want);

    while(flag==0){
        if(ima<want){
            ima=ima-1;
            ima=ima+mouth;
            ans++;
        }else{
            flag=1;
        }
    }

    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define loop(i, n) for(int i = 0; i < n; i++)
#define loop1(i, a, n) for(int i = a; i < n; i++)
#define PI 3.141592653589793238
#define bc __builtin_popcountll
#define pf push_front
#define pb push_back
#define rf pop_front
#define rb pop_back
#define fs first
#define sc second
#define mp make_pair
#define fi ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const ll INF = 1e9;
inline ll pwr(ll base, ll n, ll m) {ll ans = 1;while( n > 0 ) {if ( n & 1 ) ans = (ans * base) % m; base = (base * base) % m; n>>=1;}return ans;}


int main() {
    fi;
 
    // #ifndef ONLINE_JUDGE
    // freopen( "input.txt", "r", stdin );
    // freopen( "output.txt", "w", stdout );
    // #endif

    ll n, ans = 0;
    cin >> n;

    ans = ((n-1)*n)/2;
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
// #define MAX 110

int main(){
    int N, D, X, A[110], ans = 0;
    cin >> N >> D >> X;
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    
    for ( int i = 0; i < N; i++ ){
        for ( int j = 1; j <= D; j += A[i] ){
            ans++;
        }
        //cout << ans << endl; 
    }
    
    cout << ans + X << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, m;
    cin >> n >> m;
    int bi = 1;
    for(int i = 1; i <= m; ++i) bi <<= 1;
    cout << (n - m) * bi * 100 + 1900 * bi * m << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    string s;
    cin >> s;
    int n=s.length();
    int mn=n;
    rep(i,n){
        if(n==0)continue;
        if(s[i]!=s[i-1])chmin(mn,max(i,n-i));
    }
    cout << mn;
}
//000100010

Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int N=2010;

int n, m, k, u, v, x, y, t, a, b, sum;
int A[N];
bitset<N*N> dp;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	dp.set(0);
	for (int i=1; i<=n; i++){
		cin>>A[i];
		sum+=A[i];
		dp|=(dp<<A[i]);
	}
	for (int i=0; i<N*N; i++) if (dp[i] && sum<=2*i) kill(i)
	
	return 0;
}


Measured memory_bytes: 1792
use std::cmp::min;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n :i32 = read();
    let mut si :Vec<String> = Vec::new();
    for _ in 0..n {
        si.push(read::<String>());
    }
    let m: i32 = read();
    let mut ti :Vec<String> = Vec::new();
    for _ in 0..m {
        ti.push(read::<String>());
    }

    let mut cp = si.clone();
    cp.dedup();

    let mut ans = -100000000;
    for i in 0..cp.len(){
        let mut plus = 0;
        let mut mi = 0;
        for j in 0..n{
            if si[j as usize] == cp[i as usize] {
                plus += 1;
            }
        }
        for k in 0..m{
                if ti[k as usize] == cp[i as usize]{
                    mi += 1;
                }
        }
            if ans < plus - mi {
            ans = plus - mi;
    }

    }
    println!("{}",if ans < 0 {0} else {ans});
}

Measured memory_bytes: 4352
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;

int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
 
  ll w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<fixed<<setprecision(10)<<(double(w*h))/2.<<' ';
  if(w==2*x&&h==2*y) cout<<1;
  else cout<<0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    int ans=0;
    
    for(int i=0;i<S.size()/2;i++){
        if(S[i]!=S[S.size()-1-i]) ans++;
    }
    cout<<ans<<endl;
}



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

int main(){
  string S;
  cin >> S;
  int L = S.size();
  int ans = 0;
  for(int i=0; i<L-1; i++){
    if(S.at(i+1)!=S.at(i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
    int W,H,i,j;
    
    while(1){
        scanf("%d %d",&W,&H);
        if(W == 0 && H == 0) break;
        for(i = 0;i < W;i++){
            for(j = 0; j < H; j++){
                
                if(i == 0 || i == W - 1|| j == 0 || j == H - 1){
                printf("#");
                    }
                    
                else {
                    printf(".");
                    }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define rrep(i,l,r) for(int i=(r-1);i>=(l);i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define range(i) i.begin(),i.end()
#define sum(i) accumulate(range(i),0)
#define Yes(i) out(i?"Yes":"No")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}

int main(){
    string s;
    in(s);
    ll k;
    in(k);
    ll i=0;
    while (i<s.size()&&s[i]=='1')i++;
    out(i>=k?1:s[i]-'0');
}









Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;


int n, s, mv, to, t[105], v[105], z[40005];
int main() {
	int i, j=0;
	cin>>n;
	for(i=1; i<=n; i++) cin>>t[i], t[i]*=2;
	for(i=1; i<=n; i++) cin>>v[i], v[i]*=2;
	for(i=1; i<=n; i++) {
		to += t[i];
		z[j] = min(z[j], v[i]);
		for(++j; j<=to; j++) z[j] = min(z[j-1]+1, v[i]);
		j--;
	}
	for(i=j-1; i; i--) s += mv = min(z[i], mv+1);
	printf("%.9f", s/4.0);
	return 0;
}


// int N;
// vector<int> t,v;

// vector<int> define_path(){
// 	vector<int> path;
// 	int x = 0;
// 	int T = 0;

// 	for(int i=0;i<N;i++){
// 		path.push_back(min(x, v[i]));
// 		for(int j=T+1;j<T+t[i];j++){
// 			path.push_back(min(x+1,v[i]));
// 			x = min(x+1,v[i]);
// 		}
// 		T += t[i];
// 	}
// 	path.push_back(0);

// 	//cout << T+1 << " = " << path.size() << endl;

// 	x = 0;
// 	for(int i=N-1;0<=i;i--){
// 		path[T] = min(x,path[T]);
// 		for(int j=T-1;T-t[i]<=j;j--){
// 			path[j] = min(x+1,path[j]);
// 			x = min(x+1,path[j]);
// 		}
// 		T -= t[i];
// 	}

// 	return path;


// }

// int solve(){
// 	vector<int> path = define_path();

// 	//for(auto u:path) cout << u << endl;

// 	double ans = accumulate(path.begin(), path.end(),0)/4.0;

// 	printf("%.9f\n", ans);
// 	return 0;
// }

// int main(){
// 	cin >> N;
// 	t.resize(N);
// 	for(int i=0;i<N;i++){
// 		cin >> t[i];
// 		t[i] *= 2;
// 	}

// 	v.resize(N);
// 	for(int i=0;i<N;i++){
// 		cin >> v[i];
// 		v[i] *= 2;
// 	}

// 	solve();
// 	return 0;
// }

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int sum[501][501];
int lowbit(int x) {
    return x&-x;
}
void update(int x,int y) {
    for(int i = x;i > 0;i -= lowbit(i)) {
        for(int j = y;j <= n;j += lowbit(j)) {
            sum[i][j] ++;
        }
    }
}
int get(int x,int y) {
    int ans = 0;
    for(int i = x;i <= y;i += lowbit(i)) {
        for(int j = y;j >= x;j -= lowbit(j)) {
            ans += sum[i][j];
        }
    }
    return ans;
}
int main() {
    int m,q;
    scanf("%d%d%d",&n,&m,&q);
    int a,b;
    for(int i = 0;i < m;i ++) {
        scanf("%d%d",&a,&b);
        update(a,b);
    }
    for(int i = 0;i < q;i ++) {
        scanf("%d%d",&a,&b);
        printf("%d\n",get(a,b));
    }
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,x;
    long long ans=0;
    cin>>n;
    vector<long long> vec;
    map<long long,long long> mp;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        vec.push_back(x);
        mp[x]++;
    }
    for(auto x:mp)
    {
        long long y=x.second;
        ans+=(y*(y-1))/2;
    }
   // cout<<ans<<" ";

    for(int i=0;i<n;i++)
    {
        long long x=vec[i];
        long long y=mp[x];
        long long comb=(y*(y-1))/2;
        long long real=((y-1)*(y-2))/2;
        long long out=ans-comb+real;
        cout<<out<<endl;
    }
}



Measured memory_bytes: 11120