akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] t = in.nextIntArray(n);
			int[] v = in.nextIntArray(n);

			int m = Arrays.stream(t).sum() * 2 + 1;

			double[] maxV = new double[m];
			Arrays.fill(maxV, INF);

			int prt = 0;
			for (int i = 0; i < n; i++) {
				for (int k = 0; k <= 2 * t[i]; k++, prt++) {
					maxV[prt] = Math.min(v[i], maxV[prt]);
				}
				prt--;
			}
			
			maxV[0] = 0;
			for (int i = 0; i < m-1; i++) {
				maxV[i+1] = Math.min(maxV[i]+0.5, maxV[i+1]);
			}

			maxV[m-1] = 0;
			for (int i = m-1; i > 0; i--) {
				maxV[i-1] = Math.min(maxV[i]+0.5, maxV[i-1]);
			}

			double ans = 0;
			for (int i = 0; i < m-1; i++) {
				ans += (maxV[i+1] + maxV[i]) * 0.5 / 2;
			}
			
			out.println(ans);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 26708
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);

int main(){
	ll h, w, m; cin >> h >> w >> m;
	set<pair<ll,ll>> s;
	map<ll,ll> ycnt;
	map<ll,ll> xcnt;
	for(int i = 0; i < m; i++){
		ll y, x; cin >> y >> x;
		y--; x--;
		ycnt[y]++; xcnt[x]++;
		s.insert({y, x});
	}
	vector<ll> ymaxindex; vector<ll> xmaxindex;
	ll ymax = 0; ll xmax = 0;
	for(auto i : ycnt){
		ymax = max(ymax, i.second);
	}
	for(auto i : ycnt){
		if(i.second == ymax){
			ymaxindex.push_back(i.first);
		}
	}
	for(auto i : xcnt){
		xmax = max(xmax, i.second);
	}
	for(auto i : xcnt){
		if(i.second == xmax){
			xmaxindex.push_back(i.first);
		}
	}
	ll ans = ymax + xmax - 1;
	for(auto i : ymaxindex){
		for(auto j: xmaxindex){
			if(s.find({i,j}) == s.end()){
				cout << ans + 1 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 67908
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

int main() {
  ll a, b, x;

  cin >> a >> b >> x;

  cout << (a == b ? 0 : (b / x - a / x)) + (a % x == 0 ? 1 : 0) << endl;
 
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

main = do
  (h,w) <- getIntPair
  a <- replicateM h getLine
  let
    r i j = (i==0) || ((i < h-1) && (even j))
    b i j = (i==h-1) || ((i > 0) && (odd j))
  let
    ansR = [[if r i j || (a!!i!!j == '#') then '#' else '.' | j<-[0..w-1]] | i<-[0..h-1]]
    ansB = [[if b i j || (a!!i!!j == '#') then '#' else '.' | j<-[0..w-1]] | i<-[0..h-1]]
  mapM_ putStrLn ansR
  putStrLn ""
  mapM_ putStrLn ansB

solve a b c
  | any even [a,b,c] = 0
  | otherwise
  = let [x,y,_] = sort [a,b,c] in x*y
    

 
type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "YES"
yesNo False = "NO"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


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

int main(){
    long long a,b,c,d,h,aa,bb,cc,dd,ee,ff;
    cin >> a >> b >> c >> d;
    h=c*d/__gcd(c,d);
    aa=b/c;bb=b/d;cc=b/h;
    dd=(a-1)/c;ee=(a-1)/d;ff=(a-1)/h;
    long long q=aa+bb-cc-dd-ee+ff;
    long long ans=b-a+1-q;
    cout << ans << endl;

}

Measured memory_bytes: 256
//思维：任取一个p为根，距离为pa+pb-2pc,pa和pb同奇偶就偶，反之为奇 
//dfs?不会啊，跑dij得了，woc,边为1e5。。。 
//得学习容器和搜索 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
bool chest[N],vis[N];

struct node{
	int v;ll w;
	node(ll sw,int sv){
		w=sw,v=sv;
	}
};

vector<node>vec[2*N+1];//相当于开了一个动态的二维数组 

void dfs(int u,ll dis){
	for(int i=0;i<vec[u].size();i++){//连上它有的边 
		int vv=vec[u][i].v;
		if(vis[vv])continue;//到过了就不往下走了 
		vis[vv]=1;
		if((dis+vec[u][i].w)%2)
		chest[vv]=1;//图色1，默认为0 
		dfs(vv,dis+vec[u][i].w);//沿着点继续找 
	}
}

signed main(){
	int n;cin>>n;
	int u,v;ll w;
	for(int i=0;i<n-1;i++){
		cin>>u>>v>>w;
		vec[u].push_back(node(w,v));
		vec[v].push_back(node(w,u));//无向图 
	} 
	vis[1]=1;
	dfs(1,0);
	for(int i=1;i<=n;i++){
		cout<<chest[i]<<endl;
	}
	return 0;
}



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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))

typedef long long LL;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)

const ll mod=1000000007;
const ll INF=mod*mod;

vector<int> v;
bool isp[200000];
void init(){
  fill(isp+2,isp+200000,true);
  for(int i=3;i<200000;i++){
    if(!isp[i])continue;
    v.push_back(i);
    for(int j=2*i;j<200000;j+=i){
      isp[j]=false;
    }
  }
}
vector<int> G[100000];
int used[100000][2];
int main(){
  init();
  int n,m,s,g;cin>>n>>m>>s>>g;s--;g--;
  rep(i,m){
    int a,b;cin>>a>>b;a--;b--;G[a].push_back(b);G[b].push_back(a);
  }
  queue<int> q;q.push(s);
  int out=1000000;
  int cnt=0;
  while(!q.empty()){
    int t=cnt%2;
    int len=q.size();
    rep(i,len){
      int x=q.front();q.pop();
      used[x][t]=1;
      int l=G[x].size();
      rep(j,l){
        int nex=G[x][j];
        if(used[nex][t^1])continue;
        used[nex][t^1]=true;q.push(nex);
        if(cnt+1==2&&nex==g){
          out=min(out,2);
        }
        if(cnt%2==0&&nex==g){
          int le=lower_bound(v.begin(),v.end(),cnt+1)-v.begin();
          out=min(out,v[le]);
        }
      }
    }
    cnt++;
  }
  if(out==1000000)out=-1;
  cout<<out<<endl;
  return 0;
}



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

int main() {
  int N=0;
  cin >> N;
  vector<int> a(N+2);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
    
  int x=0,y=0;
  for(int i=0;i<N+1;i=i+2){
    x += a.at(i);
    y += a.at(i+1);
  }
  cout << x-y << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin>>n;
  for(int i=n;i<1000;i++){
	int a=i/100;
	int b=i/10%10;
	int c=i%10;
	if(a==b&&b==c){
	  cout<<i<<endl;
	  return 0;
	}
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] ins = br.readLine().split(" ");
		int N = Integer.parseInt(ins[0]), m = Integer.parseInt(ins[1]);

		// ノード配列作成
		Node[] nodes = new Node[N];
		for ( int i = 0; i < N; i++ ) {
			nodes[i] = new Node();
		}
		for ( int i = 0; i < m; i++ ) {
			ins = br.readLine().split(" ");
			int x = Integer.parseInt(ins[0]) - 1, y = Integer.parseInt(ins[1]) - 1;
			nodes[x].chldList.add(nodes[y]);
			nodes[y].prntCnt++;
		}

		// 始点サーチ
		ArrayDeque<Node> toCheck = new ArrayDeque<>();
		for ( Node node : nodes ) {
			if ( node.prntCnt == 0 ) toCheck.add(node);
		}

		// BFSで距離計算開始
		int lenMax = 0;
		while ( toCheck.size() > 0 ) {
			Node node = toCheck.pollFirst();
			for ( Node chld : node.chldList ) {
				chld.prntCnt--;
				chld.len = Math.max(node.len + 1, chld.len);
				// lenMax = Math.max(lenMax, chld.len);
				// 全辺をチェックした子はチェックリストへ
				if ( chld.prntCnt == 0 ) {
					toCheck.add(chld);
				}
			}
		}
		
		for(Node node : nodes) {
			lenMax = Math.max(lenMax, node.len);
		}
		System.out.println(lenMax);
	}
}

class Node{
	int				len			= 0;
	int				prntCnt		= 0;
	ArrayList<Node>	chldList	= new ArrayList<>();
}


Measured memory_bytes: 54080
s = input()

if s[0]=="R" and s[1] == "R" and s[2] == "R":
  print(3)
elif (s[0]=="R" and s[1]=="R") or (s[1]=="R" and s[2]=="R"):
  print(2)
elif s[0]=="S" and s[1] == "S" and s[2] == "S":
  print(0)
else:
  print(1)

Measured memory_bytes: 9116
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  D(((a * b > c * d) ? a * b : c * d));
  return 0;
}



Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    for j in range(i + 1, n-1):
        for k in range(j + 1, n):
            if len({l[i], l[j], l[k]}) != 3:
                continue
            if l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and l[j] + l[k] > l[i]:
                ans += 1
print(ans)


Measured memory_bytes: 9196
class Dice:
	def __init__(self, nums):
		self.cU = nums[0]
		self.cS = nums[1]
		self.cE = nums[2]
		self.cW = nums[3]
		self.cN = nums[4]
		self.cD = nums[5]
	def goN(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pS,pD,pU,pN
	def goE(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pW,pU,pD,pE
	def goW(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pE,pD,pU,pW
	def goS(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pN,pU,pD,pS
nums = [int(i) for i in input().split(' ')]
di = Dice(nums)
for op in input():
	if op == 'N': di.goN()
	elif op == 'E': di.goE()
	elif op == 'W': di.goW()
	elif op == 'S': di.goS()
print(di.cU)


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

int main()
{
    int ss, h, m, s;
    cin >> ss;
    
    h = ss / 3600;
    m = (ss - h * 3600) / 60;
    s = ss - (h * 3600 + m * 60);
    
    cout << h <<":" << m << ":" << s << endl;
    
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
vector<int> e[MAXN+5]; int s[MAXN+5], c[MAXN+5], n, r, f, m, Ans; string S = "B", _;
void DFS(int p, int fa){s[p] = S[p]=='W', c[p] = (S[p]!='B')^!!fa; for(auto v:e[p]) if(v^fa) DFS(v,p), s[p] += s[v], c[p] ^= !!s[v];}
void Dia(int p, int fa, int d){d>m||(d==m&&!c[p])?m=d,f=p:0; for(auto v:e[p]) if(s[v]&&v^fa) Dia(v,p,d+(c[v]<<1));}
void Cal(int p, int fa){Ans += c[p]; for(auto v:e[p]) if(s[v]&&v^fa) Cal(v,p), Ans += 2;}
int main()
{
	n = read(); for(rint i = 2, a, b; i <= n; a = read(), b = read(), e[a].push_back(b), e[b].push_back(a), i++); cin >> _, S = S+_;
	if((r=S.find('W'))==-1) return puts("0"),0; DFS(r,0), Cal(r,0), Dia(f=r,0,m=c[r]<<1), Dia(r=f,0,m=c[f]<<1), printf("%d\n",Ans-m+((c[r]&&c[f])<<1)); return 0;
}

Measured memory_bytes: 12928
w = input()
we = list(w)
count = 0
m_count = 0

for i in we:
    if i == "R":
        count += 1
    else:
        if count > m_count:
            m_count = count
        count = 0

if count > m_count:
    m_count = count
print(m_count)

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


int main(){
    ll N;
    string s;
    cin >> N;
    cout << 0 <<endl<<flush;
    cin >> s;
    ll sts;
    if(s == "Vacant"){
        return 0;
    }else if(s == "Male"){
        sts = 0;
    }else{
        sts = 1;
    }
    //ll pre = 0;
    ll L = -1;
    ll R = N;
    while(L  < R -1){
        ll x = (L+R)/2;
        cout << x << endl <<flush;
        cin >> s;
        if(s == "Vacant"){
            return 0;
        }else if(s == "Male"){
            if((x)%2 == 0 && !sts){
                L = x;
                //cout << "a";
            }else if((x)%2 == 1 && sts){
                L = x;
                //cout << "b";
            }else{
                R = x;
                //cout << "c";
            }       
        }else{
            if((x)%2 == 0 && sts){
                L = x;
            }else if((x)%2 == 1 && !sts){
                L = x;
            }else{
                R = x;
            }
        }

    }
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1e9
 
class Fraction{
public:;
    double numerator,denominator;
    double div();
};
 
double Fraction::div(){
    return numerator/denominator;
}
 
ostream &operator << (ostream &os,const Fraction &f){
    os << f.numerator << '/' << f.denominator;
    return os;
}
 
int main(){
    double p;
    int n;
    while(cin >> p >> n, p){
	p = sqrt(p);
	Fraction a = (Fraction){-1,1};
	Fraction b = (Fraction){INF,1};
	for(int den = 1 ; den <= n ; den++){
	    int l = 0, r = n+1;
	    while(l < r){
		double mid = (l + r) / 2;
		if(mid < p*den){
		    if(mid/den > a.div()){
			a = (Fraction){mid,den};
		    }
		    l = mid+1;
		}else{
		    r = mid;
		}
	    }
	    l = 0, r = n+1;
	    while(l < r){
		double mid = (l + r) / 2;
		if(mid > p*den){
		    if(mid/den < b.div()){
			b = (Fraction){mid,den};
		    }
		    r = mid;
		}else{
		    l = mid+1;
		}
	    }
	}
	cout << b << " " << a << endl;
    }
    return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i).first;
        a.at(i).second = i+1;
    }
    sort(a.begin(), a.end());
    for (int i=0; i<n; i++) {
        cout << a.at(i).second << " ";
    }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
int main(){
  long long n;
  long long sum=0;
  long long a[220000];
  long long count[220000]={0};
  long long comb[220000];
  long long minus[220000];
  
  cin >> n;
  rep1(i,n){
    long long x;
    cin >> x;
    a[i] = x;
    count[x]++;
  }
  rep1(i,n){
    if(count[i]==0){
      comb[i]=0; minus[i]=0;
    }
    else{
      comb[i] = count[i]*(count[i]-1)/2;
      minus[i] = (count[i]-1)*(count[i]-2)/2;
    }
    sum += comb[i];
  }
  rep1(i,n){
    cout << sum - comb[a[i]] + minus[a[i]] << endl;
  }
}

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

int main(){
  string s;
  cin>>s;
  int count=0;

  for(int i=0;i<s.size();i++){
    int a=0;
    for(int j=i;j<s.size();j++){
      if(s[j]=='A' ||s[j]=='G' || s[j]=='C' || s[j]=='T'){
        a++;
        count=max(a,count);
      }
      else break;
    }
  }
  cout<<count<<endl;
}

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

int main()
{
    int n,i,j,a,b;
    scanf("%d",&n);
    if(n==1)
    {
        cout<<"Hello World"<<endl;
    }
    else
    {
        cin>>a>>b;
        cout<<a+b<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<string.h>

int main(void){
  int i;
  int n, nstuo, nstut; 
  bool stu[30];

  memset(stu,false,sizeof(stu));

  for (i = 0;i < 28;i++){
    scanf("%d", &n);

    stu[n-1] = true;
  }

  for (i = 0;i < 30;i++){
    if (stu[i] == false){
      nstuo = i + 1;
      stu[i] = true;
      break;
    }
  }

  for (i = 0;i < 30;i++){
    if (stu[i] == false){
      nstut = i + 1;
      stu[i] = true;
      break;
    }
  }

  printf("%d\n%d\n", nstuo, nstut);

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k,p;
	char str[15],str2[15],str3[15];
	scanf("%lld%lld%lld%lld",&n,&m,&k,&p);
	
		printf("%lld",big(n*m,k*p));
	
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	ll x, y, z, n, k, cnt = 0, pp, h, l;
	string s, s1, s2;
	vector<ll>listx,listy,listz;
	vector<ll>list1, list2;
	int sum = 0, maxn = -9999, minn = 199999999999999;

	cin >> x >> y >> z >> k;



	for (ll i = 0; i < x; i++) {
		ll num;
		cin >> num;
		listx.push_back(num);

	}

	for (int i = 0; i < y; i++) {
		int num;
		cin >> num;
		listy.push_back(num);

	}

	for (int i = 0; i < z; i++) {
		int num;
		cin >> num;
		listz.push_back(num);

	}

	/*sort(listx.begin(), listx.end(), greater<int>());
	sort(listy.begin(), listy.end(), greater<int>());
	sort(listz.begin(), listz.end(), greater<int>());*/


	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			list1.push_back(listx[i] + listy[j]);
		}
	}

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


	for (int i = 0; i < list1.size() && i < k; i++) {
		for (int j = 0; j < z; j++) {
			list2.push_back(list1[i] + listz[j]);
		}
	}

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



	for (int i = 0; i < k; i++) {
		cout << list2[i] << endl;
	}




	
	getchar();
	getchar();
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> lbs(m);
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int l;
            cin >> l;
            lbs[i].push_back(l);
        }
    }
    int ans = 0;
    vector<int> p(m);
    for (int i = 0; i < m; i++)
        cin >> p[i];

    for (int bit = 0; bit < (1 << n); bit++)
    {
        set<int> a;
        for (int i = 0; i < n; i++)
        {
            if (bit & (1 << i))
                a.insert(i + 1);
        }
        int l = 0;
        vector<int> c(m, 0);
        for (int j = 0; j < m; j++)
        {
            int cnt = 0;
            for (int k = 0; k < lbs[j].size(); k++)
            {
                if (a.count(lbs[j][k]))
                    c[j]++;
            }
        }
        bool check = true;
        for (int j = 0; j < m; j++)
        {
            if (c[j] % 2 != p[j])
                check = false;
        }
        if (check)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,t,mn=1e9,d,cnt=1,a[101010];
int main()
{
	cin>>n>>t;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mn=min(mn,a[i]);
		if(d==a[i]-mn)
		{
			cnt++;
		}
		else if(d<a[i]-mn)
		{
			d=a[i]-mn;
			cnt=1;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

double dp[3000][3000];

int main()
{
    string s;
    cin >> s;

    bool bad = (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]);

    cout << (bad ? "Bad" : "Good") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];

void floyd() {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            if (d[i][k] == INFTY) continue;
            for (int j = 0; j < n; j++) {
                if (d[k][j] == INFTY) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    int e, u, v, c;
    cin >> n >> e;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            d[i][j] = ((i == j) ? 0 : INFTY);
        }
    }
    for (int i = 0; i < e; i++) {
        cin >> u >> v >> c;
        d[u][v] = c;
    }
    floyd();
    bool negative = false;
    for (int i = 0; i < n; i++) {
        if (d[i][i] < 0) negative = true;
    }
    if (negative) {
        cout << "NEGATIVE CYCLE" << endl;
    }
    else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j) cout << " ";
                if (d[i][j] == INFTY) cout << "INF";
                else cout << d[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;

    int n=s.length();
    int m=t.length();

    int change=n;
    for(int i=0;i<=(n-m);i++)
    {
        int c=0;
        for(int j=0;j<m;j++)
        {
            if(t[j]!=s[i+j])
                c++;
        }

        change=min(change,c);
    }

    cout<<change;

    return 0;
}

Measured memory_bytes: 3600
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
/* contest template */

int main()
{
	string s;
	cin >> s;
	int a, b, c, d;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
	if (a + b + c + d == 7) {
		cout << a << "+" << b << "+" << c << "+" << d << "=7\n";
	}
	else if (a + b + c - d == 7) {
		cout << a << "+" << b << "+" << c << "-" << d << "=7\n";
	}
	else if (a + b - c + d == 7) {
		cout << a << "+" << b << "-" << c << "+" << d << "=7\n";
	}
	else if (a + b - c - d == 7) {
		cout << a << "+" << b << "-" << c << "-" << d << "=7\n";
	}
	else if (a - b + c + d == 7) {
		cout << a << "-" << b << "+" << c << "+" << d << "=7\n";
	}
	else if (a - b + c - d == 7) {
		cout << a << "-" << b << "+" << c << "-" << d << "=7\n";
	}
	else if (a - b - c + d == 7) {
		cout << a << "-" << b << "-" << c << "+" << d << "=7\n";
	}
	else if (a - b - c - d == 7) {
		cout << a << "-" << b << "-" << c << "-" << d << "=7\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
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(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 3
#define MAX 1000
#else
#define SIZE 80
#define MAX 30000
#endif

int H,W,a,b;
int M[SIZE][SIZE]={},DP[SIZE][SIZE][MAX]={};
int base = MAX/2;

void solve() {
    cin>>H>>W;
    REP(h,H)REP(w,W) {
        cin>>a;
        M[h][w]+=a;
    }
    REP(h,H)REP(w,W) {
        cin>>a;
        M[h][w]-=a;
    }
    DP[0][0][base + M[0][0]] = 1;
    DP[0][0][base - M[0][0]] = 1;
    REP(h,H)REP(w,W)REP(j,MAX)if(DP[h][w][j]) {
        if (h<H-1) DP[h+1][w][j+M[h+1][w]] = 1;
        if (h<H-1) DP[h+1][w][j-M[h+1][w]] = 1;
        if (w<W-1) DP[h][w+1][j+M[h][w+1]] = 1;
        if (w<W-1) DP[h][w+1][j-M[h][w+1]] = 1;
    }
    int ans = INT_MAX;
    REP(j,MAX) {
        if (DP[H-1][W-1][j]) {
            chmin(ans, abs(j-base));
        }
    }
    _PN(ans);
}



Measured memory_bytes: 669236
S = input()
K = int(input())

import math

C = 0
if S[0]==S[-1]:
    C = 1
if all([True if S[0]==S[i] else False for i in range(len(S))]):
    C = 2

f = '!'
count = 0
if C == 0:
    #print('違う時')
    for i in range(len(S)):
        if S[i]==f:
            count += 1
            f = '!'
        else:
            f = S[i]
    print(K*count)
elif C==1:
    #print('同じ時')
    count = 0
    #前何文字同じかチェック
    Fflag = 0
    for i in range(len(S)):
        if S[i]==S[0]:
            Fflag += 1
        else:
            break
    Bflag = 0
    for j in range(len(S))[::-1]:
        if S[j]==S[-1]:
            Bflag += 1
        else:
            break
    f = '!'
    for k in range(Fflag,len(S)-Bflag):
        if S[k]==f:
            count += 1
            f = '!'
        else:
            f = S[k]
    print(math.floor(Fflag/2) + math.floor(Bflag/2)+ count*K + math.floor((Fflag+Bflag)/2)*(K-1))
elif C == 2:
    print(math.floor(len(S)*K/2))

Measured memory_bytes: 3064
i=0
while True:
    X=int(input())
    if X==0:
        break
    x=1000-X
    a=x//500
    b=x%500//100
    c=x%500%100//50
    d=x%500%100%50//10
    e=x%500%100%50%10//5
    f=x%500%100%50%10%5
    print(a+b+c+d+e+f)
   


Measured memory_bytes: 5588
#include<cstdio>
#include<iostream>
#include<string>
#include<cctype>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

string toUpper( string s ) {
    int i = 0;
    int n = s.size();
    while ( i < n ) {
        s[i] = toupper(s[i]);
        i++;
    }

    return s;
}

int main() {
    string word;
    cin >> word;
    
    word = toUpper(word);
    
    int i = 0;
    while (1) {
        string sample;
        cin >> sample;
        if ( sample == "END_OF_TEXT" ) break;
        
        sample = toUpper(sample);

        if ( word == sample ) {
            i++;
        }
    }
    cout << i << endl;

    return 0;
}


Measured memory_bytes: 3164
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=1e9+7;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	//道がない->違う都市
	//補グラフをつくってえいえい
	int h,i,j,n,m;cin>>n>>m;
	static bool aru[700][700];
	for(i=0;i<m;i++){
		int a,b;cin>>a>>b;a--;b--;
		aru[a][b]=1;
		aru[b][a]=1;
	}
	for(i=0;i<n;i++){aru[i][i]=1;}
	static int doti[700];
	for(i=0;i<n;i++){doti[i]=-1;}
	//大体半分半分に分けたい
	bitset<701>dp;
	dp[0]=1;
	for(h=0;h<n;h++){
		if(doti[h]!=-1){continue;}
		queue<int>que;
		que.push(h);doti[h]=0;
		int ue=0,st=0;
		while(que.size()>0){
			int ter=que.front();que.pop();
			int now=doti[ter];
			if(doti[ter]){ue++;}else{st++;}
			for(i=0;i<n;i++){
				if(aru[ter][i]){continue;}
				if(doti[i]==-1){que.push(i);doti[i]=1-doti[ter];}
				else if(doti[i]==doti[ter]){cout<<-1<<endl;return 0;}
			}
		}
		dp=(dp<<ue)|(dp<<st);
	}
	for(i=n/2;i>=0;i--){
		if(dp[i]){cout<<n*(n-1)/2 - i*(n-i)<<endl;return 0;}
	}
	return 0;
}

Measured memory_bytes: 768
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n,a,b,c,d=map(int,input().split())
s=input()
for i in range(b-1,d-1):
    if s[i]=="#" and s[i+1]=="#":
        print("No")
        quit()

if c<d:
    for i in range(a-1,c-1):
        # print(s[i],s[i+1])
        if s[i]=="#" and s[i+1]=="#":
            print("No")
            quit()

else:
    flag=0
    for i in range(b-2,d-1):
        # print(s[i],s[i+1],s[i+2])
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            flag=1
    if flag==0:
        print("No")
        quit()
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            print("No")
            quit()
print("Yes")

Measured memory_bytes: 65912
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;

int main( void ) {
    string s;
    while( cin >> s && s != "0" ) {
        int num = 0;
        for( int i = 0; i < s.length(); ++i ) num += s[i] - '0';
        cout << num << '\n';
    }
    return 0;
}



Measured memory_bytes: 3180
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(nums []int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInts(3)
	m := max(a)
	d := 0
	for i := range a {
		d += m - a[i]
	}
	if d&1 == 0 {
		puts(d / 2)
	} else {
		puts(d/2 + 2)
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf r,g,b;
    cin >>r >> g>>b;

    if((g*10+b)%4==0){
        cout << "YES" <<endl;
    }else{
        cout << "NO" <<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a(int a,int b){return a+b;}
int b(int a,int b){return a-b;}
int c(int a,int b){return a*b;}
int d(int a,int b){return a/b;}
int main(){
  int n,m;
  char op;
  while(cin >> n >> op >> m&& op!='?'){
    if(op=='+')cout << a(n,m) << endl;
    else if(op=='-')cout << b(n,m) << endl;
    else if(op=='*')cout << c(n,m) << endl;
    else if(op=='/')cout << d(n,m) << endl;
  }
}


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

int main(){
  int N;  cin >> N;
  char a;
  vector<char> S;
  for(int i = 0;i < N;i++){//
    cin >> a;
    S.push_back(a);
  }

  int max = 0;

  for(int i = 1;i <= N-1;i++){//Xとして取る文字の個数

    bool alpha[26] = {};
    bool beta[26] = {};

    //各アルファベットがX,Yに入っているかどうかの確認.
    for(int j = 0;j < i;j++){
      alpha[S[j] - 'a'] = true;
    }
    for(int k = i;k < N;k++){
      beta[S[k] - 'a'] = true;
    }

    int count = 0;


    for(int l = 0;l < 26;l++){
      if(alpha[l] == true and beta[l] == true)count++;
    }

    if(max < count)max = count;


  }

  cout << max << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c;cin>>a>>b>>c;
  for(ll i=a;i<=a*b;i+=a){
    if(i%b==c){
      cout<<"YES";
      return 0;
    }
  }
  cout<<"NO";
}

Measured memory_bytes: 23680
import java.util.Scanner;

class Main {
    public static void main (String args[]) {
	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();
	double debt = 100; //100,000 / 1,000
	double interest = 0;

	for (int i=0; i<n; i++) {
	    interest = debt * 0.05;
	    debt += interest;
	    debt = Math.ceil(debt);
	}

	System.out.printf("%.0f\n", (debt*1000));
    }
}

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

int main(){
    int N, A, B, C, D;
    cin>>N>>A>>B>>C>>D;

    int x=0;
    int y=0;

    x=(N+(A-1))/A;
    y=(N+(C-1))/C;

    int a=0;
    int b=0;

    a=x*B;
    b=y*D;

    if(a<b){
        cout<<a<<endl;
    }else{
        cout<<b<<endl;
    }

return 0;

}


Measured memory_bytes: 3080
mod = 10**9+7
input()
a = map(int, input().split())
a = [x%mod for x in a]
def sum(arr):
    res = 0
    for e in arr:
        res += e
        res %= mod
    return res
print((sum(a)**2 - sum(x**2%mod for x in a)) * (10**9//2+4) % mod)

Measured memory_bytes: 31576
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(1, N):
    A[i] += A[i - 1]
A = [0] + A
dic = defaultdict(int)

for i in A:
    dic[i % M] += 1

num = 0
for k, v in dic.items():
    num += v * (v - 1) // 2

print(num)

Measured memory_bytes: 62576
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def distance(x1, y1, x2, y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

def distance_p(a, b):
    return distance(a[0], a[1], b[0], b[1])

def distance3(p1, p2, p3):
    x1,y1 = p1
    x2,y2 = p2
    x3,y3 = p3

    ax = x2 - x1
    ay = y2 - y1
    bx = x3 - x1
    by = y3 - y1

    r = (ax*bx + ay*by) / (ax*ax + ay*ay)
    pt = (x1 + r*ax, y1 + r*ay, 0)
    return distance_p(pt, p3)

def gaisin(xy):
    a = xy[0][0]
    b = xy[0][1]
    c = xy[1][0]
    d = xy[1][1]
    e = xy[2][0]
    f = xy[2][1]

    t1 = (e-a) * (a**2 + b**2 - c**2 - d**2)
    t2 = (c-a) * (a**2 + b**2 - e**2 - f**2)
    t3 = 2 * (e-a) * (b-d) - 2 * (c-a) * (b-f)
    py = (t1 - t2) / t3
    if c - a != 0:
        px = (2 * (b-d) * py - a**2 - b**2 + c**2 + d**2) / (2 * (c-a))
    else:
        px = (2 * (b-f) * py - a**2 - b**2 + e**2 + f**2) / (2 * (e-a))
    return (px, py)

def main():
    n = I()
    xy = [LI() for _ in range(n)]

    if n == 2:
        return distance_p(xy[0], xy[1]) / 2

    r = inf
    for i in range(n):
        t1 = xy[i]
        for j in range(i+1, n):
            t2 = xy[j]
            p = ((t1[0]+t2[0]) / 2, (t1[1]+t2[1]) / 2)
            tr = max(distance_p(p, xy[l]) for l in range(n))
            if r > tr:
                r = tr
            xf = t1[0] == t2[0]
            yf = t1[1] == t2[1]
            for k in range(j+1, n):
                t3 = xy[k]
                if distance3(t1, t2, t3) < eps:
                    continue
                p = gaisin([t1, t2, t3])
                tr = max(distance_p(p, xy[l]) for l in range(n))
                if r > tr:
                    r = tr

    return r

print(main())





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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll h, w;
  cin >> h >> w;
  char a[h][w];

  REP(i, h) {
    REP(j, w) { cin >> a[i][j]; }
  }

  REP(i, w + 2) { cout << "#"; }
  cout << "\n";
  REP(i, h) {
    REP(j, w) {
      if (j == 0) cout << "#";
      cout << a[i][j];
      if (w == j + 1)
        cout << "#"
             << "\n";
    }
  }
  REP(i, w + 2) { cout << "#"; }
  cout << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0); 
	int a,b;
	cin>>a>>b;
	if(a<=5)cout<<0;
	else if(a>=6&&a<=12)cout<<b/2;
	else cout<<b;
}


Measured memory_bytes: 256
N = int(input())
reds = [tuple(map(int, input().split())) for _ in range(N)]
blues = [tuple(map(int, input().split())) for _ in range(N)]

reds.sort(key=lambda x: x[0], reverse=True)
blues.sort(key=lambda x: x[0])

res = 0
for r in reds:
    b_list = [b for b in blues if r[0] < b[0] and r[1] < b[1]]

    if len(b_list):
        b = min(b_list, key=lambda x: x[1])
        blues.remove(b)
        res += 1

print(res)


Measured memory_bytes: 3188
n = int(input())
a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))

sum_a_1 = [0]
sum_a_2 = [0]
for i in range(n):
    sum_a_1.append(sum_a_1[-1] + a_1[i])
    sum_a_2.append(sum_a_2[-1] + a_2[n-i-1])
    
res = 0
for i in range(n):
    res = max(res, sum_a_1[i+1] + sum_a_2[n-i])

print(res)

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

const int Maxn = 300005;

int n;
string s;
int res = Maxn;

int main()
{
	cin >> n;
	cin >> s;
	int sum = 0;
	for (int i = 0; i < s.length(); i++)
		sum += s[i] == 'E';
	for (int i = 0; i < s.length(); i++) {
		sum -= s[i] == 'E';
		res = min(res, sum);
		sum += s[i] == 'W';
	}
	printf("%d\n", res);
	return 0;
}

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

typedef long long LL;
typedef unsigned long long ULL;
const int MAXN=5005;
const int mod=998244353;
const LL INF=1e18+10;
const double EPS=1e-8;

int n,m,L;
int x[30];

int main(){
    scanf("%d",&L);
    n=m=0;
    while(L){
        x[++n]=L%2;
        m+=x[n];
        L/=2;
    }
    reverse(x+1,x+n+1);
    m+=2*(n-1)-1;
    printf("%d %d\n",n,m);
    for(int i=1;i<n;i++)
        printf("%d %d 0\n%d %d %d\n",i,i+1,i,i+1,1<<(n-i-1));
    int val=(1<<(n-1));
    for(int i=2;i<=n;i++){
        if (x[i]==0) continue;
        printf("1 %d %d\n",i,val);
        val+=(1<<(n-i));
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] red = new int[N][2];
        int[][] blue = new int[N][2];
        HashSet<Integer> taken = new HashSet<>();
        for(int i=0;i<N;i++){
            red[i][0] = sc.nextInt(); // x-coordinate
            red[i][1] = sc.nextInt();
        }
        for(int i=0;i<N;i++){
            blue[i][0] = sc.nextInt(); // x-coordinate
            blue[i][1] = sc.nextInt();
        }
        myComparator mc = new myComparator();
        Arrays.sort(red,mc);
        Arrays.sort(blue,mc);
        for(int j=0;j<N;j++){
            int i=0;
            int bx = blue[j][0];
            int by = blue[j][1];
            int yMax = Integer.MIN_VALUE;
            int pos = -1;
            while(i<N&&red[i][0]<bx){
                if(taken.contains(i)||red[i][1]>=by) {
                    i++;
                    continue;
                }
                if(red[i][1]>yMax){
                    yMax = red[i][1];
                    pos = i;
                }
                i++;
            }
            if(pos != -1){ // means that there is a red point satisfying the condition
                taken.add(pos);
            }
        }
        System.out.println(taken.size());
    }
    static class myComparator implements Comparator<int[]>{
        public int compare(int[]a, int[]b){
            return a[0]-b[0];
        }
    }
}


Measured memory_bytes: 24148
#include<bits/stdc++.h> 
using namespace std;
int n, k, a[105], c, d, s;
int main(){
	scanf("%d%d", &n, &k);
	for(int i=1; i<=k; i++){
		scanf("%d", &c);
		for(int p=1; p<=c; p++){
			scanf("%d", &d);
			a[d]++;
		}
	}
	for(int i=1; i<=n; i++){
		if(a[i]!=0){
			s++;
		}
	}
	printf("%d", n-s);
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const ll MOD = (ll)1e9 + 7LL;
ll dp[(int)1e5 + 5][4];

int main()
{
	memset(dp, 0LL, sizeof(dp));
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	string S; cin >> S;
	int N = (int)S.length();
	
	dp[0][0] = 1LL;
	rep (i, N){
		rep (j, 4){
			dp[i+1][j] += dp[i][j] * (S[i] == '?' ? 3LL : 1LL);
			if (j < 3 && (S[i] == '?' || S[i] == "ABC"[j])){
				dp[i+1][j+1] += dp[i][j];
			} // end if
			dp[i+1][j] %= MOD;
		} // end rep
	} // end rep

	cout << dp[N][3] << endl;

	return 0;
}

Measured memory_bytes: 3664